OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_CHROME_CONFIGURATOR_H_ | |
6 #define CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_CHROME_CONFIGURATOR_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/gtest_prod_util.h" | |
12 #include "base/task_runner.h" | |
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | |
14 #include "net/proxy/proxy_config.h" | |
15 | |
16 namespace base { | |
17 class SequencedTaskRunner; | |
18 } | |
19 | |
20 namespace data_reduction_proxy { | |
21 class DataReductionProxyEventStore; | |
22 } | |
23 | |
24 namespace net { | |
25 class NetLog; | |
26 class ProxyInfo; | |
27 class ProxyService; | |
28 } | |
29 | |
30 class PrefService; | |
31 | |
32 class DataReductionProxyChromeConfigurator | |
33 : public data_reduction_proxy::DataReductionProxyConfigurator { | |
34 public: | |
35 explicit DataReductionProxyChromeConfigurator( | |
36 PrefService* prefs, | |
37 scoped_refptr<base::SequencedTaskRunner> network_task_runner, | |
38 net::NetLog* net_log, | |
39 data_reduction_proxy::DataReductionProxyEventStore* event_store); | |
40 ~DataReductionProxyChromeConfigurator() override; | |
41 | |
42 // Removes the data reduction proxy configuration from the proxy preference. | |
43 // This disables use of the data reduction proxy. This method is public to | |
44 // disable the proxy on incognito. Disable() should be used otherwise. | |
45 static void DisableInProxyConfigPref(PrefService* prefs); | |
46 | |
47 void Enable(bool primary_restricted, | |
48 bool fallback_restricted, | |
49 const std::string& primary_origin, | |
50 const std::string& fallback_origin, | |
51 const std::string& ssl_origin) override; | |
52 void Disable() override; | |
53 | |
54 // Add a host pattern to bypass. This should follow the same syntax used | |
55 // in net::ProxyBypassRules; that is, a hostname pattern, a hostname suffix | |
56 // pattern, an IP literal, a CIDR block, or the magic string '<local>'. | |
57 // Bypass settings persist for the life of this object and are applied | |
58 // each time the proxy is enabled, but are not updated while it is enabled. | |
59 void AddHostPatternToBypass(const std::string& pattern) override; | |
60 | |
61 // Add a URL pattern to bypass the proxy. The base implementation strips | |
62 // everything in |pattern| after the first single slash and then treats it | |
63 // as a hostname pattern. Subclasses may implement other semantics. | |
64 void AddURLPatternToBypass(const std::string& pattern) override; | |
65 | |
66 // Updates the config for use on the IO thread. | |
67 void UpdateProxyConfigOnIOThread(const net::ProxyConfig& config); | |
68 | |
69 // Returns the current data reduction proxy config, even if it is not the | |
70 // effective configuration used by the proxy service. | |
71 const net::ProxyConfig& GetProxyConfigOnIOThread() const; | |
72 | |
73 private: | |
74 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, TestBypassList); | |
75 | |
76 // Check whether the |proxy_rules| contain any of the data reduction proxies. | |
77 static bool ContainsDataReductionProxy( | |
78 const net::ProxyConfig::ProxyRules& proxy_rules); | |
79 | |
80 PrefService* prefs_; | |
81 scoped_refptr<base::SequencedTaskRunner> network_task_runner_; | |
82 | |
83 std::vector<std::string> bypass_rules_; | |
84 net::ProxyConfig config_; | |
85 net::NetLog* net_log_; | |
86 data_reduction_proxy::DataReductionProxyEventStore* | |
87 data_reduction_proxy_event_store_; | |
88 | |
89 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyChromeConfigurator); | |
90 }; | |
91 | |
92 #endif // CHROME_BROWSER_NET_SPDYPROXY_DATA_REDUCTION_PROXY_CHROME_CONFIGURATOR
_H_ | |
OLD | NEW |