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

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

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 years, 4 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 | 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 the Chrome Extensions Proxy Settings API. 5 // Implementation of the Chrome Extensions Proxy Settings API.
6 6
7 #include "chrome/browser/extensions/extension_proxy_api.h" 7 #include "chrome/browser/extensions/extension_proxy_api.h"
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 ProxyPrefTransformer::~ProxyPrefTransformer() { 92 ProxyPrefTransformer::~ProxyPrefTransformer() {
93 } 93 }
94 94
95 Value* ProxyPrefTransformer::ExtensionToBrowserPref(const Value* extension_pref, 95 Value* ProxyPrefTransformer::ExtensionToBrowserPref(const Value* extension_pref,
96 std::string* error, 96 std::string* error,
97 bool* bad_message) { 97 bool* bad_message) {
98 // When ExtensionToBrowserPref is called, the format of |extension_pref| 98 // When ExtensionToBrowserPref is called, the format of |extension_pref|
99 // has been verified already by the extension API to match the schema 99 // has been verified already by the extension API to match the schema
100 // defined in chrome/common/extensions/api/extension_api.json. 100 // defined in chrome/common/extensions/api/extension_api.json.
101 CHECK(extension_pref->IsType(Value::TYPE_DICTIONARY)); 101 CHECK(extension_pref->IsDictionary());
102 const DictionaryValue* config = 102 const DictionaryValue* config =
103 static_cast<const DictionaryValue*>(extension_pref); 103 static_cast<const DictionaryValue*>(extension_pref);
104 104
105 // Extract the various pieces of information passed to 105 // Extract the various pieces of information passed to
106 // chrome.proxy.settings.set(). Several of these strings will 106 // chrome.proxy.settings.set(). Several of these strings will
107 // remain blank no respective values have been passed to set(). 107 // remain blank no respective values have been passed to set().
108 // If a values has been passed to set but could not be parsed, we bail 108 // If a values has been passed to set but could not be parsed, we bail
109 // out and return NULL. 109 // out and return NULL.
110 ProxyPrefs::ProxyMode mode_enum; 110 ProxyPrefs::ProxyMode mode_enum;
111 bool pac_mandatory; 111 bool pac_mandatory;
(...skipping 15 matching lines...) Expand all
127 config, &bypass_list, error, bad_message)) { 127 config, &bypass_list, error, bad_message)) {
128 return NULL; 128 return NULL;
129 } 129 }
130 130
131 return helpers::CreateProxyConfigDict( 131 return helpers::CreateProxyConfigDict(
132 mode_enum, pac_mandatory, pac_url, pac_data, proxy_rules_string, 132 mode_enum, pac_mandatory, pac_url, pac_data, proxy_rules_string,
133 bypass_list, error); 133 bypass_list, error);
134 } 134 }
135 135
136 Value* ProxyPrefTransformer::BrowserToExtensionPref(const Value* browser_pref) { 136 Value* ProxyPrefTransformer::BrowserToExtensionPref(const Value* browser_pref) {
137 CHECK(browser_pref->IsType(Value::TYPE_DICTIONARY)); 137 CHECK(browser_pref->IsDictionary());
138 138
139 // This is a dictionary wrapper that exposes the proxy configuration stored in 139 // This is a dictionary wrapper that exposes the proxy configuration stored in
140 // the browser preferences. 140 // the browser preferences.
141 ProxyConfigDictionary config( 141 ProxyConfigDictionary config(
142 static_cast<const DictionaryValue*>(browser_pref)); 142 static_cast<const DictionaryValue*>(browser_pref));
143 143
144 ProxyPrefs::ProxyMode mode; 144 ProxyPrefs::ProxyMode mode;
145 if (!config.GetMode(&mode)) { 145 if (!config.GetMode(&mode)) {
146 LOG(ERROR) << "Cannot determine proxy mode."; 146 LOG(ERROR) << "Cannot determine proxy mode.";
147 return NULL; 147 return NULL;
(...skipping 27 matching lines...) Expand all
175 if (!proxy_rules_dict) 175 if (!proxy_rules_dict)
176 return NULL; 176 return NULL;
177 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict); 177 extension_pref->Set(keys::kProxyConfigRules, proxy_rules_dict);
178 break; 178 break;
179 } 179 }
180 case ProxyPrefs::kModeCount: 180 case ProxyPrefs::kModeCount:
181 NOTREACHED(); 181 NOTREACHED();
182 } 182 }
183 return extension_pref.release(); 183 return extension_pref.release();
184 } 184 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_management_api.cc ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698