OLD | NEW |
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 "net/proxy/proxy_config_service_linux.h" | 5 #include "net/proxy/proxy_config_service_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #if defined(USE_GCONF) |
9 #include <gconf/gconf-client.h> | 10 #include <gconf/gconf-client.h> |
| 11 #endif |
10 #include <limits.h> | 12 #include <limits.h> |
11 #include <stdio.h> | 13 #include <stdio.h> |
12 #include <stdlib.h> | 14 #include <stdlib.h> |
13 #include <sys/inotify.h> | 15 #include <sys/inotify.h> |
14 #include <unistd.h> | 16 #include <unistd.h> |
15 | 17 |
16 #include <map> | 18 #include <map> |
17 | 19 |
18 #include "base/environment.h" | 20 #include "base/environment.h" |
19 #include "base/file_path.h" | 21 #include "base/file_path.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // is understood to mean a bypass of "*google.com". | 180 // is understood to mean a bypass of "*google.com". |
179 config->proxy_rules().bypass_rules.ParseFromStringUsingSuffixMatching( | 181 config->proxy_rules().bypass_rules.ParseFromStringUsingSuffixMatching( |
180 no_proxy); | 182 no_proxy); |
181 return true; | 183 return true; |
182 } | 184 } |
183 | 185 |
184 namespace { | 186 namespace { |
185 | 187 |
186 const int kDebounceTimeoutMilliseconds = 250; | 188 const int kDebounceTimeoutMilliseconds = 250; |
187 | 189 |
| 190 #if defined(USE_GCONF) |
188 // This is the "real" gconf version that actually uses gconf. | 191 // This is the "real" gconf version that actually uses gconf. |
189 class GConfSettingGetterImplGConf | 192 class GConfSettingGetterImplGConf |
190 : public ProxyConfigServiceLinux::GConfSettingGetter { | 193 : public ProxyConfigServiceLinux::GConfSettingGetter { |
191 public: | 194 public: |
192 GConfSettingGetterImplGConf() | 195 GConfSettingGetterImplGConf() |
193 : client_(NULL), notify_delegate_(NULL), loop_(NULL) {} | 196 : client_(NULL), notify_delegate_(NULL), loop_(NULL) {} |
194 | 197 |
195 virtual ~GConfSettingGetterImplGConf() { | 198 virtual ~GConfSettingGetterImplGConf() { |
196 // client_ should have been released before now, from | 199 // client_ should have been released before now, from |
197 // Delegate::OnDestroy(), while running on the UI thread. However | 200 // Delegate::OnDestroy(), while running on the UI thread. However |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 ProxyConfigServiceLinux::Delegate* notify_delegate_; | 415 ProxyConfigServiceLinux::Delegate* notify_delegate_; |
413 base::OneShotTimer<GConfSettingGetterImplGConf> debounce_timer_; | 416 base::OneShotTimer<GConfSettingGetterImplGConf> debounce_timer_; |
414 | 417 |
415 // Message loop of the thread that we make gconf calls on. It should | 418 // Message loop of the thread that we make gconf calls on. It should |
416 // be the UI thread and all our methods should be called on this | 419 // be the UI thread and all our methods should be called on this |
417 // thread. Only for assertions. | 420 // thread. Only for assertions. |
418 MessageLoop* loop_; | 421 MessageLoop* loop_; |
419 | 422 |
420 DISALLOW_COPY_AND_ASSIGN(GConfSettingGetterImplGConf); | 423 DISALLOW_COPY_AND_ASSIGN(GConfSettingGetterImplGConf); |
421 }; | 424 }; |
| 425 #endif // defined(USE_GCONF) |
422 | 426 |
423 // This is the KDE version that reads kioslaverc and simulates gconf. | 427 // This is the KDE version that reads kioslaverc and simulates gconf. |
424 // Doing this allows the main Delegate code, as well as the unit tests | 428 // Doing this allows the main Delegate code, as well as the unit tests |
425 // for it, to stay the same - and the settings map fairly well besides. | 429 // for it, to stay the same - and the settings map fairly well besides. |
426 class GConfSettingGetterImplKDE | 430 class GConfSettingGetterImplKDE |
427 : public ProxyConfigServiceLinux::GConfSettingGetter, | 431 : public ProxyConfigServiceLinux::GConfSettingGetter, |
428 public base::MessagePumpLibevent::Watcher { | 432 public base::MessagePumpLibevent::Watcher { |
429 public: | 433 public: |
430 explicit GConfSettingGetterImplKDE(base::Environment* env_var_getter) | 434 explicit GConfSettingGetterImplKDE(base::Environment* env_var_getter) |
431 : inotify_fd_(-1), notify_delegate_(NULL), indirect_manual_(false), | 435 : inotify_fd_(-1), notify_delegate_(NULL), indirect_manual_(false), |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1061 |
1058 return true; | 1062 return true; |
1059 } | 1063 } |
1060 | 1064 |
1061 ProxyConfigServiceLinux::Delegate::Delegate(base::Environment* env_var_getter) | 1065 ProxyConfigServiceLinux::Delegate::Delegate(base::Environment* env_var_getter) |
1062 : env_var_getter_(env_var_getter), | 1066 : env_var_getter_(env_var_getter), |
1063 glib_default_loop_(NULL), io_loop_(NULL) { | 1067 glib_default_loop_(NULL), io_loop_(NULL) { |
1064 // Figure out which GConfSettingGetterImpl to use, if any. | 1068 // Figure out which GConfSettingGetterImpl to use, if any. |
1065 switch (base::nix::GetDesktopEnvironment(env_var_getter)) { | 1069 switch (base::nix::GetDesktopEnvironment(env_var_getter)) { |
1066 case base::nix::DESKTOP_ENVIRONMENT_GNOME: | 1070 case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
| 1071 #if defined(USE_GCONF) |
1067 gconf_getter_.reset(new GConfSettingGetterImplGConf()); | 1072 gconf_getter_.reset(new GConfSettingGetterImplGConf()); |
| 1073 #endif |
1068 break; | 1074 break; |
1069 case base::nix::DESKTOP_ENVIRONMENT_KDE3: | 1075 case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
1070 case base::nix::DESKTOP_ENVIRONMENT_KDE4: | 1076 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
1071 gconf_getter_.reset(new GConfSettingGetterImplKDE(env_var_getter)); | 1077 gconf_getter_.reset(new GConfSettingGetterImplKDE(env_var_getter)); |
1072 break; | 1078 break; |
1073 case base::nix::DESKTOP_ENVIRONMENT_XFCE: | 1079 case base::nix::DESKTOP_ENVIRONMENT_XFCE: |
1074 case base::nix::DESKTOP_ENVIRONMENT_OTHER: | 1080 case base::nix::DESKTOP_ENVIRONMENT_OTHER: |
1075 break; | 1081 break; |
1076 } | 1082 } |
1077 } | 1083 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 : delegate_(new Delegate(env_var_getter)) { | 1249 : delegate_(new Delegate(env_var_getter)) { |
1244 } | 1250 } |
1245 | 1251 |
1246 ProxyConfigServiceLinux::ProxyConfigServiceLinux( | 1252 ProxyConfigServiceLinux::ProxyConfigServiceLinux( |
1247 base::Environment* env_var_getter, | 1253 base::Environment* env_var_getter, |
1248 GConfSettingGetter* gconf_getter) | 1254 GConfSettingGetter* gconf_getter) |
1249 : delegate_(new Delegate(env_var_getter, gconf_getter)) { | 1255 : delegate_(new Delegate(env_var_getter, gconf_getter)) { |
1250 } | 1256 } |
1251 | 1257 |
1252 } // namespace net | 1258 } // namespace net |
OLD | NEW |