Index: chrome/browser/browser_process_impl.cc |
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc |
index ad5d4a4b67727b5fb31aa70fbcca93fe458f766f..55fc18cd6005b8808403385cf1dedc35143f7951 100644 |
--- a/chrome/browser/browser_process_impl.cc |
+++ b/chrome/browser/browser_process_impl.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -34,6 +34,7 @@ |
#include "chrome/browser/metrics/metrics_service.h" |
#include "chrome/browser/net/chrome_net_log.h" |
#include "chrome/browser/net/predictor_api.h" |
+#include "chrome/browser/net/pref_proxy_config_service.h" |
#include "chrome/browser/net/sdch_dictionary_fetcher.h" |
#include "chrome/browser/notifications/notification_ui_manager.h" |
#include "chrome/browser/plugin_data_remover.h" |
@@ -50,6 +51,7 @@ |
#include "chrome/browser/safe_browsing/safe_browsing_service.h" |
#include "chrome/browser/shell_integration.h" |
#include "chrome/browser/sidebar/sidebar_manager.h" |
+#include "chrome/browser/system_url_request_context_getter.h" |
#include "chrome/browser/tab_closeable_state_watcher.h" |
#include "chrome/common/chrome_constants.h" |
#include "chrome/common/chrome_paths.h" |
@@ -245,6 +247,11 @@ BrowserProcessImpl::~BrowserProcessImpl() { |
// on the db thread too. |
db_thread_.reset(); |
+ // Need to destroy PrefProxyConfigTracker before local state, since it |
+ // caches a pointer to it. |
+ pref_proxy_config_tracker_->DetachFromPrefService(); |
+ pref_proxy_config_tracker_ = NULL; |
+ |
// At this point, no render process exist and the file, io, db, and |
// webkit threads in this process have all terminated, so it's safe |
// to access local state data such as cookies, database, or local storage. |
@@ -423,6 +430,20 @@ ui::Clipboard* BrowserProcessImpl::clipboard() { |
return clipboard_.get(); |
} |
+PrefProxyConfigTracker* BrowserProcessImpl::pref_proxy_config_tracker() { |
+ DCHECK(CalledOnValidThread()); |
+ if (!created_pref_proxy_config_tracker_) |
+ CreatePrefProxyConfigTracker(); |
+ return pref_proxy_config_tracker_.get(); |
+} |
+ |
+URLRequestContextGetter* BrowserProcessImpl::system_request_context() { |
+ DCHECK(CalledOnValidThread()); |
+ if (!system_request_context_) |
+ CreateSystemRequestContextGetter(); |
+ return system_request_context_.get(); |
+} |
+ |
NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
DCHECK(CalledOnValidThread()); |
if (!created_notification_ui_manager_) |
@@ -829,6 +850,18 @@ void BrowserProcessImpl::CreateSafeBrowsingDetectionService() { |
} |
} |
+void BrowserProcessImpl::CreatePrefProxyConfigTracker() { |
+ DCHECK(pref_proxy_config_tracker_.get() == NULL); |
+ created_pref_proxy_config_tracker_ = true; |
+ pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state()); |
+} |
+ |
+void BrowserProcessImpl::CreateSystemRequestContextGetter() { |
+ DCHECK(system_request_context_.get() == NULL); |
+ created_system_request_context_ = true; |
+ system_request_context_ = new SystemURLRequestContextGetter(io_thread()); |
+} |
+ |
bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { |
// The safe browsing client-side detection is enabled only if the switch is |
// enabled and when safe browsing related stats is allowed to be collected. |
@@ -950,3 +983,32 @@ void BrowserProcessImpl::OnAutoupdateTimer() { |
} |
#endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
+ |
+void BrowserProcessImpl::InitSystemRequestContext() { |
+ // The linux gconf-based proxy settings getter relies on being initialized |
+ // from the UI thread. |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ |
+ // Create a baseline service that provides proxy configuration in case nothing |
+ // is configured through prefs (Note: prefs include command line and |
+ // configuration policy). |
+ net::ProxyConfigService* base_service = NULL; |
+ |
+ // TODO(port): the IO and FILE message loops are only used by Linux. Can |
+ // that code be moved to chrome/browser instead of being in net, so that it |
+ // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. |
+#if defined(OS_CHROMEOS) |
+ base_service = new chromeos::ProxyConfigService( |
+ new chromeos::ProxyConfigServiceImpl()); |
+#else |
+ base_service = net::ProxyService::CreateSystemProxyConfigService( |
+ io_thread()->message_loop(), file_thread()->message_loop()); |
+#endif // defined(OS_CHROMEOS) |
+ |
+ net::ProxyConfigService* config_service = |
+ new PrefProxyConfigService(pref_proxy_config_tracker(), |
+ base_service); |
+ |
+ // Takes ownership of config_service. |
+ io_thread()->InitSystemRequestContext(config_service); |
+} |