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

Side by Side Diff: chrome/browser/prefs/command_line_pref_store.cc

Issue 6240013: Make proxy settings one atomic dictionary in the PrefStores such that modifications are atomic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/out/Debug
Patch Set: Updated to ToT and addressed Matt's comments in base-CL Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/prefs/command_line_pref_store.h" 5 #include "chrome/browser/prefs/command_line_pref_store.h"
6 6
7 #include "app/app_switches.h" 7 #include "app/app_switches.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/prefs/proxy_prefs.h" 10 #include "chrome/browser/prefs/proxy_prefs.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "ui/base/ui_base_switches.h" 13 #include "ui/base/ui_base_switches.h"
14 14
15 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry 15 const CommandLinePrefStore::StringSwitchToPreferenceMapEntry
16 CommandLinePrefStore::string_switch_map_[] = { 16 CommandLinePrefStore::string_switch_map_[] = {
17 { switches::kLang, prefs::kApplicationLocale }, 17 { switches::kLang, prefs::kApplicationLocale },
18 { switches::kProxyServer, prefs::kProxyServer },
19 { switches::kProxyPacUrl, prefs::kProxyPacUrl },
20 { switches::kProxyBypassList, prefs::kProxyBypassList },
21 { switches::kAuthSchemes, prefs::kAuthSchemes }, 18 { switches::kAuthSchemes, prefs::kAuthSchemes },
22 { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist }, 19 { switches::kAuthServerWhitelist, prefs::kAuthServerWhitelist },
23 { switches::kAuthNegotiateDelegateWhitelist, 20 { switches::kAuthNegotiateDelegateWhitelist,
24 prefs::kAuthNegotiateDelegateWhitelist }, 21 prefs::kAuthNegotiateDelegateWhitelist },
25 { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName }, 22 { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName },
26 }; 23 };
27 24
28 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry 25 const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry
29 CommandLinePrefStore::boolean_switch_map_[] = { 26 CommandLinePrefStore::boolean_switch_map_[] = {
30 { switches::kDisableAuthNegotiateCnameLookup, 27 { switches::kDisableAuthNegotiateCnameLookup,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 command_line_->HasSwitch(switches::kProxyBypassList))) { 67 command_line_->HasSwitch(switches::kProxyBypassList))) {
71 LOG(WARNING) << "Additional command-line proxy switches specified when --" 68 LOG(WARNING) << "Additional command-line proxy switches specified when --"
72 << switches::kNoProxyServer << " was also specified."; 69 << switches::kNoProxyServer << " was also specified.";
73 return false; 70 return false;
74 } 71 }
75 return true; 72 return true;
76 } 73 }
77 74
78 void CommandLinePrefStore::ApplyProxyMode() { 75 void CommandLinePrefStore::ApplyProxyMode() {
79 if (command_line_->HasSwitch(switches::kNoProxyServer)) { 76 if (command_line_->HasSwitch(switches::kNoProxyServer)) {
80 SetValue(prefs::kProxyMode, 77 SetValue(prefs::kProxy,
81 Value::CreateIntegerValue(ProxyPrefs::MODE_DIRECT)); 78 ProxyPrefsDictionary::CreateDirect());
82 } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) { 79 } else if (command_line_->HasSwitch(switches::kProxyPacUrl)) {
83 SetValue(prefs::kProxyMode, 80 std::string pac_script_url =
84 Value::CreateIntegerValue(ProxyPrefs::MODE_PAC_SCRIPT)); 81 command_line_->GetSwitchValueASCII(switches::kProxyPacUrl);
82 SetValue(prefs::kProxy,
83 ProxyPrefsDictionary::CreatePacScript(pac_script_url));
85 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) { 84 } else if (command_line_->HasSwitch(switches::kProxyAutoDetect)) {
86 SetValue(prefs::kProxyMode, 85 SetValue(prefs::kProxy,
87 Value::CreateIntegerValue(ProxyPrefs::MODE_AUTO_DETECT)); 86 ProxyPrefsDictionary::CreateAutoDetect());
88 } else if (command_line_->HasSwitch(switches::kProxyServer)) { 87 } else if (command_line_->HasSwitch(switches::kProxyServer)) {
89 SetValue(prefs::kProxyMode, 88 std::string proxy_server =
90 Value::CreateIntegerValue(ProxyPrefs::MODE_FIXED_SERVERS)); 89 command_line_->GetSwitchValueASCII(switches::kProxyServer);
90 std::string bypass_list =
91 command_line_->GetSwitchValueASCII(switches::kProxyBypassList);
92 SetValue(prefs::kProxy,
93 ProxyPrefsDictionary::CreateFixedServers(proxy_server,
94 bypass_list));
91 } 95 }
92 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698