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

Side by Side Diff: chrome/browser/extensions/extension_proxy_api_helpers.cc

Issue 8869003: Move the "extension" namespace from extension_api.json into extension_api_extension.json. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build.py again? Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // Extension Pref -> Browser Pref conversion. 58 // Extension Pref -> Browser Pref conversion.
59 59
60 bool GetProxyModeFromExtensionPref(const DictionaryValue* proxy_config, 60 bool GetProxyModeFromExtensionPref(const DictionaryValue* proxy_config,
61 ProxyPrefs::ProxyMode* out, 61 ProxyPrefs::ProxyMode* out,
62 std::string* error, 62 std::string* error,
63 bool* bad_message) { 63 bool* bad_message) {
64 std::string proxy_mode; 64 std::string proxy_mode;
65 65
66 // We can safely assume that this is ASCII due to the allowed enumeration 66 // We can safely assume that this is ASCII due to the allowed enumeration
67 // values specified in extension_api.json. 67 // values specified in the extension API JSON.
68 proxy_config->GetStringASCII(keys::kProxyConfigMode, &proxy_mode); 68 proxy_config->GetStringASCII(keys::kProxyConfigMode, &proxy_mode);
69 if (!ProxyPrefs::StringToProxyMode(proxy_mode, out)) { 69 if (!ProxyPrefs::StringToProxyMode(proxy_mode, out)) {
70 LOG(ERROR) << "Invalid mode for proxy settings: " << proxy_mode; 70 LOG(ERROR) << "Invalid mode for proxy settings: " << proxy_mode;
71 *bad_message = true; 71 *bad_message = true;
72 return false; 72 return false;
73 } 73 }
74 return true; 74 return true;
75 } 75 }
76 76
77 bool GetPacMandatoryFromExtensionPref(const DictionaryValue* proxy_config, 77 bool GetPacMandatoryFromExtensionPref(const DictionaryValue* proxy_config,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 bool GetProxyServer(const DictionaryValue* proxy_server, 149 bool GetProxyServer(const DictionaryValue* proxy_server,
150 net::ProxyServer::Scheme default_scheme, 150 net::ProxyServer::Scheme default_scheme,
151 net::ProxyServer* out, 151 net::ProxyServer* out,
152 std::string* error, 152 std::string* error,
153 bool* bad_message) { 153 bool* bad_message) {
154 std::string scheme_string; // optional. 154 std::string scheme_string; // optional.
155 155
156 // We can safely assume that this is ASCII due to the allowed enumeration 156 // We can safely assume that this is ASCII due to the allowed enumeration
157 // values specified in extension_api.json. 157 // values specified in the extension API JSON.
158 proxy_server->GetStringASCII(keys::kProxyConfigRuleScheme, &scheme_string); 158 proxy_server->GetStringASCII(keys::kProxyConfigRuleScheme, &scheme_string);
159 159
160 net::ProxyServer::Scheme scheme = 160 net::ProxyServer::Scheme scheme =
161 net::ProxyServer::GetSchemeFromURI(scheme_string); 161 net::ProxyServer::GetSchemeFromURI(scheme_string);
162 if (scheme == net::ProxyServer::SCHEME_INVALID) 162 if (scheme == net::ProxyServer::SCHEME_INVALID)
163 scheme = default_scheme; 163 scheme = default_scheme;
164 164
165 // TODO(battre): handle UTF-8 in hostnames (http://crbug.com/72692). 165 // TODO(battre): handle UTF-8 in hostnames (http://crbug.com/72692).
166 string16 host16; 166 string16 host16;
167 if (!proxy_server->GetString(keys::kProxyConfigRuleHost, &host16)) { 167 if (!proxy_server->GetString(keys::kProxyConfigRuleHost, &host16)) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 ListValue* TokenizeToStringList(const std::string& in, 479 ListValue* TokenizeToStringList(const std::string& in,
480 const std::string& delims) { 480 const std::string& delims) {
481 ListValue* out = new ListValue; 481 ListValue* out = new ListValue;
482 StringTokenizer entries(in, delims); 482 StringTokenizer entries(in, delims);
483 while (entries.GetNext()) 483 while (entries.GetNext())
484 out->Append(Value::CreateStringValue(entries.token())); 484 out->Append(Value::CreateStringValue(entries.token()));
485 return out; 485 return out;
486 } 486 }
487 487
488 } // namespace extension_proxy_api_helpers 488 } // namespace extension_proxy_api_helpers
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_proxy_api.cc ('k') | chrome/browser/extensions/extension_webnavigation_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698