Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings.h

Issue 279633003: Use non-static set_key interface on DataReductionProxySettings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Returns true if the data reduction proxy key is set on the command line. 95 // Returns true if the data reduction proxy key is set on the command line.
96 static bool IsProxyKeySetOnCommandLine(); 96 static bool IsProxyKeySetOnCommandLine();
97 97
98 // Returns true if this application instance is part of the data reduction 98 // Returns true if this application instance is part of the data reduction
99 // proxy field trial, or if it a proxy origin is set in flags. This is a 99 // proxy field trial, or if it a proxy origin is set in flags. This is a
100 // convenience method for platforms like Chrome on Android and iOS, to 100 // convenience method for platforms like Chrome on Android and iOS, to
101 // determine if the data reduction proxy is allowed. 101 // determine if the data reduction proxy is allowed.
102 static bool IsIncludedInFieldTrialOrFlags(); 102 static bool IsIncludedInFieldTrialOrFlags();
103 103
104 static void SetKey(const std::string& key);
105 static void SetAllowed(bool allowed); 104 static void SetAllowed(bool allowed);
106 static void SetPromoAllowed(bool promo_allowed); 105 static void SetPromoAllowed(bool promo_allowed);
107 106
108 DataReductionProxySettings(); 107 DataReductionProxySettings();
109 virtual ~DataReductionProxySettings(); 108 virtual ~DataReductionProxySettings();
110 109
110 // Set and get the key to be used for data reduction proxy authentication.
111 void set_key(const std::string& key);
112 std::string key();
mmenke 2014/05/09 15:27:08 nit: When using this naming style, bodies should
mmenke 2014/05/09 15:27:08 nit: const std::string& key() const;
bengr 2014/05/09 15:47:28 Done.
bengr 2014/05/09 15:47:28 Done.
113
111 // Initializes the data reduction proxy with profile and local state prefs, 114 // Initializes the data reduction proxy with profile and local state prefs,
112 // and a |UrlRequestContextGetter| for canary probes. The caller must ensure 115 // and a |UrlRequestContextGetter| for canary probes. The caller must ensure
113 // that all parameters remain alive for the lifetime of the 116 // that all parameters remain alive for the lifetime of the
114 // |DataReductionProxySettings| instance. 117 // |DataReductionProxySettings| instance.
115 void InitDataReductionProxySettings( 118 void InitDataReductionProxySettings(
116 PrefService* prefs, 119 PrefService* prefs,
117 PrefService* local_state_prefs, 120 PrefService* local_state_prefs,
118 net::URLRequestContextGetter* url_request_context_getter); 121 net::URLRequestContextGetter* url_request_context_getter);
119 122
120 // Initializes the data reduction proxy with profile and local state prefs, 123 // Initializes the data reduction proxy with profile and local state prefs,
121 // a |UrlRequestContextGetter| for canary probes, and a proxy configurator. 124 // a |UrlRequestContextGetter| for canary probes, and a proxy configurator.
122 // The caller must ensure that all parameters remain alive for the lifetime of 125 // The caller must ensure that all parameters remain alive for the lifetime of
123 // the |DataReductionProxySettings| instance. 126 // the |DataReductionProxySettings| instance.
124 // TODO(marq): Remove when iOS supports the new interface above. 127 // TODO(marq): Remove when iOS supports the new interface above.
125 void InitDataReductionProxySettings( 128 void InitDataReductionProxySettings(
126 PrefService* prefs, 129 PrefService* prefs,
127 PrefService* local_state_prefs, 130 PrefService* local_state_prefs,
128 net::URLRequestContextGetter* url_request_context_getter, 131 net::URLRequestContextGetter* url_request_context_getter,
129 scoped_ptr<DataReductionProxyConfigurator> config); 132 scoped_ptr<DataReductionProxyConfigurator> config);
130 133
131 // Sets the logic the embedder uses to set the networking configuration that 134 // Sets the logic the embedder uses to set the networking configuration that
132 // causes traffic to be proxied. 135 // causes traffic to be proxied.
133 void SetProxyConfigurator( 136 void SetProxyConfigurator(
134 scoped_ptr<DataReductionProxyConfigurator> configurator); 137 scoped_ptr<DataReductionProxyConfigurator> configurator);
135 138
136 // If proxy authentication is compiled in, pre-cache authentication 139 // If proxy authentication is compiled in, pre-cache an authentication
137 // keys for all configured proxies in |session|. 140 // |key| for all configured proxies in |session|.
138 static void InitDataReductionProxySession(net::HttpNetworkSession* session); 141 static void InitDataReductionProxySession(net::HttpNetworkSession* session,
142 const std::string& key);
139 143
140 // Returns true if the data reduction proxy is allowed to be used. This could 144 // Returns true if the data reduction proxy is allowed to be used. This could
141 // return false, for example, if this instance is not part of the field trial, 145 // return false, for example, if this instance is not part of the field trial,
142 // or if the proxy name is not configured via gyp. 146 // or if the proxy name is not configured via gyp.
143 static bool IsDataReductionProxyAllowed(); 147 static bool IsDataReductionProxyAllowed();
144 148
145 // Returns true if a screen promoting the data reduction proxy is allowed to 149 // Returns true if a screen promoting the data reduction proxy is allowed to
146 // be shown. Logic that decides when to show the promo should check its 150 // be shown. Logic that decides when to show the promo should check its
147 // availability. This would return false if not part of a separate field 151 // availability. This would return false if not part of a separate field
148 // trial that governs the use of the promotion. 152 // trial that governs the use of the promotion.
(...skipping 12 matching lines...) Expand all
161 // Returns a vector of GURLs for all configured proxies. 165 // Returns a vector of GURLs for all configured proxies.
162 static DataReductionProxyList GetDataReductionProxies(); 166 static DataReductionProxyList GetDataReductionProxies();
163 167
164 // Returns true if |auth_info| represents an authentication challenge from 168 // Returns true if |auth_info| represents an authentication challenge from
165 // a compatible, configured proxy. 169 // a compatible, configured proxy.
166 static bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info); 170 static bool IsAcceptableAuthChallenge(net::AuthChallengeInfo* auth_info);
167 171
168 // Returns a UTF16 string suitable for use as an authentication token in 172 // Returns a UTF16 string suitable for use as an authentication token in
169 // response to the challenge represented by |auth_info|. If the token can't 173 // response to the challenge represented by |auth_info|. If the token can't
170 // be correctly generated for |auth_info|, returns an empty UTF16 string. 174 // be correctly generated for |auth_info|, returns an empty UTF16 string.
171 static base::string16 GetTokenForAuthChallenge( 175 base::string16 GetTokenForAuthChallenge(
172 net::AuthChallengeInfo* auth_info); 176 net::AuthChallengeInfo* auth_info);
173 177
174 // Returns true if the proxy is enabled. 178 // Returns true if the proxy is enabled.
175 bool IsDataReductionProxyEnabled(); 179 bool IsDataReductionProxyEnabled();
176 180
177 // Returns true if the proxy is managed by an adminstrator's policy. 181 // Returns true if the proxy is managed by an adminstrator's policy.
178 bool IsDataReductionProxyManaged(); 182 bool IsDataReductionProxyManaged();
179 183
180 // Enables or disables the data reduction proxy. If a probe URL is available, 184 // Enables or disables the data reduction proxy. If a probe URL is available,
181 // and a probe request fails at some point, the proxy won't be used until a 185 // and a probe request fails at some point, the proxy won't be used until a
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, 283 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
280 TestBypassList); 284 TestBypassList);
281 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest, 285 FRIEND_TEST_ALL_PREFIXES(DataReductionProxySettingsTest,
282 CheckInitMetricsWhenNotAllowed); 286 CheckInitMetricsWhenNotAllowed);
283 287
284 // NetworkChangeNotifier::IPAddressObserver: 288 // NetworkChangeNotifier::IPAddressObserver:
285 virtual void OnIPAddressChanged() OVERRIDE; 289 virtual void OnIPAddressChanged() OVERRIDE;
286 290
287 // Underlying implementation of InitDataReductionProxySession(), factored 291 // Underlying implementation of InitDataReductionProxySession(), factored
288 // out to be testable without creating a full HttpNetworkSession. 292 // out to be testable without creating a full HttpNetworkSession.
289 static void InitDataReductionAuthentication(net::HttpAuthCache* auth_cache); 293 static void InitDataReductionAuthentication(net::HttpAuthCache* auth_cache,
294 const std::string& key);
290 295
291 void OnProxyEnabledPrefChange(); 296 void OnProxyEnabledPrefChange();
292 297
293 void ResetDataReductionStatistics(); 298 void ResetDataReductionStatistics();
294 299
295 void MaybeActivateDataReductionProxy(bool at_startup); 300 void MaybeActivateDataReductionProxy(bool at_startup);
296 301
297 // Requests the proxy probe URL, if one is set. If unable to do so, disables 302 // Requests the proxy probe URL, if one is set. If unable to do so, disables
298 // the proxy, if enabled. Otherwise enables the proxy if disabled by a probe 303 // the proxy, if enabled. Otherwise enables the proxy if disabled by a probe
299 // failure. 304 // failure.
300 void ProbeWhetherDataReductionProxyIsAvailable(); 305 void ProbeWhetherDataReductionProxyIsAvailable();
301 std::string GetProxyCheckURL(); 306 std::string GetProxyCheckURL();
302 307
303 // Returns a UTF16 string that's the hash of the configured authentication 308 // Returns a UTF16 string that's the hash of the configured authentication
304 // key and |salt|. Returns an empty UTF16 string if no key is configured or 309 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or
305 // the data reduction proxy feature isn't available. 310 // the data reduction proxy feature isn't available.
306 static base::string16 AuthHashForSalt(int64 salt); 311 static base::string16 AuthHashForSalt(int64 salt,
312 const std::string& key);
307 313
308 static std::string key_;
309 static bool allowed_; 314 static bool allowed_;
310 static bool promo_allowed_; 315 static bool promo_allowed_;
311 316
317 std::string key_;
312 bool restricted_by_carrier_; 318 bool restricted_by_carrier_;
313 bool enabled_by_user_; 319 bool enabled_by_user_;
314 320
315 scoped_ptr<net::URLFetcher> fetcher_; 321 scoped_ptr<net::URLFetcher> fetcher_;
316 BooleanPrefMember spdy_proxy_auth_enabled_; 322 BooleanPrefMember spdy_proxy_auth_enabled_;
317 323
318 PrefService* prefs_; 324 PrefService* prefs_;
319 PrefService* local_state_prefs_; 325 PrefService* local_state_prefs_;
320 326
321 net::URLRequestContextGetter* url_request_context_getter_; 327 net::URLRequestContextGetter* url_request_context_getter_;
322 328
323 scoped_ptr<DataReductionProxyConfigurator> config_; 329 scoped_ptr<DataReductionProxyConfigurator> config_;
324 330
325 base::ThreadChecker thread_checker_; 331 base::ThreadChecker thread_checker_;
326 332
327 bool fallback_allowed_; 333 bool fallback_allowed_;
328 334
329 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings); 335 DISALLOW_COPY_AND_ASSIGN(DataReductionProxySettings);
330 }; 336 };
331 337
332 } // namespace data_reduction_proxy 338 } // namespace data_reduction_proxy
333 339
334 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _H_ 340 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698