OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 <gconf/gconf-client.h> | 7 #include <gconf/gconf-client.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
| 10 #include "base/linux_util.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/string_tokenizer.h" | 12 #include "base/string_tokenizer.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/task.h" | 14 #include "base/task.h" |
14 #include "googleurl/src/url_canon.h" | 15 #include "googleurl/src/url_canon.h" |
15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
16 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
17 #include "net/proxy/proxy_config.h" | 18 #include "net/proxy/proxy_config.h" |
18 #include "net/proxy/proxy_server.h" | 19 #include "net/proxy/proxy_server.h" |
19 | 20 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 529 } |
529 | 530 |
530 ProxyConfigServiceLinux::Delegate::Delegate( | 531 ProxyConfigServiceLinux::Delegate::Delegate( |
531 EnvironmentVariableGetter* env_var_getter, | 532 EnvironmentVariableGetter* env_var_getter, |
532 GConfSettingGetter* gconf_getter) | 533 GConfSettingGetter* gconf_getter) |
533 : env_var_getter_(env_var_getter), gconf_getter_(gconf_getter), | 534 : env_var_getter_(env_var_getter), gconf_getter_(gconf_getter), |
534 glib_default_loop_(NULL), io_loop_(NULL) { | 535 glib_default_loop_(NULL), io_loop_(NULL) { |
535 } | 536 } |
536 | 537 |
537 bool ProxyConfigServiceLinux::Delegate::ShouldTryGConf() { | 538 bool ProxyConfigServiceLinux::Delegate::ShouldTryGConf() { |
538 // GNOME_DESKTOP_SESSION_ID being defined is a good indication that | |
539 // we are probably running under GNOME. | |
540 // Note: KDE_FULL_SESSION is a corresponding env var to recognize KDE. | |
541 std::string dummy, desktop_session; | |
542 return env_var_getter_->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy) | |
543 || (env_var_getter_->Getenv("DESKTOP_SESSION", &desktop_session) | |
544 && desktop_session == "gnome"); | |
545 // I (sdoyon) would have liked to prioritize environment variables | 539 // I (sdoyon) would have liked to prioritize environment variables |
546 // and only fallback to gconf if env vars were unset. But | 540 // and only fallback to gconf if env vars were unset. But |
547 // gnome-terminal "helpfully" sets http_proxy and no_proxy, and it | 541 // gnome-terminal "helpfully" sets http_proxy and no_proxy, and it |
548 // does so even if the proxy mode is set to auto, which would | 542 // does so even if the proxy mode is set to auto, which would |
549 // mislead us. | 543 // mislead us. |
550 // | 544 // |
551 // We could introduce a CHROME_PROXY_OBEY_ENV_VARS variable...?? | 545 // We could introduce a CHROME_PROXY_OBEY_ENV_VARS variable...?? |
| 546 return base::UseGnomeForSettings(); |
552 } | 547 } |
553 | 548 |
554 void ProxyConfigServiceLinux::Delegate::SetupAndFetchInitialConfig( | 549 void ProxyConfigServiceLinux::Delegate::SetupAndFetchInitialConfig( |
555 MessageLoop* glib_default_loop, MessageLoop* io_loop) { | 550 MessageLoop* glib_default_loop, MessageLoop* io_loop) { |
556 // We should be running on the default glib main loop thread right | 551 // We should be running on the default glib main loop thread right |
557 // now. gconf can only be accessed from this thread. | 552 // now. gconf can only be accessed from this thread. |
558 DCHECK(MessageLoop::current() == glib_default_loop); | 553 DCHECK(MessageLoop::current() == glib_default_loop); |
559 glib_default_loop_ = glib_default_loop; | 554 glib_default_loop_ = glib_default_loop; |
560 io_loop_ = io_loop; | 555 io_loop_ = io_loop; |
561 | 556 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 new GConfSettingGetterImpl())) { | 672 new GConfSettingGetterImpl())) { |
678 } | 673 } |
679 | 674 |
680 ProxyConfigServiceLinux::ProxyConfigServiceLinux( | 675 ProxyConfigServiceLinux::ProxyConfigServiceLinux( |
681 EnvironmentVariableGetter* env_var_getter, | 676 EnvironmentVariableGetter* env_var_getter, |
682 GConfSettingGetter* gconf_getter) | 677 GConfSettingGetter* gconf_getter) |
683 : delegate_(new Delegate(env_var_getter, gconf_getter)) { | 678 : delegate_(new Delegate(env_var_getter, gconf_getter)) { |
684 } | 679 } |
685 | 680 |
686 } // namespace net | 681 } // namespace net |
OLD | NEW |