OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ | 6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
7 | 7 |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/android/jni_weak_ref.h" | 9 #include "base/android/jni_weak_ref.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/prefs/pref_member.h" | 15 #include "base/prefs/pref_member.h" |
16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | |
17 #include "components/keyed_service/core/keyed_service.h" | |
18 | 16 |
19 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
20 | 18 |
21 class Profile; | 19 class Profile; |
22 | 20 |
23 namespace data_reduction_proxy { | 21 namespace data_reduction_proxy { |
24 class DataReductionProxyParams; | 22 class DataReductionProxySettings; |
25 } | 23 } |
26 | 24 |
27 // Central point for configuring the data reduction proxy on Android. | 25 // Central point for configuring the data reduction proxy on Android. |
28 // This object lives on the UI thread and all of its methods are expected to | 26 // This object lives on the UI thread and all of its methods are expected to |
29 // be called from there. | 27 // be called from there. |
30 class DataReductionProxySettingsAndroid | 28 class DataReductionProxySettingsAndroid { |
31 : public data_reduction_proxy::DataReductionProxySettings, | |
32 public KeyedService { | |
33 public: | 29 public: |
34 // Factory constructor. | 30 DataReductionProxySettingsAndroid(); |
35 DataReductionProxySettingsAndroid( | |
36 data_reduction_proxy::DataReductionProxyParams* params); | |
37 | |
38 | 31 |
39 virtual ~DataReductionProxySettingsAndroid(); | 32 virtual ~DataReductionProxySettingsAndroid(); |
40 | 33 |
41 void InitDataReductionProxySettings(Profile* profile); | 34 void InitDataReductionProxySettings(Profile* profile); |
42 | 35 |
43 void BypassHostPattern(JNIEnv* env, jobject obj, jstring pattern); | |
44 // Add a URL pattern to bypass the proxy. Wildcards | |
45 // should be compatible with the JavaScript function shExpMatch, which can be | |
46 // used in proxy PAC resolution. These functions must only be called before | |
47 // the proxy is used. | |
48 void BypassURLPattern(JNIEnv* env, jobject obj, jstring pattern); | |
49 | |
50 // JNI wrapper interfaces to the indentically-named superclass methods. | 36 // JNI wrapper interfaces to the indentically-named superclass methods. |
51 jboolean IsDataReductionProxyAllowed(JNIEnv* env, jobject obj); | 37 jboolean IsDataReductionProxyAllowed(JNIEnv* env, jobject obj); |
52 jboolean IsDataReductionProxyPromoAllowed(JNIEnv* env, jobject obj); | 38 jboolean IsDataReductionProxyPromoAllowed(JNIEnv* env, jobject obj); |
53 jboolean IsIncludedInAltFieldTrial(JNIEnv* env, jobject obj); | 39 jboolean IsIncludedInAltFieldTrial(JNIEnv* env, jobject obj); |
54 ScopedJavaLocalRef<jstring> GetDataReductionProxyOrigin(JNIEnv* env, | 40 ScopedJavaLocalRef<jstring> GetDataReductionProxyOrigin(JNIEnv* env, |
55 jobject obj); | 41 jobject obj); |
56 jboolean IsDataReductionProxyEnabled(JNIEnv* env, jobject obj); | 42 jboolean IsDataReductionProxyEnabled(JNIEnv* env, jobject obj); |
57 jboolean IsDataReductionProxyManaged(JNIEnv* env, jobject obj); | 43 jboolean IsDataReductionProxyManaged(JNIEnv* env, jobject obj); |
58 void SetDataReductionProxyEnabled(JNIEnv* env, jobject obj, jboolean enabled); | 44 void SetDataReductionProxyEnabled(JNIEnv* env, jobject obj, jboolean enabled); |
59 | 45 |
(...skipping 14 matching lines...) Expand all Loading... |
74 jboolean IsDataReductionProxyUnreachable(JNIEnv* env, jobject obj); | 60 jboolean IsDataReductionProxyUnreachable(JNIEnv* env, jobject obj); |
75 | 61 |
76 ScopedJavaLocalRef<jstring> GetTokenForAuthChallenge(JNIEnv* env, | 62 ScopedJavaLocalRef<jstring> GetTokenForAuthChallenge(JNIEnv* env, |
77 jobject obj, | 63 jobject obj, |
78 jstring host, | 64 jstring host, |
79 jstring realm); | 65 jstring realm); |
80 | 66 |
81 // Registers the native methods to be call from Java. | 67 // Registers the native methods to be call from Java. |
82 static bool Register(JNIEnv* env); | 68 static bool Register(JNIEnv* env); |
83 | 69 |
84 protected: | |
85 // DataReductionProxySettings overrides. | |
86 virtual void AddDefaultProxyBypassRules() OVERRIDE; | |
87 | |
88 // Configures the proxy settings by generating a data URL containing a PAC | |
89 // file. | |
90 virtual void SetProxyConfigs(bool enabled, | |
91 bool alt_enabled, | |
92 bool restricted, | |
93 bool at_startup) OVERRIDE; | |
94 | |
95 private: | 70 private: |
96 friend class DataReductionProxySettingsAndroidTest; | 71 friend class DataReductionProxySettingsAndroidTest; |
97 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, | 72 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, |
98 TestGetDailyContentLengths); | 73 TestGetDailyContentLengths); |
99 | 74 |
100 | 75 |
101 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, | 76 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, |
102 const char* pref_name); | 77 const char* pref_name); |
103 | 78 |
| 79 virtual data_reduction_proxy::DataReductionProxySettings* Settings(); |
| 80 |
104 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); | 81 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); |
105 }; | 82 }; |
106 | 83 |
107 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ | 84 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
OLD | NEW |