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

Side by Side Diff: chrome/browser/prefs/proxy_config_dictionary.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: Fixed Lint comment 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/prefs/proxy_config_dictionary.h"
6
7 #include "base/basictypes.h"
8 #include "base/logging.h"
9 #include "base/values.h"
10
11 namespace {
12
13 // Integer to specify the type of proxy settings.
14 // See ProxyPrefs for possible values and interactions with the other proxy
15 // preferences.
16 const char kProxyMode[] = "mode";
17 // String specifying the proxy server. For a specification of the expected
18 // syntax see net::ProxyConfig::ProxyRules::ParseFromString().
19 const char kProxyServer[] = "server";
20 // URL to the proxy .pac file.
21 const char kProxyPacUrl[] = "pac_url";
22 // String containing proxy bypass rules. For a specification of the
23 // expected syntax see net::ProxyBypassRules::ParseFromString().
24 const char kProxyBypassList[] = "bypass_list";
25
26 } // namespace
27
28 ProxyConfigDictionary::ProxyConfigDictionary(const DictionaryValue* dict)
29 : dict_(dict->DeepCopy()) {
30 }
31
32 bool ProxyConfigDictionary::GetMode(ProxyPrefs::ProxyMode* out) const {
33 std::string mode_str;
34 return dict_->GetString(kProxyMode, &mode_str)
35 && StringToProxyMode(mode_str, out);
36 }
37
38 bool ProxyConfigDictionary::GetPacUrl(std::string* out) const {
39 return dict_->GetString(kProxyPacUrl, out);
40 }
41
42 bool ProxyConfigDictionary::GetProxyServer(std::string* out) const {
43 return dict_->GetString(kProxyServer, out);
44 }
45
46 bool ProxyConfigDictionary::GetBypassList(std::string* out) const {
47 return dict_->GetString(kProxyBypassList, out);
48 }
49
50 // static
51 DictionaryValue* ProxyConfigDictionary::CreateDirect() {
52 return CreateDictionary(ProxyPrefs::MODE_DIRECT, "", "", "");
53 }
54
55 // static
56 DictionaryValue* ProxyConfigDictionary::CreateAutoDetect() {
57 return CreateDictionary(ProxyPrefs::MODE_AUTO_DETECT, "", "", "");
58 }
59
60 // static
61 DictionaryValue* ProxyConfigDictionary::CreatePacScript(
62 const std::string& pac_url) {
63 return CreateDictionary(ProxyPrefs::MODE_PAC_SCRIPT, pac_url, "", "");
64 }
65
66 // static
67 DictionaryValue* ProxyConfigDictionary::CreateFixedServers(
68 const std::string& proxy_server,
69 const std::string& bypass_list) {
70 return CreateDictionary(
71 ProxyPrefs::MODE_FIXED_SERVERS, "", proxy_server, bypass_list);
72 }
73
74 // static
75 DictionaryValue* ProxyConfigDictionary::CreateSystem() {
76 return CreateDictionary(ProxyPrefs::MODE_SYSTEM, "", "", "");
77 }
78
79 // static
80 DictionaryValue* ProxyConfigDictionary::CreateDictionary(
81 ProxyPrefs::ProxyMode mode,
82 const std::string& pac_url,
83 const std::string& proxy_server,
84 const std::string& bypass_list) {
85 DictionaryValue* dict = new DictionaryValue();
86 dict->SetString(kProxyMode, GetProxyModeName(mode));
87 if (!pac_url.empty())
88 dict->SetString(kProxyPacUrl, pac_url);
89 if (!proxy_server.empty())
90 dict->SetString(kProxyServer, proxy_server);
91 if (!bypass_list.empty())
92 dict->SetString(kProxyBypassList, bypass_list);
93 return dict;
94 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/proxy_config_dictionary.h ('k') | chrome/browser/prefs/proxy_config_dictionary_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698