diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/preferences_window_controller.mm | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/options/advanced_contents_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/net/net_pref_observer.cc | 26 | ||||
-rw-r--r-- | chrome/browser/net/net_pref_observer.h | 33 | ||||
-rw-r--r-- | chrome/browser/profile_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profile_impl.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/options/advanced_contents_view.cc | 3 |
7 files changed, 66 insertions, 8 deletions
diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 0f11f63..45f2836 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -36,7 +36,6 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/net/predictor_api.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/options_util.h" #include "chrome/browser/options_window.h" @@ -1582,7 +1581,6 @@ const int kDisabledIndex = 1; [self recordUserAction:UserMetricsAction( "Options_DnsPrefetchCheckbox_Disable")]; dnsPrefetch_.SetValueIfNotManaged(value ? true : false); - chrome_browser_net::EnablePredictor(dnsPrefetch_.GetValue()); } // Returns whether the safe browsing checkbox should be checked based on the diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index cda323a..edf89b8 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -32,7 +32,6 @@ #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/gtk/options/content_settings_window_gtk.h" #include "chrome/browser/gtk/options/options_layout_gtk.h" -#include "chrome/browser/net/predictor_api.h" #include "chrome/browser/options_page_base.h" #include "chrome/browser/options_util.h" #include "chrome/browser/prefs/pref_member.h" @@ -930,7 +929,6 @@ void PrivacySection::OnDNSPrefetchingChange(GtkWidget* widget, UserMetricsAction("Options_DnsPrefetchCheckbox_Disable"), privacy_section->profile()->GetPrefs()); privacy_section->dns_prefetch_enabled_.SetValue(enabled); - chrome_browser_net::EnablePredictor(enabled); } // static @@ -1001,7 +999,6 @@ void PrivacySection::NotifyPrefChanged(const std::string* pref_name) { bool enabled = dns_prefetch_enabled_.GetValue(); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(enable_dns_prefetching_checkbox_), enabled); - chrome_browser_net::EnablePredictor(enabled); } if (!pref_name || *pref_name == prefs::kSafeBrowsingEnabled) { gtk_widget_set_sensitive( diff --git a/chrome/browser/net/net_pref_observer.cc b/chrome/browser/net/net_pref_observer.cc new file mode 100644 index 0000000..f81febf --- /dev/null +++ b/chrome/browser/net/net_pref_observer.cc @@ -0,0 +1,26 @@ +// Copyright (c) 2010 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. + +#include "chrome/browser/net/net_pref_observer.h" + +#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/net/predictor_api.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/pref_names.h" + +NetPrefObserver::NetPrefObserver(PrefService* prefs) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + dns_prefetching_enabled_.Init(prefs::kDnsPrefetchingEnabled, prefs, this); +} + +NetPrefObserver::~NetPrefObserver() { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); +} + +void NetPrefObserver::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + chrome_browser_net::EnablePredictor(*dns_prefetching_enabled_); +} diff --git a/chrome/browser/net/net_pref_observer.h b/chrome/browser/net/net_pref_observer.h new file mode 100644 index 0000000..d41e8b7 --- /dev/null +++ b/chrome/browser/net/net_pref_observer.h @@ -0,0 +1,33 @@ +// Copyright (c) 2010 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. + +#ifndef CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ +#define CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ +#pragma once + +#include "base/basictypes.h" +#include "chrome/browser/prefs/pref_member.h" +#include "chrome/common/notification_observer.h" + +// Monitors network-related preferences for changes and applies them. +// The supplied PrefService must outlive this NetPrefObserver. +// Must be used only on the UI thread. +class NetPrefObserver : public NotificationObserver { + public: + explicit NetPrefObserver(PrefService* prefs); + ~NetPrefObserver(); + + // NotificationObserver + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + private: + BooleanPrefMember dns_prefetching_enabled_; + + DISALLOW_COPY_AND_ASSIGN(NetPrefObserver); +}; + +#endif // CHROME_BROWSER_NET_NET_PREF_OBSERVER_H_ + diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index e0087f8..acbf6f5 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -45,6 +45,7 @@ #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/gaia/token_service.h" +#include "chrome/browser/net/net_pref_observer.h" #include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/password_manager/password_store_default.h" @@ -667,6 +668,9 @@ PrefService* ProfileImpl::GetPrefs() { prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); // Make sure we save to disk that the session has opened. prefs_->ScheduleSavePersistentPrefs(); + + DCHECK(!net_pref_observer_.get()); + net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); } return prefs_.get(); diff --git a/chrome/browser/profile_impl.h b/chrome/browser/profile_impl.h index c7b60d0..25a38a9 100644 --- a/chrome/browser/profile_impl.h +++ b/chrome/browser/profile_impl.h @@ -26,6 +26,8 @@ class Preferences; } #endif +class NetPrefObserver; + // The default profile implementation. class ProfileImpl : public Profile, public SpellCheckHostObserver, @@ -167,6 +169,7 @@ class ProfileImpl : public Profile, scoped_refptr<TransportSecurityPersister> transport_security_persister_; scoped_ptr<PrefService> prefs_; + scoped_ptr<NetPrefObserver> net_pref_observer_; scoped_ptr<TemplateURLFetcher> template_url_fetcher_; scoped_ptr<TemplateURLModel> template_url_model_; scoped_ptr<BookmarkModel> bookmark_bar_model_; diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index c7d0fc75..a1c1937 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -28,7 +28,6 @@ #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_prefs.h" #include "chrome/browser/gears_integration.h" -#include "chrome/browser/net/predictor_api.h" #include "chrome/browser/options_util.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_service.h" @@ -506,7 +505,6 @@ void PrivacySection::ButtonPressed( "Options_DnsPrefetchCheckbox_Disable"), profile()->GetPrefs()); dns_prefetch_enabled_.SetValue(enabled); - chrome_browser_net::EnablePredictor(enabled); } else if (sender == enable_safe_browsing_checkbox_) { bool enabled = enable_safe_browsing_checkbox_->checked(); UserMetricsRecordAction(UserMetricsAction(enabled ? @@ -655,7 +653,6 @@ void PrivacySection::NotifyPrefChanged(const std::string* pref_name) { !dns_prefetch_enabled_.IsManaged()); bool enabled = dns_prefetch_enabled_.GetValue(); enable_dns_prefetching_checkbox_->SetChecked(enabled); - chrome_browser_net::EnablePredictor(enabled); } if (!pref_name || *pref_name == prefs::kSafeBrowsingEnabled) { enable_safe_browsing_checkbox_->SetEnabled(!safe_browsing_.IsManaged()); |