OLD | NEW |
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 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using data_reduction_proxy::Client; | 23 using data_reduction_proxy::Client; |
24 using data_reduction_proxy::DataReductionProxyParams; | 24 using data_reduction_proxy::DataReductionProxyParams; |
25 using data_reduction_proxy::DataReductionProxySettings; | 25 using data_reduction_proxy::DataReductionProxySettings; |
26 | 26 |
27 // The Data Reduction Proxy has been turned into a "best effort" proxy, | 27 // The Data Reduction Proxy has been turned into a "best effort" proxy, |
28 // meaning it is used only if the effective proxy configuration resolves to | 28 // meaning it is used only if the effective proxy configuration resolves to |
29 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference | 29 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference |
30 // hierarchy. This method removes the Data Reduction Proxy configuration from | 30 // hierarchy. This method removes the Data Reduction Proxy configuration from |
31 // prefs, if present. |proxy_pref_name| is the name of the proxy pref. | 31 // prefs, if present. |proxy_pref_name| is the name of the proxy pref. |
32 void MigrateDataReductionProxyOffProxyPrefs(PrefService* prefs) { | 32 void MigrateDataReductionProxyOffProxyPrefs(PrefService* prefs) { |
33 DictionaryPrefUpdate update(prefs, prefs::kProxy); | 33 base::DictionaryValue* dict = |
34 base::DictionaryValue* dict = update.Get(); | 34 (base::DictionaryValue*) prefs->GetUserPrefValue(prefs::kProxy); |
| 35 if (!dict) |
| 36 return; |
| 37 |
| 38 // Clear empty "proxy" dictionary created by a bug. See http://crbug/448172 |
| 39 if (dict->empty()) { |
| 40 prefs->ClearPref(prefs::kProxy); |
| 41 return; |
| 42 } |
| 43 |
35 std::string mode; | 44 std::string mode; |
36 if (!dict->GetString("mode", &mode)) | 45 if (!dict->GetString("mode", &mode)) |
37 return; | 46 return; |
38 if (ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS) != mode) | 47 if (ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS) != mode) |
39 return; | 48 return; |
40 std::string proxy_server; | 49 std::string proxy_server; |
41 if (!dict->GetString("server", &proxy_server)) | 50 if (!dict->GetString("server", &proxy_server)) |
42 return; | 51 return; |
43 net::ProxyConfig::ProxyRules proxy_rules; | 52 net::ProxyConfig::ProxyRules proxy_rules; |
44 proxy_rules.ParseFromString(proxy_server); | 53 proxy_rules.ParseFromString(proxy_server); |
45 if (!data_reduction_proxy::DataReductionProxyConfigurator:: | 54 if (!data_reduction_proxy::DataReductionProxyConfigurator:: |
46 ContainsDataReductionProxy(proxy_rules)) { | 55 ContainsDataReductionProxy(proxy_rules)) { |
47 return; | 56 return; |
48 } | 57 } |
49 dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); | 58 prefs->ClearPref(prefs::kProxy); |
50 dict->SetString("server", ""); | |
51 dict->SetString("bypass_list", ""); | |
52 } | 59 } |
53 | 60 |
54 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( | 61 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings( |
55 scoped_ptr<DataReductionProxyParams> params) | 62 scoped_ptr<DataReductionProxyParams> params) |
56 : DataReductionProxySettings(params.Pass()) { | 63 : DataReductionProxySettings(params.Pass()) { |
57 } | 64 } |
58 | 65 |
59 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { | 66 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { |
60 } | 67 } |
61 | 68 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 #elif defined(OS_OPENBSD) | 112 #elif defined(OS_OPENBSD) |
106 return Client::CHROME_OPENBSD; | 113 return Client::CHROME_OPENBSD; |
107 #elif defined(OS_SOLARIS) | 114 #elif defined(OS_SOLARIS) |
108 return Client::CHROME_SOLARIS; | 115 return Client::CHROME_SOLARIS; |
109 #elif defined(OS_QNX) | 116 #elif defined(OS_QNX) |
110 return Client::CHROME_QNX; | 117 return Client::CHROME_QNX; |
111 #else | 118 #else |
112 return Client::UNKNOWN; | 119 return Client::UNKNOWN; |
113 #endif | 120 #endif |
114 } | 121 } |
OLD | NEW |