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

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

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 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 helper functions for the Chrome Extensions Proxy Settings 5 // Implementation of helper functions for the Chrome Extensions Proxy Settings
6 // API. 6 // API.
7 // 7 //
8 // Throughout this code, we report errors to the user by setting an |error| 8 // Throughout this code, we report errors to the user by setting an |error|
9 // parameter, if and only if these errors can be cause by invalid input 9 // parameter, if and only if these errors can be cause by invalid input
10 // from the extension and we cannot expect that the extensions API has 10 // from the extension and we cannot expect that the extensions API has
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 NOTREACHED(); 357 NOTREACHED();
358 } 358 }
359 return result_proxy_config; 359 return result_proxy_config;
360 } 360 }
361 361
362 base::DictionaryValue* CreateProxyRulesDict( 362 base::DictionaryValue* CreateProxyRulesDict(
363 const ProxyConfigDictionary& proxy_config) { 363 const ProxyConfigDictionary& proxy_config) {
364 ProxyPrefs::ProxyMode mode; 364 ProxyPrefs::ProxyMode mode;
365 CHECK(proxy_config.GetMode(&mode) && mode == ProxyPrefs::MODE_FIXED_SERVERS); 365 CHECK(proxy_config.GetMode(&mode) && mode == ProxyPrefs::MODE_FIXED_SERVERS);
366 366
367 scoped_ptr<base::DictionaryValue> extension_proxy_rules( 367 std::unique_ptr<base::DictionaryValue> extension_proxy_rules(
368 new base::DictionaryValue); 368 new base::DictionaryValue);
369 369
370 std::string proxy_servers; 370 std::string proxy_servers;
371 if (!proxy_config.GetProxyServer(&proxy_servers)) { 371 if (!proxy_config.GetProxyServer(&proxy_servers)) {
372 LOG(ERROR) << "Missing proxy servers in configuration."; 372 LOG(ERROR) << "Missing proxy servers in configuration.";
373 return NULL; 373 return NULL;
374 } 374 }
375 375
376 net::ProxyConfig::ProxyRules rules; 376 net::ProxyConfig::ProxyRules rules;
377 rules.ParseFromString(proxy_servers); 377 rules.ParseFromString(proxy_servers);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 423 }
424 base::ListValue* bypass_list = 424 base::ListValue* bypass_list =
425 TokenizeToStringList(bypass_list_string, ",;"); 425 TokenizeToStringList(bypass_list_string, ",;");
426 extension_proxy_rules->Set(keys::kProxyConfigBypassList, bypass_list); 426 extension_proxy_rules->Set(keys::kProxyConfigBypassList, bypass_list);
427 } 427 }
428 428
429 return extension_proxy_rules.release(); 429 return extension_proxy_rules.release();
430 } 430 }
431 431
432 base::DictionaryValue* CreateProxyServerDict(const net::ProxyServer& proxy) { 432 base::DictionaryValue* CreateProxyServerDict(const net::ProxyServer& proxy) {
433 scoped_ptr<base::DictionaryValue> out(new base::DictionaryValue); 433 std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
434 switch (proxy.scheme()) { 434 switch (proxy.scheme()) {
435 case net::ProxyServer::SCHEME_HTTP: 435 case net::ProxyServer::SCHEME_HTTP:
436 out->SetString(keys::kProxyConfigRuleScheme, "http"); 436 out->SetString(keys::kProxyConfigRuleScheme, "http");
437 break; 437 break;
438 case net::ProxyServer::SCHEME_HTTPS: 438 case net::ProxyServer::SCHEME_HTTPS:
439 out->SetString(keys::kProxyConfigRuleScheme, "https"); 439 out->SetString(keys::kProxyConfigRuleScheme, "https");
440 break; 440 break;
441 case net::ProxyServer::SCHEME_QUIC: 441 case net::ProxyServer::SCHEME_QUIC:
442 out->SetString(keys::kProxyConfigRuleScheme, "quic"); 442 out->SetString(keys::kProxyConfigRuleScheme, "quic");
443 break; 443 break;
(...skipping 11 matching lines...) Expand all
455 out->SetString(keys::kProxyConfigRuleHost, proxy.host_port_pair().host()); 455 out->SetString(keys::kProxyConfigRuleHost, proxy.host_port_pair().host());
456 out->SetInteger(keys::kProxyConfigRulePort, proxy.host_port_pair().port()); 456 out->SetInteger(keys::kProxyConfigRulePort, proxy.host_port_pair().port());
457 return out.release(); 457 return out.release();
458 } 458 }
459 459
460 base::DictionaryValue* CreatePacScriptDict( 460 base::DictionaryValue* CreatePacScriptDict(
461 const ProxyConfigDictionary& proxy_config) { 461 const ProxyConfigDictionary& proxy_config) {
462 ProxyPrefs::ProxyMode mode; 462 ProxyPrefs::ProxyMode mode;
463 CHECK(proxy_config.GetMode(&mode) && mode == ProxyPrefs::MODE_PAC_SCRIPT); 463 CHECK(proxy_config.GetMode(&mode) && mode == ProxyPrefs::MODE_PAC_SCRIPT);
464 464
465 scoped_ptr<base::DictionaryValue> pac_script_dict(new base::DictionaryValue); 465 std::unique_ptr<base::DictionaryValue> pac_script_dict(
466 new base::DictionaryValue);
466 std::string pac_url; 467 std::string pac_url;
467 if (!proxy_config.GetPacUrl(&pac_url)) { 468 if (!proxy_config.GetPacUrl(&pac_url)) {
468 LOG(ERROR) << "Invalid proxy configuration. Missing PAC URL."; 469 LOG(ERROR) << "Invalid proxy configuration. Missing PAC URL.";
469 return NULL; 470 return NULL;
470 } 471 }
471 bool pac_mandatory = false; 472 bool pac_mandatory = false;
472 if (!proxy_config.GetPacMandatory(&pac_mandatory)) { 473 if (!proxy_config.GetPacMandatory(&pac_mandatory)) {
473 LOG(ERROR) << "Invalid proxy configuration. Missing PAC mandatory field."; 474 LOG(ERROR) << "Invalid proxy configuration. Missing PAC mandatory field.";
474 return NULL; 475 return NULL;
475 } 476 }
(...skipping 17 matching lines...) Expand all
493 const std::string& delims) { 494 const std::string& delims) {
494 base::ListValue* out = new base::ListValue; 495 base::ListValue* out = new base::ListValue;
495 base::StringTokenizer entries(in, delims); 496 base::StringTokenizer entries(in, delims);
496 while (entries.GetNext()) 497 while (entries.GetNext())
497 out->Append(new base::StringValue(entries.token())); 498 out->Append(new base::StringValue(entries.token()));
498 return out; 499 return out;
499 } 500 }
500 501
501 } // namespace proxy_api_helpers 502 } // namespace proxy_api_helpers
502 } // namespace extensions 503 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/proxy/proxy_api.cc ('k') | chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698