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

Side by Side Diff: chrome/browser/extensions/api/proxy/proxy_api.cc

Issue 2785883003: Use unique_ptr<DictionaryValue> in ProxyConfigDictionary (Closed)
Patch Set: Fix compilation Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implementation of the Chrome Extensions Proxy Settings API. 5 // Implementation of the Chrome Extensions Proxy Settings API.
6 6
7 #include "chrome/browser/extensions/api/proxy/proxy_api.h" 7 #include "chrome/browser/extensions/api/proxy/proxy_api.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 config, &pac_url, error, bad_message) || 126 config, &pac_url, error, bad_message) ||
127 !helpers::GetPacDataFromExtensionPref( 127 !helpers::GetPacDataFromExtensionPref(
128 config, &pac_data, error, bad_message) || 128 config, &pac_data, error, bad_message) ||
129 !helpers::GetProxyRulesStringFromExtensionPref( 129 !helpers::GetProxyRulesStringFromExtensionPref(
130 config, &proxy_rules_string, error, bad_message) || 130 config, &proxy_rules_string, error, bad_message) ||
131 !helpers::GetBypassListFromExtensionPref( 131 !helpers::GetBypassListFromExtensionPref(
132 config, &bypass_list, error, bad_message)) { 132 config, &bypass_list, error, bad_message)) {
133 return NULL; 133 return NULL;
134 } 134 }
135 135
136 return helpers::CreateProxyConfigDict( 136 return helpers::CreateProxyConfigDict(mode_enum, pac_mandatory, pac_url,
137 mode_enum, pac_mandatory, pac_url, pac_data, proxy_rules_string, 137 pac_data, proxy_rules_string,
138 bypass_list, error); 138 bypass_list, error)
139 .release();
139 } 140 }
140 141
141 base::Value* ProxyPrefTransformer::BrowserToExtensionPref( 142 base::Value* ProxyPrefTransformer::BrowserToExtensionPref(
142 const base::Value* browser_pref) { 143 const base::Value* browser_pref) {
143 CHECK(browser_pref->IsType(base::Value::Type::DICTIONARY)); 144 CHECK(browser_pref->IsType(base::Value::Type::DICTIONARY));
144 145
145 // This is a dictionary wrapper that exposes the proxy configuration stored in 146 // This is a dictionary wrapper that exposes the proxy configuration stored in
146 // the browser preferences. 147 // the browser preferences.
147 ProxyConfigDictionary config( 148 ProxyConfigDictionary config(
148 static_cast<const base::DictionaryValue*>(browser_pref)); 149 static_cast<const base::DictionaryValue*>(browser_pref)
150 ->CreateDeepCopy());
149 151
150 ProxyPrefs::ProxyMode mode; 152 ProxyPrefs::ProxyMode mode;
151 if (!config.GetMode(&mode)) { 153 if (!config.GetMode(&mode)) {
152 LOG(ERROR) << "Cannot determine proxy mode."; 154 LOG(ERROR) << "Cannot determine proxy mode.";
153 return NULL; 155 return NULL;
154 } 156 }
155 157
156 // Build a new ProxyConfig instance as defined in the extension API. 158 // Build a new ProxyConfig instance as defined in the extension API.
157 std::unique_ptr<base::DictionaryValue> extension_pref( 159 std::unique_ptr<base::DictionaryValue> extension_pref(
158 new base::DictionaryValue); 160 new base::DictionaryValue);
(...skipping 26 matching lines...) Expand all
185 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); 187 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict);
186 break; 188 break;
187 } 189 }
188 case ProxyPrefs::kModeCount: 190 case ProxyPrefs::kModeCount:
189 NOTREACHED(); 191 NOTREACHED();
190 } 192 }
191 return extension_pref.release(); 193 return extension_pref.release();
192 } 194 }
193 195
194 } // namespace extensions 196 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698