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

Side by Side Diff: chrome/browser/prefs/proxy_prefs.h

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 #ifndef CHROME_BROWSER_PREFS_PROXY_PREFS_H_ 5 #ifndef CHROME_BROWSER_PREFS_PROXY_PREFS_H_
6 #define CHROME_BROWSER_PREFS_PROXY_PREFS_H_ 6 #define CHROME_BROWSER_PREFS_PROXY_PREFS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/values.h"
12
11 namespace ProxyPrefs { 13 namespace ProxyPrefs {
12 14
13 // Possible types of specifying proxy settings. Do not change the order of 15 // Possible types of specifying proxy settings. Do not change the order of
14 // the constants, because numeric values are exposed to users. 16 // the constants, because numeric values are exposed to users.
15 // If you add an enum constant, you should also add a string to 17 // If you add an enum constant, you should also add a string to
16 // kProxyModeNames in the .cc file. 18 // kProxyModeNames in the .cc file.
17 enum ProxyMode { 19 enum ProxyMode {
18 // Direct connection to the network, other proxy preferences are ignored. 20 // Direct connection to the network, other proxy preferences are ignored.
19 MODE_DIRECT = 0, 21 MODE_DIRECT = 0,
20 22
(...skipping 22 matching lines...) Expand all
43 extern const char kPacScriptProxyModeName[]; 45 extern const char kPacScriptProxyModeName[];
44 extern const char kFixedServersProxyModeName[]; 46 extern const char kFixedServersProxyModeName[];
45 extern const char kSystemProxyModeName[]; 47 extern const char kSystemProxyModeName[];
46 48
47 bool IntToProxyMode(int in_value, ProxyMode* out_value); 49 bool IntToProxyMode(int in_value, ProxyMode* out_value);
48 bool StringToProxyMode(const std::string& in_value, 50 bool StringToProxyMode(const std::string& in_value,
49 ProxyMode* out_value); 51 ProxyMode* out_value);
50 52
51 } // namespace ProxyPrefs 53 } // namespace ProxyPrefs
52 54
55 // Factory and wrapper for proxy preferences dictionaries that are stored
56 // in the user preferences. The dictionary has the following structure:
57 // {
58 // mode: string,
59 // server: string,
60 // pac_url: string,
61 // bypass_list: string
62 // }
63 // See proxy_prefs.cc for the structure of the respective strings.
64 class ProxyPrefsDictionary {
danno 2011/02/04 10:32:13 How about putting this in the ProxyPrefs namespace
battre 2011/02/07 14:13:47 I have renamed ProxyPrefsDictionary to ProxyConfig
65 public:
66 explicit ProxyPrefsDictionary(const DictionaryValue* dict);
67
68 bool GetMode(ProxyPrefs::ProxyMode* out) const;
69 bool GetPacUrl(std::string* out) const;
70 bool GetProxyServer(std::string* out) const;
71 bool GetBypassList(std::string* out) const;
72
73 static DictionaryValue* CreateDirect();
74 static DictionaryValue* CreateAutoDetect();
75 static DictionaryValue* CreatePacScript(const std::string& pac_url);
76 static DictionaryValue* CreateFixedServers(
77 const std::string& proxy_server,
78 const std::string& bypass_list);
79 static DictionaryValue* CreateSystem();
80 private:
81 static DictionaryValue* CreateDictionary(ProxyPrefs::ProxyMode mode,
82 const std::string& pac_url,
83 const std::string& proxy_server,
84 const std::string& bypass_list);
85
86 const DictionaryValue* dict_; // weak pointer
danno 2011/02/04 10:32:13 Would it not be better/safer to copy the dictionar
battre 2011/02/07 14:13:47 Done.
87
88 DISALLOW_COPY_AND_ASSIGN(ProxyPrefsDictionary);
89 };
90
53 #endif // CHROME_BROWSER_PREFS_PROXY_PREFS_H_ 91 #endif // CHROME_BROWSER_PREFS_PROXY_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698