| 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" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 17 |
| 18 | 18 |
| 19 using base::android::ScopedJavaLocalRef; | 19 using base::android::ScopedJavaLocalRef; |
| 20 | 20 |
| 21 class Profile; | |
| 22 | |
| 23 namespace data_reduction_proxy { | |
| 24 class DataReductionProxyParams; | |
| 25 } | |
| 26 | 21 |
| 27 // Central point for configuring the data reduction proxy on Android. | 22 // 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 | 23 // This object lives on the UI thread and all of its methods are expected to |
| 29 // be called from there. | 24 // be called from there. |
| 30 class DataReductionProxySettingsAndroid | 25 class DataReductionProxySettingsAndroid |
| 31 : public data_reduction_proxy::DataReductionProxySettings, | 26 : public data_reduction_proxy::DataReductionProxySettings { |
| 32 public KeyedService { | |
| 33 public: | 27 public: |
| 34 // Factory constructor. | 28 DataReductionProxySettingsAndroid(JNIEnv* env, jobject obj); |
| 35 DataReductionProxySettingsAndroid( | 29 // Parameter-free constructor for C++ unit tests. |
| 36 data_reduction_proxy::DataReductionProxyParams* params); | 30 DataReductionProxySettingsAndroid(); |
| 37 | |
| 38 | 31 |
| 39 virtual ~DataReductionProxySettingsAndroid(); | 32 virtual ~DataReductionProxySettingsAndroid(); |
| 40 | 33 |
| 41 void InitDataReductionProxySettings(Profile* profile); | 34 void InitDataReductionProxySettings(JNIEnv* env, jobject obj); |
| 42 | 35 |
| 43 void BypassHostPattern(JNIEnv* env, jobject obj, jstring pattern); | 36 void BypassHostPattern(JNIEnv* env, jobject obj, jstring pattern); |
| 44 // Add a URL pattern to bypass the proxy. Wildcards | 37 // Add a URL pattern to bypass the proxy. Wildcards |
| 45 // should be compatible with the JavaScript function shExpMatch, which can be | 38 // should be compatible with the JavaScript function shExpMatch, which can be |
| 46 // used in proxy PAC resolution. These functions must only be called before | 39 // used in proxy PAC resolution. These functions must only be called before |
| 47 // the proxy is used. | 40 // the proxy is used. |
| 48 void BypassURLPattern(JNIEnv* env, jobject obj, jstring pattern); | 41 void BypassURLPattern(JNIEnv* env, jobject obj, jstring pattern); |
| 49 | 42 |
| 50 // JNI wrapper interfaces to the indentically-named superclass methods. | 43 // JNI wrapper interfaces to the indentically-named superclass methods. |
| 51 jboolean IsDataReductionProxyAllowed(JNIEnv* env, jobject obj); | 44 jboolean IsDataReductionProxyAllowed(JNIEnv* env, jobject obj); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 82 | 75 |
| 83 // Registers the native methods to be call from Java. | 76 // Registers the native methods to be call from Java. |
| 84 static bool Register(JNIEnv* env); | 77 static bool Register(JNIEnv* env); |
| 85 | 78 |
| 86 protected: | 79 protected: |
| 87 // DataReductionProxySettings overrides. | 80 // DataReductionProxySettings overrides. |
| 88 virtual void AddDefaultProxyBypassRules() OVERRIDE; | 81 virtual void AddDefaultProxyBypassRules() OVERRIDE; |
| 89 | 82 |
| 90 // Configures the proxy settings by generating a data URL containing a PAC | 83 // Configures the proxy settings by generating a data URL containing a PAC |
| 91 // file. | 84 // file. |
| 92 virtual void SetProxyConfigs(bool enabled, | 85 virtual void SetProxyConfigs( |
| 93 bool alt_enabled, | 86 bool enabled, bool restricted, bool at_startup) OVERRIDE; |
| 94 bool restricted, | |
| 95 bool at_startup) OVERRIDE; | |
| 96 | 87 |
| 97 private: | 88 private: |
| 98 friend class DataReductionProxySettingsAndroidTest; | 89 friend class DataReductionProxySettingsAndroidTest; |
| 99 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, | 90 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, |
| 100 TestGetDailyContentLengths); | 91 TestGetDailyContentLengths); |
| 101 | 92 |
| 102 | 93 |
| 103 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, | 94 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, |
| 104 const char* pref_name); | 95 const char* pref_name); |
| 105 | 96 |
| 106 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); | 97 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); |
| 107 }; | 98 }; |
| 108 | 99 |
| 109 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ | 100 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
| OLD | NEW |