Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / net / spdyproxy / data_reduction_proxy_settings_android.h
blob3da9e4842b86911dafe456d3da59a88252b3a8ea
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_
8 #include "base/android/jni_string.h"
9 #include "base/android/jni_weak_ref.h"
10 #include "base/android/scoped_java_ref.h"
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/prefs/pref_member.h"
17 using base::android::ScopedJavaLocalRef;
19 class Profile;
21 namespace data_reduction_proxy {
22 class DataReductionProxySettings;
25 // Central point for configuring the data reduction proxy on Android.
26 // This object lives on the UI thread and all of its methods are expected to
27 // be called from there.
28 class DataReductionProxySettingsAndroid {
29 public:
30 DataReductionProxySettingsAndroid();
32 virtual ~DataReductionProxySettingsAndroid();
34 void InitDataReductionProxySettings(Profile* profile);
36 // JNI wrapper interfaces to the indentically-named superclass methods.
37 jboolean IsDataReductionProxyAllowed(JNIEnv* env, jobject obj);
38 jboolean IsDataReductionProxyPromoAllowed(JNIEnv* env, jobject obj);
39 jboolean IsIncludedInAltFieldTrial(JNIEnv* env, jobject obj);
40 jboolean IsDataReductionProxyEnabled(JNIEnv* env, jobject obj);
41 jboolean CanUseDataReductionProxy(JNIEnv* env, jobject obj, jstring url);
42 jboolean WasLoFiModeActiveOnMainFrame(JNIEnv* env, jobject obj);
43 jboolean WasLoFiLoadImageRequestedBefore(JNIEnv* env, jobject obj);
44 void SetLoFiLoadImageRequested(JNIEnv* env, jobject obj);
45 jboolean IsDataReductionProxyManaged(JNIEnv* env, jobject obj);
46 void IncrementLoFiUserRequestsForImages(JNIEnv* env, jobject obj);
47 void SetDataReductionProxyEnabled(JNIEnv* env, jobject obj, jboolean enabled);
49 jlong GetDataReductionLastUpdateTime(JNIEnv* env, jobject obj);
50 ScopedJavaLocalRef<jlongArray> GetDailyOriginalContentLengths(JNIEnv* env,
51 jobject obj);
52 ScopedJavaLocalRef<jlongArray> GetDailyReceivedContentLengths(JNIEnv* env,
53 jobject obj);
55 // Return a Java |ContentLengths| object wrapping the results of a call to
56 // DataReductionProxySettings::GetContentLengths.
57 base::android::ScopedJavaLocalRef<jobject> GetContentLengths(JNIEnv* env,
58 jobject obj);
60 // Determines whether the data reduction proxy is unreachable. This is
61 // done by keeping a count of requests which go through proxy vs those
62 // which should have gone through the proxy based on the config.
63 jboolean IsDataReductionProxyUnreachable(JNIEnv* env, jobject obj);
65 ScopedJavaLocalRef<jstring> GetTokenForAuthChallenge(JNIEnv* env,
66 jobject obj,
67 jstring host,
68 jstring realm);
70 // Registers the native methods to be call from Java.
71 static bool Register(JNIEnv* env);
73 private:
74 friend class DataReductionProxySettingsAndroidTest;
75 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest,
76 TestGetDailyContentLengths);
78 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env,
79 const char* pref_name);
81 virtual data_reduction_proxy::DataReductionProxySettings* Settings();
83 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid);
86 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_