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

Side by Side Diff: net/proxy/proxy_config_service_linux.h

Issue 60009: ProxyConfigService for Linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_
6 #define NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/scoped_ptr.h"
13 #include "net/proxy/proxy_config_service.h"
14 #include "net/proxy/proxy_server.h"
15
16 namespace net {
17
18 // Implementation of ProxyConfigService that retrieves the system proxy
19 // settings from environment variables or gconf.
20 class ProxyConfigServiceLinux : public ProxyConfigService {
21 public:
22
23 // These are used to derive mocks for unittests.
24 class EnvironmentVariableGetter {
25 public:
26 virtual ~EnvironmentVariableGetter() {}
27 // Gets an environment variable's value and stores it in
28 // result. Returns false if the key is unset.
29 virtual bool Getenv(const char* variable_name, std::string* result) = 0;
30 };
31
32 class GConfSettingGetter {
33 public:
34 virtual ~GConfSettingGetter() {}
35
36 // GDK/GTK+ thread-safety: multi-threaded programs coordinate
37 // around a global lock. See
38 // http://library.gnome.org/devel/gdk/unstable/gdk-Threads.html
39 // and http://research.operationaldynamics.com/blogs/andrew/software/gnome-d esktop/gtk-thread-awareness.html
40 // The following methods are used to grab said lock around any
41 // actual gconf usage: including calls to Init() and any of the
42 // Get* methods.
43 virtual void Enter() = 0;
44 virtual void Leave() = 0;
45
46 // Initializes the class: obtains a gconf client, in the concrete
47 // implementation. Returns true on success. Must be called before
48 // any of the Get* methods, and the Get* methods must not be used
49 // if this method returns false. This method may be called again,
50 // whether or not it succeeded before.
51 virtual bool InitIfNeeded() = 0;
52
53 // Gets a string type value from gconf and stores it in result. Returns
54 // false if the key is unset or on error.
55 virtual bool GetString(const char* key, std::string* result) = 0;
56 // Same thing for a bool typed value.
57 virtual bool GetBoolean(const char* key, bool* result) = 0;
58 // Same for an int typed value.
59 virtual bool GetInt(const char* key, int* result) = 0;
60 // And for a string list.
61 virtual bool GetStringList(const char* key,
62 std::vector<std::string>* result) = 0;
63 };
64
65 // Usual constructor
66 ProxyConfigServiceLinux();
67 // For testing: pass in alternate gconf and env var getter implementations.
68 // ProxyConfigServiceLinux takes ownership of the getter objects.
69 ProxyConfigServiceLinux(EnvironmentVariableGetter* env_var_getter,
70 GConfSettingGetter* gconf_getter);
71
72 // ProxyConfigService methods:
73 virtual int GetProxyConfig(ProxyConfig* config);
74
75 private:
76 // Obtains an environment variable's value. Parses a proxy server
77 // specification from it and puts it in result. Returns true if the
78 // requested variable is defined and the value valid.
79 bool GetProxyFromEnvVarForScheme(const char* variable,
80 ProxyServer::Scheme scheme,
81 ProxyServer* result_server);
82 // As above but with scheme set to HTTP, for convenience.
83 bool GetProxyFromEnvVar(const char* variable, ProxyServer* result_server);
84 // Parses entries from the value of the no_proxy env var, and stuffs
85 // them into config->proxy_bypass.
86 void ParseNoProxyList(const std::string& no_proxy, ProxyConfig* config);
87 // Fills proxy config from environment variables. Returns true if
88 // variables were found and the configuration is valid.
89 bool GetConfigFromEnv(ProxyConfig* config);
90
91 // Obtains host and port gconf settings and parses a proxy server
92 // specification from it and puts it in result. Returns true if the
93 // requested variable is defined and the value valid.
94 bool GetProxyFromGConf(const char* key_prefix, bool is_socks,
95 ProxyServer* result_server);
96 // Fills proxy config from gconf. Returns true if settings were found
97 // and the configuration is valid.
98 bool GetConfigFromGConf(ProxyConfig* config);
99
100 scoped_ptr<EnvironmentVariableGetter> env_var_getter_;
101 scoped_ptr<GConfSettingGetter> gconf_getter_;
102
103 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceLinux);
104 };
105
106 } // namespace net
107
108 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_service_common_unittest.cc ('k') | net/proxy/proxy_config_service_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698