Index: chrome/browser/extensions/extension_proxy_api.cc |
diff --git a/chrome/browser/extensions/extension_proxy_api.cc b/chrome/browser/extensions/extension_proxy_api.cc |
index 9bc33cbf5681cc01b57efc1299fe72db7803f1b1..5c42b29caaeca8d368944bed6c0fa07983a22c1a 100644 |
--- a/chrome/browser/extensions/extension_proxy_api.cc |
+++ b/chrome/browser/extensions/extension_proxy_api.cc |
@@ -7,6 +7,7 @@ |
#include "base/string_util.h" |
#include "base/stringprintf.h" |
#include "base/values.h" |
+#include "chrome/browser/prefs/proxy_prefs.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/common/pref_names.h" |
@@ -53,8 +54,8 @@ bool UseCustomProxySettingsFunction::RunImpl() { |
DictionaryValue* proxy_config; |
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &proxy_config)); |
- bool auto_detect = false; |
- proxy_config->GetBoolean("autoDetect", &auto_detect); |
+ std::string proxy_mode; |
+ proxy_config->GetString("mode", &proxy_mode); |
DictionaryValue* pac_dict = NULL; |
proxy_config->GetDictionary("pacScript", &pac_dict); |
@@ -62,7 +63,9 @@ bool UseCustomProxySettingsFunction::RunImpl() { |
DictionaryValue* proxy_rules = NULL; |
proxy_config->GetDictionary("rules", &proxy_rules); |
- return ApplyAutoDetect(auto_detect) && |
+ // TODO(battre,gfeher): Make sure all the preferences get always |
+ // overwritten. |
+ return ApplyMode(proxy_mode) && |
ApplyPacScript(pac_dict) && |
ApplyProxyRules(proxy_rules); |
} |
@@ -75,13 +78,20 @@ bool UseCustomProxySettingsFunction::GetProxyServer( |
return true; |
} |
-bool UseCustomProxySettingsFunction::ApplyAutoDetect(bool auto_detect) { |
- // We take control of the auto-detect preference even if none was specified, |
+bool UseCustomProxySettingsFunction::ApplyMode(const std::string& mode) { |
+ // We take control of the mode preference even if none was specified, |
// so that all proxy preferences are controlled by the same extension (if not |
// by a higher-priority source). |
- SendNotification(prefs::kProxyAutoDetect, |
- Value::CreateBooleanValue(auto_detect)); |
- return true; |
+ bool result = true; |
+ ProxyPrefs::ProxyServerMode mode_enum; |
+ if (!ProxyPrefs::StringToProxyMode(mode, &mode_enum)) { |
+ mode_enum = ProxyPrefs::SYSTEM; |
+ LOG(WARNING) << "Invalid mode for proxy settings: " << mode << std::endl; |
Pam (message me for reviews)
2010/12/18 08:29:55
Is the endl needed? I don't recall seeing it in ot
battre (please use the other)
2010/12/20 12:57:23
Done.
Mattias Nissler (ping if slow)
2010/12/20 13:34:03
No, it gets appended automatically. Please remove.
battre (please use the other)
2010/12/21 14:18:18
Done.
|
+ result = false; |
+ } |
+ SendNotification(prefs::kProxyServerMode, |
Mattias Nissler (ping if slow)
2010/12/20 13:34:03
I think it's time to rename SendNotification() to
battre (please use the other)
2010/12/21 14:18:18
Done.
|
+ Value::CreateIntegerValue(mode_enum)); |
+ return result; |
} |
bool UseCustomProxySettingsFunction::ApplyPacScript(DictionaryValue* pac_dict) { |