OLD | NEW |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
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 the extension API JSON. |
101 CHECK(extension_pref->IsType(Value::TYPE_DICTIONARY)); | 101 CHECK(extension_pref->IsType(Value::TYPE_DICTIONARY)); |
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; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |