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 | |
mmenke
2013/09/05 21:34:33
Class should be documented, as should most of thes
bengr
2013/09/10 00:56:09
Done.
| |
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 jboolean IsDataReductionProxyManaged(JNIEnv* env, jobject obj); | |
37 void SetDataReductionProxyEnabled(JNIEnv* env, jobject obj,jboolean enabled); | |
mmenke
2013/09/09 15:40:05
nit: Missing space.
bengr
2013/09/10 00:56:09
Done.
| |
38 | |
39 jlong GetDataReductionLastUpdateTime(JNIEnv* env, jobject obj); | |
40 | |
41 base::android::ScopedJavaLocalRef<jobject> GetContentLengths(JNIEnv* env, | |
42 jobject obj); | |
43 ScopedJavaLocalRef<jlongArray> GetDailyOriginalContentLengths(JNIEnv* env, | |
44 jobject obj); | |
45 ScopedJavaLocalRef<jlongArray> GetDailyReceivedContentLengths(JNIEnv* env, | |
46 jobject obj); | |
47 | |
48 static bool Register(JNIEnv* env); | |
49 | |
50 private: | |
51 friend class DataReductionProxySettingsAndroidTest; | |
52 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, | |
53 TestBypassRules); | |
54 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, | |
55 TestFormatURL); | |
56 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsAndroidTest, | |
57 TestStatistics); | |
58 | |
59 // net::URLFetcherDelegate: | |
60 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
61 | |
62 | |
63 // NetworkChangeNotifier::IPAddressObserver: | |
64 virtual void OnIPAddressChanged() OVERRIDE; | |
65 | |
66 bool IsDataReductionProxyAvailable(); | |
67 bool IsDataReductionProxyPromoAvailable(); | |
68 | |
69 void AddDefaultProxyBypassRules(); | |
70 void AddURLPatternToBypass(const std::string& pattern); | |
71 void AddHostPatternToBypass(const std::string& pattern); | |
72 void AddPatternToBypass(const std::string& url_or_host, | |
73 const std::string& pattern); | |
74 void AddHostToBypass(const std::string& host); | |
75 void AddURLSubstringToBypass(const std::string& url, int from, int to); | |
76 | |
77 PrefService* GetPrefService(); | |
78 PrefService* GetLocalState(); | |
79 void set_pref_service(PrefService* pref_service); | |
80 void set_local_state(PrefService* local_state); | |
mmenke
2013/09/05 21:34:33
If this is only intended for testing, the name sho
bengr
2013/09/10 00:56:09
Done.
| |
81 | |
82 | |
83 std::string GetDataReductionProxyOriginHostPort(); | |
84 void RemoveSchemeAndTrailingSlash(std::string* url); | |
85 void ResetDataReductionStatistics(); | |
86 | |
87 void SetProxyPac(bool enable_spdy_proxy, bool at_startup); | |
88 | |
89 std::string GetProxyCheckURL(); | |
90 | |
91 ScopedJavaLocalRef<jlongArray> GetDailyContentLengths(JNIEnv* env, | |
92 const char* pref_name); | |
93 void GetContentLengths(int days, | |
94 int64* original_content_length, | |
95 int64* received_content_length, | |
96 int64* last_update_time); | |
97 | |
98 void CheckDataReductionProxyIsAvailable(std::string url); | |
99 | |
100 std::string GetProxyPacScript(); | |
101 | |
102 std::vector<std::string> bypass_rules_; | |
103 | |
104 // Indicate whether a user has turned on SPDY proxy auth previously in this | |
105 // session. | |
mmenke
2013/09/09 15:40:05
I'm not really follow...This is SPDY proxy auth sp
bengr
2013/09/10 00:56:09
Done. The data reduction proxy had been called "SP
| |
106 bool has_turned_on_; | |
107 | |
108 // Indicate whether a user has turned off SPDY proxy auth previously in this | |
109 // session. | |
110 bool has_turned_off_; | |
111 | |
112 bool disabled_by_carrier_; | |
113 bool enabled_by_user_; | |
114 | |
115 scoped_ptr<net::URLFetcher> fetcher_; | |
116 PrefService* pref_service_; | |
117 PrefService* local_state_; | |
mmenke
2013/09/05 21:34:33
I don't think it's at all clear what the differenc
mmenke
2013/09/09 15:40:05
Also, if these are only used for unit tests, they
bengr
2013/09/10 00:56:09
Done.
bengr
2013/09/10 00:56:09
Done.
| |
118 | |
119 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettingsAndroid); | |
120 }; | |
121 | |
122 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_SETTINGS_ANDROID_H_ | |
OLD | NEW |