OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
| 6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
| 7 |
| 8 #include "base/android/jni_helper.h" |
| 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/prefs/pref_service.h" |
| 13 #include "net/base/network_change_notifier.h" |
| 14 #include "net/url_request/url_fetcher.h" |
| 15 #include "net/url_request/url_fetcher_delegate.h" |
| 16 |
| 17 using base::android::ScopedJavaLocalRef; |
| 18 |
| 19 class DataReductionProxySettingsAndroid |
| 20 : public net::URLFetcherDelegate, |
| 21 public net::NetworkChangeNotifier::IPAddressObserver { |
| 22 public: |
| 23 DataReductionProxySettingsAndroid(JNIEnv* env, jobject obj); |
| 24 virtual ~DataReductionProxySettingsAndroid(); |
| 25 |
| 26 void InitDataReductionProxySettings(JNIEnv* env, jobject obj); |
| 27 |
| 28 jboolean IsDataReductionProxyAvailable(JNIEnv* env, jobject obj); |
| 29 jboolean IsDataReductionProxyPromoAvailable(JNIEnv* env, jobject obj); |
| 30 ScopedJavaLocalRef<jstring> GetDataReductionProxyOrigin(JNIEnv* env, |
| 31 jobject obj); |
| 32 ScopedJavaLocalRef<jstring> GetDataReductionProxyValue(JNIEnv* env, |
| 33 jobject obj); |
| 34 |
| 35 jboolean IsDataReductionProxyEnabled(JNIEnv* env, jobject obj); |
| 36 void SetDataReductionProxyEnabled(JNIEnv* env, jobject obj,jboolean enabled); |
| 37 |
| 38 jlong GetDataReductionLastUpdateTime(JNIEnv* env, jobject obj); |
| 39 |
| 40 base::android::ScopedJavaLocalRef<jobject> GetContentLengths(JNIEnv* env, |
| 41 jobject obj); |
| 42 ScopedJavaLocalRef<jlongArray> GetDailyOriginalContentLengths(JNIEnv* env, |
| 43 jobject obj); |
| 44 ScopedJavaLocalRef<jlongArray> GetDailyReceivedContentLengths(JNIEnv* env, |
| 45 jobject obj); |
| 46 |
| 47 static bool Register(JNIEnv* env); |
| 48 |
| 49 private: |
| 50 friend class DataReductionProxySettingsAndroidTest; |
| 51 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, |
| 52 TestBypassRules); |
| 53 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, |
| 54 TestFormatURL); |
| 55 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, |
| 56 TestStatistics); |
| 57 |
| 58 // net::URLFetcherDelegate: |
| 59 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 60 |
| 61 |
| 62 // NetworkChangeNotifier::IPAddressObserver: |
| 63 virtual void OnIPAddressChanged() OVERRIDE; |
| 64 |
| 65 bool IsDataReductionProxyAvailable(); |
| 66 bool IsDataReductionProxyPromoAvailable(); |
| 67 |
| 68 void AddDefaultProxyBypassRules(); |
| 69 void AddURLPatternToBypass(const std::string& pattern); |
| 70 void AddHostPatternToBypass(const std::string& pattern); |
| 71 void AddPatternToBypass(const std::string& url_or_host, |
| 72 const std::string& pattern); |
| 73 void AddHostToBypass(const std::string& host); |
| 74 void AddURLSubstringToBypass(const std::string& url, int from, int to); |
| 75 |
| 76 PrefService* GetPrefService(); |
| 77 PrefService* GetLocalState(); |
| 78 void set_pref_service(PrefService* pref_service); |
| 79 void set_local_state(PrefService* local_state); |
| 80 |
| 81 |
| 82 std::string GetDataReductionProxyOriginHostPort(); |
| 83 void RemoveSchemeAndTrailingSlash(std::string* url); |
| 84 void ResetDataReductionStatistics(); |
| 85 |
| 86 void SetProxyPac(bool enable_spdy_proxy, bool at_startup); |
| 87 |
| 88 std::string GetProxyCheckURL(); |
| 89 |
| 90 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, |
| 91 const char* pref_name); |
| 92 void GetContentLengths(int days, |
| 93 int64* original_content_length, |
| 94 int64* received_content_length, |
| 95 int64* last_update_time); |
| 96 |
| 97 void CheckDataReductionProxyIsAvailable(std::string url); |
| 98 |
| 99 std::string GetProxyPacScript(); |
| 100 |
| 101 std::vector<std::string> bypass_rules_; |
| 102 |
| 103 // Indicate whether a user has turned on SPDY proxy auth previously in this |
| 104 // session. |
| 105 bool has_turned_on_; |
| 106 |
| 107 // Indicate whether a user has turned off SPDY proxy auth previously in this |
| 108 // session. |
| 109 bool has_turned_off_; |
| 110 |
| 111 bool disabled_by_carrier_; |
| 112 bool enabled_by_user_; |
| 113 |
| 114 scoped_ptr<net::URLFetcher> fetcher_; |
| 115 PrefService* pref_service_; |
| 116 PrefService* local_state_; |
| 117 |
| 118 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); |
| 119 }; |
| 120 |
| 121 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ |
OLD | NEW |