Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / net / spdyproxy / data_reduction_proxy_settings_android.h
blobe79be28b89fee7ef722976859e12ea28454deee0
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 IncrementLoFiSnackbarShown(JNIEnv* env, jobject obj);
47 void IncrementLoFiUserRequestsForImages(JNIEnv* env, jobject obj);
48 void SetDataReductionProxyEnabled(JNIEnv* env, jobject obj, jboolean enabled);
50 jlong GetDataReductionLastUpdateTime(JNIEnv* env, jobject obj);
51 ScopedJavaLocalRef<jlongArray> GetDailyOriginalContentLengths(JNIEnv* env,
52 jobject obj);
53 ScopedJavaLocalRef<jlongArray> GetDailyReceivedContentLengths(JNIEnv* env,
54 jobject obj);
56 // Return a Java |ContentLengths| object wrapping the results of a call to
57 // DataReductionProxySettings::GetContentLengths.
58 base::android::ScopedJavaLocalRef<jobject> GetContentLengths(JNIEnv* env,
59 jobject obj);
61 // Determines whether the data reduction proxy is unreachable. This is
62 // done by keeping a count of requests which go through proxy vs those
63 // which should have gone through the proxy based on the config.
64 jboolean IsDataReductionProxyUnreachable(JNIEnv* env, jobject obj);
66 ScopedJavaLocalRef<jstring> GetTokenForAuthChallenge(JNIEnv* env,
67 jobject obj,
68 jstring host,
69 jstring realm);
71 // Returns a Java string of the Data Reduction Proxy proxy list for HTTP
72 // origins as a semi-colon delimited list.
73 ScopedJavaLocalRef<jstring> GetHttpProxyList(JNIEnv* env, jobject obj);
75 // Returns a Java string of the Data Reduction Proxy proxy list for HTTPS
76 // origins as a semi-colon delimited list.
77 ScopedJavaLocalRef<jstring> GetHttpsProxyList(JNIEnv* env, jobject obj);
79 // Returns a Java string of the last Data Reduction Proxy bypass event as
80 // a JSON object.
81 ScopedJavaLocalRef<jstring> GetLastBypassEvent(JNIEnv* env, jobject obj);
83 // Registers the native methods to be call from Java.
84 static bool Register(JNIEnv* env);
86 private:
87 friend class DataReductionProxySettingsAndroidTest;
88 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest,
89 TestGetDailyContentLengths);
91 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env,
92 const char* pref_name);
94 virtual data_reduction_proxy::DataReductionProxySettings* Settings();
96 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid);
99 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_