diff options
Diffstat (limited to 'chrome')
49 files changed, 211 insertions, 286 deletions
diff --git a/chrome/browser/background_mode_manager.cc b/chrome/browser/background_mode_manager.cc index 0882e4b..d675958 100644 --- a/chrome/browser/background_mode_manager.cc +++ b/chrome/browser/background_mode_manager.cc @@ -148,8 +148,7 @@ BackgroundModeManager::BackgroundModeManager(Profile* profile, NotificationService::AllSources()); // Listen for changes to the background mode preference. - pref_registrar_.Init(profile_->GetPrefs()); - pref_registrar_.Add(prefs::kBackgroundModeEnabled, this); + profile_->GetPrefs()->AddPrefObserver(prefs::kBackgroundModeEnabled, this); } BackgroundModeManager::~BackgroundModeManager() { @@ -158,6 +157,10 @@ BackgroundModeManager::~BackgroundModeManager() { // because in an actual running system we'd get an APP_TERMINATING // notification before being destroyed. EndBackgroundMode(); + // Manually remove our pref observer so we don't get notified for prefs + // changes (have to do it manually because we can't use the registrar for + // prefs notifications). + profile_->GetPrefs()->RemovePrefObserver(prefs::kBackgroundModeEnabled, this); } bool BackgroundModeManager::IsBackgroundModeEnabled() { diff --git a/chrome/browser/background_mode_manager.h b/chrome/browser/background_mode_manager.h index 52f37da..46e8847 100644 --- a/chrome/browser/background_mode_manager.h +++ b/chrome/browser/background_mode_manager.h @@ -8,7 +8,6 @@ #include "app/menus/simple_menu_model.h" #include "base/gtest_prod_util.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/status_icons/status_icon.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -143,9 +142,6 @@ class BackgroundModeManager // Reference to our status icon (if any) - owned by the StatusTray. StatusIcon* status_icon_; - // Ensure observed preferences are properly cleaned up. - PrefChangeRegistrar pref_registrar_; - DISALLOW_COPY_AND_ASSIGN(BackgroundModeManager); }; diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.h b/chrome/browser/cocoa/content_settings_dialog_controller.h index 8fe92da..d48b962 100644 --- a/chrome/browser/cocoa/content_settings_dialog_controller.h +++ b/chrome/browser/cocoa/content_settings_dialog_controller.h @@ -7,7 +7,6 @@ #import "base/cocoa_protocols_mac.h" #include "base/scoped_ptr.h" #include "chrome/common/content_settings_types.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_member.h" // Index of the "enabled" and "disabled" radio group settings in all tabs except @@ -51,7 +50,6 @@ class Profile; Profile* profile_; // weak IntegerPrefMember lastSelectedTab_; BooleanPrefMember clearSiteDataOnExit_; - PrefChangeRegistrar registrar_; scoped_ptr<ContentSettingsDialogControllerInternal::PrefObserverBridge> observer_; // Watches for pref changes. } diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.mm b/chrome/browser/cocoa/content_settings_dialog_controller.mm index 70287cc..0c71fd9 100644 --- a/chrome/browser/cocoa/content_settings_dialog_controller.mm +++ b/chrome/browser/cocoa/content_settings_dialog_controller.mm @@ -140,11 +140,11 @@ class PrefObserverDisabler { // Manually observe notifications for preferences that are grouped in // the HostContentSettingsMap or GeolocationContentSettingsMap. PrefService* prefs = profile_->GetPrefs(); - registrar_.Init(prefs); - registrar_.Add(prefs::kBlockThirdPartyCookies, observer_.get()); - registrar_.Add(prefs::kBlockNonsandboxedPlugins, observer_.get()); - registrar_.Add(prefs::kDefaultContentSettings, observer_.get()); - registrar_.Add(prefs::kGeolocationDefaultContentSetting, observer_.get()); + prefs->AddPrefObserver(prefs::kBlockThirdPartyCookies, observer_.get()); + prefs->AddPrefObserver(prefs::kBlockNonsandboxedPlugins, observer_.get()); + prefs->AddPrefObserver(prefs::kDefaultContentSettings, observer_.get()); + prefs->AddPrefObserver(prefs::kGeolocationDefaultContentSetting, + observer_.get()); // We don't need to observe changes in this value. lastSelectedTab_.Init(prefs::kContentSettingsWindowLastTabIndex, @@ -153,6 +153,20 @@ class PrefObserverDisabler { return self; } +- (void)dealloc { + if (profile_) { + PrefService* prefs = profile_->GetPrefs(); + prefs->RemovePrefObserver(prefs::kBlockThirdPartyCookies, observer_.get()); + prefs->RemovePrefObserver(prefs::kBlockNonsandboxedPlugins, + observer_.get()); + prefs->RemovePrefObserver(prefs::kDefaultContentSettings, observer_.get()); + prefs->RemovePrefObserver(prefs::kGeolocationDefaultContentSetting, + observer_.get()); + } + + [super dealloc]; +} + - (void)closeExceptionsSheet { NSWindow* attachedSheet = [[self window] attachedSheet]; if (attachedSheet) { diff --git a/chrome/browser/cocoa/extensions/extension_action_context_menu.mm b/chrome/browser/cocoa/extensions/extension_action_context_menu.mm index 81aa61e..10ea079 100644 --- a/chrome/browser/cocoa/extensions/extension_action_context_menu.mm +++ b/chrome/browser/cocoa/extensions/extension_action_context_menu.mm @@ -18,7 +18,6 @@ #include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/extension_tabs_module.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/extensions/extension.h" @@ -72,10 +71,14 @@ class DevmodeObserver : public NotificationObserver { DevmodeObserver(ExtensionActionContextMenu* menu, PrefService* service) : menu_(menu), pref_service_(service) { - registrar_.Init(pref_service_); - registrar_.Add(prefs::kExtensionsUIDeveloperMode, this); + pref_service_->AddPrefObserver(prefs::kExtensionsUIDeveloperMode, + this); + } + + ~DevmodeObserver() { + pref_service_->RemovePrefObserver(prefs::kExtensionsUIDeveloperMode, + this); } - virtual ~DevmodeObserver() {} void Observe(NotificationType type, const NotificationSource& source, @@ -89,7 +92,6 @@ class DevmodeObserver : public NotificationObserver { private: ExtensionActionContextMenu* menu_; PrefService* pref_service_; - PrefChangeRegistrar registrar_; }; } // namespace extension_action_context_menu diff --git a/chrome/browser/cocoa/preferences_window_controller.h b/chrome/browser/cocoa/preferences_window_controller.h index 54d4778..e7b8383 100644 --- a/chrome/browser/cocoa/preferences_window_controller.h +++ b/chrome/browser/cocoa/preferences_window_controller.h @@ -9,7 +9,6 @@ #include "chrome/browser/options_window.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/prefs/pref_set_observer.h" -#include "chrome/browser/prefs/pref_change_registrar.h" namespace PreferencesWindowControllerInternal { class PrefObserverBridge; @@ -46,7 +45,6 @@ class ProfileSyncService; ProfileSyncService* syncService_; scoped_ptr<PreferencesWindowControllerInternal::PrefObserverBridge> observer_; // Watches for pref changes. - PrefChangeRegistrar registrar_; // Manages pref change observer registration. scoped_nsobject<WindowSizeAutosaver> sizeSaver_; NSView* currentPrefsView_; // weak ref - current prefs page view. scoped_ptr<PreferencesWindowControllerInternal::ManagedPrefsBannerState> diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 0f11f63..c7c2b7b 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -330,6 +330,7 @@ CGFloat AutoSizeUnderTheHoodContent(NSView* view, // Record the user performed a certain action and save the preferences. - (void)recordUserAction:(const UserMetricsAction&) action; - (void)registerPrefObservers; +- (void)unregisterPrefObservers; // KVC setter methods. - (void)setNewTabPageIsHomePageIndex:(NSInteger)val; @@ -760,6 +761,7 @@ class ManagedPrefsBannerState : public policy::ManagedPrefsBannerBase { syncService_->RemoveObserver(observer_.get()); } [[NSNotificationCenter defaultCenter] removeObserver:self]; + [self unregisterPrefObservers]; [animation_ setDelegate:nil]; [animation_ stopAnimation]; [super dealloc]; @@ -779,8 +781,7 @@ class ManagedPrefsBannerState : public policy::ManagedPrefsBannerBase { if (!prefs_) return; // Basics panel - registrar_.Init(prefs_); - registrar_.Add(prefs::kURLsToRestoreOnStartup, observer_.get()); + prefs_->AddPrefObserver(prefs::kURLsToRestoreOnStartup, observer_.get()); restoreOnStartup_.Init(prefs::kRestoreOnStartup, prefs_, observer_.get()); newTabPageIsHomePage_.Init(prefs::kHomePageIsNewTabPage, prefs_, observer_.get()); @@ -822,6 +823,17 @@ class ManagedPrefsBannerState : public policy::ManagedPrefsBannerBase { lastSelectedPage_.Init(prefs::kOptionsWindowLastTabIndex, local, NULL); } +// Clean up what was registered in -registerPrefObservers. We only have to +// clean up the non-PrefMember registrations. +- (void)unregisterPrefObservers { + if (!prefs_) return; + + // Basics + prefs_->RemovePrefObserver(prefs::kURLsToRestoreOnStartup, observer_.get()); + + // Nothing to do for other panels... +} + // Called when the window wants to be closed. - (BOOL)windowShouldClose:(id)sender { // Stop any animation and clear the delegate to avoid stale pointers. diff --git a/chrome/browser/dom_ui/core_options_handler.cc b/chrome/browser/dom_ui/core_options_handler.cc index 849e768b..2739ebc 100644 --- a/chrome/browser/dom_ui/core_options_handler.cc +++ b/chrome/browser/dom_ui/core_options_handler.cc @@ -88,13 +88,6 @@ void CoreOptionsHandler::Uninitialize() { } } -DOMMessageHandler* CoreOptionsHandler::Attach(DOMUI* dom_ui) { - DOMMessageHandler* result = DOMMessageHandler::Attach(dom_ui); - DCHECK(dom_ui_); - registrar_.Init(dom_ui_->GetProfile()->GetPrefs()); - return result; -} - void CoreOptionsHandler::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { @@ -145,7 +138,9 @@ Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) { } void CoreOptionsHandler::ObservePref(const std::string& pref_name) { - registrar_.Add(pref_name.c_str(), this); + DCHECK(dom_ui_); + PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); + pref_service->AddPrefObserver(pref_name.c_str(), this); } void CoreOptionsHandler::SetPref(const std::string& pref_name, @@ -190,7 +185,9 @@ void CoreOptionsHandler::ProcessUserMetric(Value::ValueType pref_type, } void CoreOptionsHandler::StopObservingPref(const std::string& path) { - registrar_.Remove(path.c_str(), this); + DCHECK(dom_ui_); + PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); + pref_service->RemovePrefObserver(path.c_str(), this); } void CoreOptionsHandler::HandleFetchPrefs(const ListValue* args) { diff --git a/chrome/browser/dom_ui/core_options_handler.h b/chrome/browser/dom_ui/core_options_handler.h index fd94d10..748ab83 100644 --- a/chrome/browser/dom_ui/core_options_handler.h +++ b/chrome/browser/dom_ui/core_options_handler.h @@ -11,7 +11,6 @@ #include "base/values.h" #include "chrome/browser/dom_ui/options_ui.h" -#include "chrome/browser/prefs/pref_change_registrar.h" // Core options UI handler. // Handles resource and JS calls common to all options sub-pages. @@ -23,6 +22,7 @@ class CoreOptionsHandler : public OptionsPageUIHandler { virtual void GetLocalizedValues(DictionaryValue* localized_strings); virtual void Uninitialize(); + // NotificationObserver implementation. virtual void Observe(NotificationType type, const NotificationSource& source, @@ -30,7 +30,6 @@ class CoreOptionsHandler : public OptionsPageUIHandler { // DOMMessageHandler implementation. virtual void RegisterMessages(); - virtual DOMMessageHandler* Attach(DOMUI* dom_ui); protected: // Fetches a pref value of given |pref_name|. @@ -88,8 +87,6 @@ class CoreOptionsHandler : public OptionsPageUIHandler { void NotifyPrefChanged(const std::string* pref_name); - PrefChangeRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); }; diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc index 50964c9..169aea0 100644 --- a/chrome/browser/dom_ui/ntp_resource_cache.cc +++ b/chrome/browser/dom_ui/ntp_resource_cache.cc @@ -130,9 +130,15 @@ NTPResourceCache::NTPResourceCache(Profile* profile) : profile_(profile) { NotificationService::AllSources()); // Watch for pref changes that cause us to need to invalidate the HTML cache. - pref_change_registrar_.Init(profile_->GetPrefs()); - pref_change_registrar_.Add(prefs::kShowBookmarkBar, this); - pref_change_registrar_.Add(prefs::kNTPShownSections, this); + PrefService* pref_service = profile_->GetPrefs(); + pref_service->AddPrefObserver(prefs::kShowBookmarkBar, this); + pref_service->AddPrefObserver(prefs::kNTPShownSections, this); +} + +NTPResourceCache::~NTPResourceCache() { + PrefService* pref_service = profile_->GetPrefs(); + pref_service->RemovePrefObserver(prefs::kShowBookmarkBar, this); + pref_service->RemovePrefObserver(prefs::kNTPShownSections, this); } RefCountedBytes* NTPResourceCache::GetNewTabHTML(bool is_off_the_record) { diff --git a/chrome/browser/dom_ui/ntp_resource_cache.h b/chrome/browser/dom_ui/ntp_resource_cache.h index 3cdc3e5..f669325 100644 --- a/chrome/browser/dom_ui/ntp_resource_cache.h +++ b/chrome/browser/dom_ui/ntp_resource_cache.h @@ -10,7 +10,6 @@ #include "base/ref_counted.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" -#include "chrome/browser/prefs/pref_change_registrar.h" class Profile; class RefCountedBytes; @@ -20,7 +19,7 @@ class RefCountedBytes; class NTPResourceCache : public NotificationObserver { public: explicit NTPResourceCache(Profile* profile); - virtual ~NTPResourceCache() {} + virtual ~NTPResourceCache(); RefCountedBytes* GetNewTabHTML(bool is_off_the_record); RefCountedBytes* GetNewTabCSS(bool is_off_the_record); @@ -44,7 +43,6 @@ class NTPResourceCache : public NotificationObserver { scoped_refptr<RefCountedBytes> new_tab_css_; NotificationRegistrar registrar_; - PrefChangeRegistrar pref_change_registrar_; DISALLOW_COPY_AND_ASSIGN(NTPResourceCache); }; diff --git a/chrome/browser/dom_ui/shown_sections_handler.cc b/chrome/browser/dom_ui/shown_sections_handler.cc index 94a49a4..4af2d0b 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.cc +++ b/chrome/browser/dom_ui/shown_sections_handler.cc @@ -50,8 +50,11 @@ int ShownSectionsHandler::GetShownSections(PrefService* prefs) { ShownSectionsHandler::ShownSectionsHandler(PrefService* pref_service) : pref_service_(pref_service) { - registrar_.Init(pref_service); - registrar_.Add(prefs::kNTPShownSections, this); + pref_service_->AddPrefObserver(prefs::kNTPShownSections, this); +} + +ShownSectionsHandler::~ShownSectionsHandler() { + pref_service_->RemovePrefObserver(prefs::kNTPShownSections, this); } void ShownSectionsHandler::RegisterMessages() { diff --git a/chrome/browser/dom_ui/shown_sections_handler.h b/chrome/browser/dom_ui/shown_sections_handler.h index 39428bb..8821d640 100644 --- a/chrome/browser/dom_ui/shown_sections_handler.h +++ b/chrome/browser/dom_ui/shown_sections_handler.h @@ -8,7 +8,6 @@ #include "chrome/browser/dom_ui/dom_ui.h" #include "chrome/common/notification_observer.h" -#include "chrome/browser/prefs/pref_change_registrar.h" class DOMUI; class Value; @@ -29,7 +28,7 @@ class ShownSectionsHandler : public DOMMessageHandler, public NotificationObserver { public: explicit ShownSectionsHandler(PrefService* pref_service); - virtual ~ShownSectionsHandler() {} + virtual ~ShownSectionsHandler(); // Helper to get the current shown sections. static int GetShownSections(PrefService* pref_service); @@ -56,7 +55,6 @@ class ShownSectionsHandler : public DOMMessageHandler, private: PrefService* pref_service_; - PrefChangeRegistrar registrar_; DISALLOW_COPY_AND_ASSIGN(ShownSectionsHandler); }; diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 512772d..79810c0 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -548,9 +548,8 @@ ExtensionsService::ExtensionsService(Profile* profile, NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, NotificationService::AllSources()); - pref_change_registrar_.Init(prefs); - pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); - pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); + prefs->AddPrefObserver(prefs::kExtensionInstallAllowList, this); + prefs->AddPrefObserver(prefs::kExtensionInstallDenyList, this); // Set up the ExtensionUpdater if (autoupdate_enabled) { @@ -1189,7 +1188,11 @@ void ExtensionsService::UpdateExtensionBlacklist( } void ExtensionsService::DestroyingProfile() { - pref_change_registrar_.RemoveAll(); + profile_->GetPrefs()->RemovePrefObserver( + prefs::kExtensionInstallAllowList, this); + profile_->GetPrefs()->RemovePrefObserver( + prefs::kExtensionInstallDenyList, this); + profile_ = NULL; } diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h index 1c50434..211bc8de 100644 --- a/chrome/browser/extensions/extensions_service.h +++ b/chrome/browser/extensions/extensions_service.h @@ -28,7 +28,6 @@ #include "chrome/browser/extensions/extensions_quota_service.h" #include "chrome/browser/extensions/external_extension_provider.h" #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/extensions/extension.h" @@ -485,7 +484,6 @@ class ExtensionsService OrphanedDevTools orphaned_dev_tools_; NotificationRegistrar registrar_; - PrefChangeRegistrar pref_change_registrar_; // Keeps track of menu items added by extensions. ExtensionMenuManager menu_manager_; diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 60a6910..281e9cb 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -2476,7 +2476,8 @@ TEST(ExtensionsServiceTestSimple, Enabledness) { // By default, we are enabled. command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); - service = profile->CreateExtensionsService(command_line.get(), install_dir); + service = new ExtensionsService(profile.get(), command_line.get(), + profile->GetPrefs(), install_dir, false); EXPECT_TRUE(service->extensions_enabled()); service->Init(); loop.RunAllPending(); @@ -2486,7 +2487,8 @@ TEST(ExtensionsServiceTestSimple, Enabledness) { recorder.set_ready(false); profile.reset(new TestingProfile()); command_line->AppendSwitch(switches::kDisableExtensions); - service = profile->CreateExtensionsService(command_line.get(), install_dir); + service = new ExtensionsService(profile.get(), command_line.get(), + profile->GetPrefs(), install_dir, false); EXPECT_FALSE(service->extensions_enabled()); service->Init(); loop.RunAllPending(); @@ -2495,7 +2497,8 @@ TEST(ExtensionsServiceTestSimple, Enabledness) { recorder.set_ready(false); profile.reset(new TestingProfile()); profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); - service = profile->CreateExtensionsService(command_line.get(), install_dir); + service = new ExtensionsService(profile.get(), command_line.get(), + profile->GetPrefs(), install_dir, false); EXPECT_FALSE(service->extensions_enabled()); service->Init(); loop.RunAllPending(); @@ -2505,7 +2508,8 @@ TEST(ExtensionsServiceTestSimple, Enabledness) { profile.reset(new TestingProfile()); profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true); command_line.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); - service = profile->CreateExtensionsService(command_line.get(), install_dir); + service = new ExtensionsService(profile.get(), command_line.get(), + profile->GetPrefs(), install_dir, false); EXPECT_FALSE(service->extensions_enabled()); service->Init(); loop.RunAllPending(); diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc index 5bcd8a3..7e5a2c2 100644 --- a/chrome/browser/gtk/gtk_theme_provider.cc +++ b/chrome/browser/gtk/gtk_theme_provider.cc @@ -258,6 +258,7 @@ GtkThemeProvider::GtkThemeProvider() } GtkThemeProvider::~GtkThemeProvider() { + profile()->GetPrefs()->RemovePrefObserver(prefs::kUsesSystemTheme, this); gtk_widget_destroy(fake_window_); gtk_widget_destroy(fake_frame_); fake_label_.Destroy(); @@ -272,8 +273,7 @@ GtkThemeProvider::~GtkThemeProvider() { } void GtkThemeProvider::Init(Profile* profile) { - registrar_.Init(profile->GetPrefs()); - registrar_.Add(prefs::kUsesSystemTheme, this); + profile->GetPrefs()->AddPrefObserver(prefs::kUsesSystemTheme, this); use_gtk_ = profile->GetPrefs()->GetBoolean(prefs::kUsesSystemTheme); BrowserThemeProvider::Init(profile); diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h index 2ecef7a..33b1ec2 100644 --- a/chrome/browser/gtk/gtk_theme_provider.h +++ b/chrome/browser/gtk/gtk_theme_provider.h @@ -12,7 +12,6 @@ #include "app/gtk_integers.h" #include "app/gtk_signal.h" #include "base/scoped_ptr.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/gtk/owned_widget_gtk.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/common/notification_observer.h" @@ -276,8 +275,6 @@ class GtkThemeProvider : public BrowserThemeProvider, PerDisplaySurfaceMap per_display_surfaces_; PerDisplaySurfaceMap per_display_unthemed_surfaces_; - PrefChangeRegistrar registrar_; - // This is a dummy widget that only exists so we have something to pass to // gtk_widget_render_icon(). static GtkWidget* icon_widget_; diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc index 734ee8c..fb4db2b 100644 --- a/chrome/browser/gtk/options/general_page_gtk.cc +++ b/chrome/browser/gtk/options/general_page_gtk.cc @@ -95,9 +95,8 @@ GeneralPageGtk::GeneralPageGtk(Profile* profile) InitDefaultBrowserGroup(), false); #endif - registrar_.Init(profile->GetPrefs()); - registrar_.Add(prefs::kRestoreOnStartup, this); - registrar_.Add(prefs::kURLsToRestoreOnStartup, this); + profile->GetPrefs()->AddPrefObserver(prefs::kRestoreOnStartup, this); + profile->GetPrefs()->AddPrefObserver(prefs::kURLsToRestoreOnStartup, this); new_tab_page_is_home_page_.Init(prefs::kHomePageIsNewTabPage, profile->GetPrefs(), this); @@ -109,6 +108,10 @@ GeneralPageGtk::GeneralPageGtk(Profile* profile) } GeneralPageGtk::~GeneralPageGtk() { + profile()->GetPrefs()->RemovePrefObserver(prefs::kRestoreOnStartup, this); + profile()->GetPrefs()->RemovePrefObserver( + prefs::kURLsToRestoreOnStartup, this); + if (template_url_model_) template_url_model_->RemoveObserver(this); diff --git a/chrome/browser/gtk/options/general_page_gtk.h b/chrome/browser/gtk/options/general_page_gtk.h index 143f447..3a072ac 100644 --- a/chrome/browser/gtk/options/general_page_gtk.h +++ b/chrome/browser/gtk/options/general_page_gtk.h @@ -14,7 +14,6 @@ #include "chrome/browser/gtk/gtk_tree.h" #include "chrome/browser/gtk/options/managed_prefs_banner_gtk.h" #include "chrome/browser/options_page_base.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/search_engines/template_url_model_observer.h" #include "chrome/browser/shell_integration.h" @@ -161,8 +160,6 @@ class GeneralPageGtk : public OptionsPageBase, // Tracks managed preference warning banner state. ManagedPrefsBannerGtk managed_prefs_banner_; - PrefChangeRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(GeneralPageGtk); }; diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index 4ac9f405..cffe57e 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -230,11 +230,10 @@ HostContentSettingsMap::HostContentSettingsMap(Profile* profile) // Read exceptions. ReadExceptions(false); - pref_change_registrar_.Init(prefs); - pref_change_registrar_.Add(prefs::kDefaultContentSettings, this); - pref_change_registrar_.Add(prefs::kContentSettingsPatterns, this); - pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); - pref_change_registrar_.Add(prefs::kBlockNonsandboxedPlugins, this); + prefs->AddPrefObserver(prefs::kDefaultContentSettings, this); + prefs->AddPrefObserver(prefs::kContentSettingsPatterns, this); + prefs->AddPrefObserver(prefs::kBlockThirdPartyCookies, this); + prefs->AddPrefObserver(prefs::kBlockNonsandboxedPlugins, this); notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, Source<Profile>(profile_)); } @@ -910,7 +909,11 @@ void HostContentSettingsMap::UnregisterObservers() { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); if (!profile_) return; - pref_change_registrar_.RemoveAll(); + PrefService* prefs = profile_->GetPrefs(); + prefs->RemovePrefObserver(prefs::kDefaultContentSettings, this); + prefs->RemovePrefObserver(prefs::kContentSettingsPatterns, this); + prefs->RemovePrefObserver(prefs::kBlockThirdPartyCookies, this); + prefs->RemovePrefObserver(prefs::kBlockNonsandboxedPlugins, this); notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, Source<Profile>(profile_)); profile_ = NULL; diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h index 7afb808..ff9c8f0 100644 --- a/chrome/browser/host_content_settings_map.h +++ b/chrome/browser/host_content_settings_map.h @@ -18,7 +18,6 @@ #include "base/lock.h" #include "base/ref_counted.h" #include "chrome/browser/chrome_thread.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/content_settings.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -286,7 +285,6 @@ class HostContentSettingsMap Profile* profile_; NotificationRegistrar notification_registrar_; - PrefChangeRegistrar pref_change_registrar_; // Copies of the pref data, so that we can read it on the IO thread. ContentSettings default_content_settings_; diff --git a/chrome/browser/host_zoom_map.cc b/chrome/browser/host_zoom_map.cc index cb67a04..0c1d96a 100644 --- a/chrome/browser/host_zoom_map.cc +++ b/chrome/browser/host_zoom_map.cc @@ -27,10 +27,8 @@ HostZoomMap::HostZoomMap(Profile* profile) // Don't observe pref changes (e.g. from sync) in Incognito; once we create // the incognito window it should have no further connection to the main // profile/prefs. - if (!profile_->IsOffTheRecord()) { - pref_change_registrar_.Init(profile_->GetPrefs()); - pref_change_registrar_.Add(prefs::kPerHostZoomLevels, this); - } + if (!profile_->IsOffTheRecord()) + profile_->GetPrefs()->AddPrefObserver(prefs::kPerHostZoomLevels, this); } void HostZoomMap::Load() { @@ -130,7 +128,7 @@ void HostZoomMap::Shutdown() { NotificationType::PROFILE_DESTROYED, Source<Profile>(profile_)); if (!profile_->IsOffTheRecord()) - pref_change_registrar_.RemoveAll(); + profile_->GetPrefs()->RemovePrefObserver(prefs::kPerHostZoomLevels, this); profile_ = NULL; } diff --git a/chrome/browser/host_zoom_map.h b/chrome/browser/host_zoom_map.h index 3142024..caa60b7 100644 --- a/chrome/browser/host_zoom_map.h +++ b/chrome/browser/host_zoom_map.h @@ -15,7 +15,6 @@ #include "base/basictypes.h" #include "base/lock.h" #include "base/ref_counted.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -84,7 +83,6 @@ class HostZoomMap : public NotificationObserver, bool updating_preferences_; NotificationRegistrar registrar_; - PrefChangeRegistrar pref_change_registrar_; DISALLOW_COPY_AND_ASSIGN(HostZoomMap); }; diff --git a/chrome/browser/host_zoom_map_unittest.cc b/chrome/browser/host_zoom_map_unittest.cc index 5d206e1..e6b1f72 100644 --- a/chrome/browser/host_zoom_map_unittest.cc +++ b/chrome/browser/host_zoom_map_unittest.cc @@ -70,9 +70,7 @@ TEST_F(HostZoomMapTest, Load) { TEST_F(HostZoomMapTest, SetZoomLevel) { scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_)); - PrefChangeRegistrar registrar; - registrar.Init(prefs_); - registrar.Add(prefs::kPerHostZoomLevels, &pref_observer_); + prefs_->AddPrefObserver(prefs::kPerHostZoomLevels, &pref_observer_); SetPrefObserverExpectation(); map->SetZoomLevel(url_, kZoomLevel); EXPECT_EQ(kZoomLevel, map->GetZoomLevel(url_)); @@ -86,19 +84,19 @@ TEST_F(HostZoomMapTest, SetZoomLevel) { map->SetZoomLevel(url_, 0); EXPECT_EQ(0, map->GetZoomLevel(url_)); EXPECT_FALSE(dict->HasKey(host_)); + prefs_->RemovePrefObserver(prefs::kPerHostZoomLevels, &pref_observer_); } TEST_F(HostZoomMapTest, ResetToDefaults) { scoped_refptr<HostZoomMap> map(new HostZoomMap(&profile_)); map->SetZoomLevel(url_, kZoomLevel); - PrefChangeRegistrar registrar; - registrar.Init(prefs_); - registrar.Add(prefs::kPerHostZoomLevels, &pref_observer_); + prefs_->AddPrefObserver(prefs::kPerHostZoomLevels, &pref_observer_); SetPrefObserverExpectation(); map->ResetToDefaults(); EXPECT_EQ(0, map->GetZoomLevel(url_)); EXPECT_EQ(NULL, prefs_->GetDictionary(prefs::kPerHostZoomLevels)); + prefs_->RemovePrefObserver(prefs::kPerHostZoomLevels, &pref_observer_); } TEST_F(HostZoomMapTest, ReloadOnPrefChange) { diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index caefe49..f14958f 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -526,7 +526,8 @@ ChromeURLRequestContext* FactoryForMedia::Create() { ChromeURLRequestContextGetter::ChromeURLRequestContextGetter( Profile* profile, ChromeURLRequestContextFactory* factory) - : factory_(factory), + : prefs_(NULL), + factory_(factory), url_request_context_(NULL) { DCHECK(factory); @@ -538,7 +539,7 @@ ChromeURLRequestContextGetter::ChromeURLRequestContextGetter( ChromeURLRequestContextGetter::~ChromeURLRequestContextGetter() { CheckCurrentlyOnIOThread(); - DCHECK(registrar_.IsEmpty()) << "Probably didn't call CleanupOnUIThread"; + DCHECK(!prefs_) << "Probably didn't call CleanupOnUIThread"; // Either we already transformed the factory into a URLRequestContext, or // we still have a pending factory. @@ -651,8 +652,13 @@ ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( void ChromeURLRequestContextGetter::CleanupOnUIThread() { CheckCurrentlyOnMainThread(); - // Unregister for pref notifications. - registrar_.RemoveAll(); + + if (prefs_) { + // Unregister for pref notifications. + prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this); + prefs_->RemovePrefObserver(prefs::kDefaultCharset, this); + prefs_ = NULL; + } } void ChromeURLRequestContextGetter::OnNewExtensions( @@ -704,9 +710,10 @@ void ChromeURLRequestContextGetter::Observe( void ChromeURLRequestContextGetter::RegisterPrefsObserver(Profile* profile) { CheckCurrentlyOnMainThread(); - registrar_.Init(profile->GetPrefs()); - registrar_.Add(prefs::kAcceptLanguages, this); - registrar_.Add(prefs::kDefaultCharset, this); + prefs_ = profile->GetPrefs(); + + prefs_->AddPrefObserver(prefs::kAcceptLanguages, this); + prefs_->AddPrefObserver(prefs::kDefaultCharset, this); } // static diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index 52dc3f7..97997e3 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -18,7 +18,6 @@ #include "chrome/browser/host_zoom_map.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/net/chrome_cookie_policy.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/net/url_request_context_getter.h" @@ -368,7 +367,8 @@ class ChromeURLRequestContextGetter : public URLRequestContextGetter, void GetCookieStoreAsyncHelper(base::WaitableEvent* completion, net::CookieStore** result); - PrefChangeRegistrar registrar_; + // Access only from the UI thread. + PrefService* prefs_; // Deferred logic for creating a ChromeURLRequestContext. // Access only from the IO thread. diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 26afbed..a467697 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -209,7 +209,6 @@ DesktopNotificationService::DesktopNotificationService(Profile* profile, NotificationUIManager* ui_manager) : profile_(profile), ui_manager_(ui_manager) { - registrar_.Init(profile_->GetPrefs()); InitPrefs(); StartObserving(); } @@ -254,15 +253,21 @@ void DesktopNotificationService::InitPrefs() { void DesktopNotificationService::StartObserving() { if (!profile_->IsOffTheRecord()) { - registrar_.Add(prefs::kDesktopNotificationDefaultContentSetting, this); - registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this); - registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this); + PrefService* prefs = profile_->GetPrefs(); + prefs->AddPrefObserver(prefs::kDesktopNotificationDefaultContentSetting, + this); + prefs->AddPrefObserver(prefs::kDesktopNotificationAllowedOrigins, this); + prefs->AddPrefObserver(prefs::kDesktopNotificationDeniedOrigins, this); } } void DesktopNotificationService::StopObserving() { if (!profile_->IsOffTheRecord()) { - registrar_.RemoveAll(); + PrefService* prefs = profile_->GetPrefs(); + prefs->RemovePrefObserver(prefs::kDesktopNotificationDefaultContentSetting, + this); + prefs->RemovePrefObserver(prefs::kDesktopNotificationAllowedOrigins, this); + prefs->RemovePrefObserver(prefs::kDesktopNotificationDeniedOrigins, this); } } diff --git a/chrome/browser/notifications/desktop_notification_service.h b/chrome/browser/notifications/desktop_notification_service.h index 2282cd2..d1a4ccc 100644 --- a/chrome/browser/notifications/desktop_notification_service.h +++ b/chrome/browser/notifications/desktop_notification_service.h @@ -11,7 +11,6 @@ #include "base/basictypes.h" #include "base/string16.h" #include "chrome/browser/notifications/notification.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/content_settings.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -137,8 +136,6 @@ class DesktopNotificationService : public NotificationObserver { // UI for desktop toasts. NotificationUIManager* ui_manager_; - PrefChangeRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); }; diff --git a/chrome/browser/prefs/pref_change_registrar.cc b/chrome/browser/prefs/pref_change_registrar.cc index 05372b1..dc8bb97 100644 --- a/chrome/browser/prefs/pref_change_registrar.cc +++ b/chrome/browser/prefs/pref_change_registrar.cc @@ -9,11 +9,16 @@ PrefChangeRegistrar::PrefChangeRegistrar() : service_(NULL) {} PrefChangeRegistrar::~PrefChangeRegistrar() { - RemoveAll(); + if (service_) { + for (std::set<ObserverRegistration>::const_iterator it = observers_.begin(); + it != observers_.end(); ++it) { + service_->RemovePrefObserver(it->first.c_str(), it->second); + } + } } void PrefChangeRegistrar::Init(PrefService* service) { - DCHECK(IsEmpty() || service_ == service); + DCHECK(!service_); service_ = service; } @@ -46,17 +51,3 @@ void PrefChangeRegistrar::Remove(const char* path, NotificationObserver* obs) { service_->RemovePrefObserver(it->first.c_str(), it->second); observers_.erase(it); } - -void PrefChangeRegistrar::RemoveAll() { - if (service_) { - for (std::set<ObserverRegistration>::const_iterator it = observers_.begin(); - it != observers_.end(); ++it) { - service_->RemovePrefObserver(it->first.c_str(), it->second); - } - observers_.clear(); - } -} - -bool PrefChangeRegistrar::IsEmpty() const { - return observers_.empty(); -} diff --git a/chrome/browser/prefs/pref_change_registrar.h b/chrome/browser/prefs/pref_change_registrar.h index 773c556..cd8f5eb 100644 --- a/chrome/browser/prefs/pref_change_registrar.h +++ b/chrome/browser/prefs/pref_change_registrar.h @@ -23,8 +23,7 @@ class PrefChangeRegistrar { PrefChangeRegistrar(); virtual ~PrefChangeRegistrar(); - // Must be called before adding or removing observers. Can be called more - // than once as long as the value of |service| doesn't change. + // Must be called before adding or removing observers. void Init(PrefService* service); // Adds an pref observer for the specified pref |path| and |obs| observer @@ -39,12 +38,6 @@ class PrefChangeRegistrar { void Remove(const char* path, NotificationObserver* obs); - // Removes all observers that have been previously added with a call to Add. - void RemoveAll(); - - // Returns true if no pref observers are registered. - bool IsEmpty() const; - private: typedef std::pair<std::string, NotificationObserver*> ObserverRegistration; diff --git a/chrome/browser/prefs/pref_change_registrar_unittest.cc b/chrome/browser/prefs/pref_change_registrar_unittest.cc index 8096ee6..4d7f747 100644 --- a/chrome/browser/prefs/pref_change_registrar_unittest.cc +++ b/chrome/browser/prefs/pref_change_registrar_unittest.cc @@ -63,7 +63,6 @@ TEST_F(PrefChangeRegistrarTest, AddAndRemove) { AddPrefObserver(Eq(std::string("test.pref.2")), observer())); registrar.Add("test.pref.1", observer()); registrar.Add("test.pref.2", observer()); - EXPECT_FALSE(registrar.IsEmpty()); // Test removing. Mock::VerifyAndClearExpectations(service()); @@ -73,11 +72,6 @@ TEST_F(PrefChangeRegistrarTest, AddAndRemove) { RemovePrefObserver(Eq(std::string("test.pref.2")), observer())); registrar.Remove("test.pref.1", observer()); registrar.Remove("test.pref.2", observer()); - EXPECT_TRUE(registrar.IsEmpty()); - - // Explicitly check the expectations now to make sure that the Removes - // worked (rather than the registrar destructor doing the work). - Mock::VerifyAndClearExpectations(service()); } TEST_F(PrefChangeRegistrarTest, AutoRemove) { @@ -89,33 +83,8 @@ TEST_F(PrefChangeRegistrarTest, AutoRemove) { AddPrefObserver(Eq(std::string("test.pref.1")), observer())); registrar.Add("test.pref.1", observer()); Mock::VerifyAndClearExpectations(service()); - EXPECT_FALSE(registrar.IsEmpty()); // Test auto-removing. EXPECT_CALL(*service(), RemovePrefObserver(Eq(std::string("test.pref.1")), observer())); } - -TEST_F(PrefChangeRegistrarTest, RemoveAll) { - PrefChangeRegistrar registrar; - registrar.Init(service()); - - EXPECT_CALL(*service(), - AddPrefObserver(Eq(std::string("test.pref.1")), observer())); - EXPECT_CALL(*service(), - AddPrefObserver(Eq(std::string("test.pref.2")), observer())); - registrar.Add("test.pref.1", observer()); - registrar.Add("test.pref.2", observer()); - Mock::VerifyAndClearExpectations(service()); - - EXPECT_CALL(*service(), - RemovePrefObserver(Eq(std::string("test.pref.1")), observer())); - EXPECT_CALL(*service(), - RemovePrefObserver(Eq(std::string("test.pref.2")), observer())); - registrar.RemoveAll(); - EXPECT_TRUE(registrar.IsEmpty()); - - // Explicitly check the expectations now to make sure that the RemoveAll - // worked (rather than the registrar destructor doing the work). - Mock::VerifyAndClearExpectations(service()); -} diff --git a/chrome/browser/prefs/pref_service.h b/chrome/browser/prefs/pref_service.h index 5cedd52..450c6c1 100644 --- a/chrome/browser/prefs/pref_service.h +++ b/chrome/browser/prefs/pref_service.h @@ -19,14 +19,9 @@ class FilePath; class NotificationObserver; -class PrefChangeObserver; class PrefNotifier; class Profile; -namespace subtle { - class PrefMemberBase; -}; - class PrefService : public NonThreadSafe { public: // A helper class to store all the information associated with a preference. @@ -166,6 +161,11 @@ class PrefService : public NonThreadSafe { const DictionaryValue* GetDictionary(const char* path) const; const ListValue* GetList(const char* path) const; + // If the pref at the given path changes, we call the observer's Observe + // method with NOTIFY_PREF_CHANGED. + virtual void AddPrefObserver(const char* path, NotificationObserver* obs); + virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); + // Removes a user pref and restores the pref to its default value. void ClearPref(const char* path); @@ -229,22 +229,6 @@ class PrefService : public NonThreadSafe { scoped_ptr<PrefNotifier> pref_notifier_; private: - // Registration of pref change observers must be done using the - // PrefChangeRegistrar, which is declared as a friend here to grant it - // access to the otherwise protected members Add/RemovePrefObserver. - // PrefMember registers for preferences changes notification directly to - // avoid the storage overhead of the registrar, so its base class must be - // declared as a friend, too. - friend class PrefChangeRegistrar; - friend class subtle::PrefMemberBase; - - // If the pref at the given path changes, we call the observer's Observe - // method with NOTIFY_PREF_CHANGED. Note that observers should not call - // these methods directly but rather use a PrefChangeRegistrar to make sure - // the observer gets cleaned up properly. - virtual void AddPrefObserver(const char* path, NotificationObserver* obs); - virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); - // Add a preference to the PreferenceMap. If the pref already exists, return // false. This method takes ownership of |default_value|. void RegisterPreference(const char* path, Value* default_value); diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc index d62679d..461f108 100644 --- a/chrome/browser/prefs/pref_service_unittest.cc +++ b/chrome/browser/prefs/pref_service_unittest.cc @@ -8,7 +8,6 @@ #include "base/scoped_ptr.h" #include "base/values.h" #include "chrome/browser/prefs/dummy_pref_store.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_value_store.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/notification_observer_mock.h" @@ -95,10 +94,7 @@ TEST(PrefServiceTest, NoObserverFire) { const std::string new_pref_value("http://www.google.com/"); TestPrefObserver obs(&prefs, pref_name, new_pref_value); - - PrefChangeRegistrar registrar; - registrar.Init(&prefs); - registrar.Add(pref_name, &obs); + prefs.AddPrefObserver(pref_name, &obs); // This should fire the checks in TestPrefObserver::Observe. prefs.SetString(pref_name, new_pref_value); @@ -120,6 +116,9 @@ TEST(PrefServiceTest, NoObserverFire) { obs.Reset(""); prefs.ClearPref(pref_name); EXPECT_FALSE(obs.observer_fired()); + + // Ok, clean up. + prefs.RemovePrefObserver(pref_name, &obs); } TEST(PrefServiceTest, HasPrefPath) { @@ -149,9 +148,7 @@ TEST(PrefServiceTest, Observers) { const std::string new_pref_value("http://www.google.com/"); TestPrefObserver obs(&prefs, pref_name, new_pref_value); - PrefChangeRegistrar registrar; - registrar.Init(&prefs); - registrar.Add(pref_name, &obs); + prefs.AddPrefObserver(pref_name, &obs); // This should fire the checks in TestPrefObserver::Observe. prefs.SetString(pref_name, new_pref_value); @@ -162,20 +159,23 @@ TEST(PrefServiceTest, Observers) { const std::string new_pref_value2("http://www.youtube.com/"); obs.Reset(new_pref_value2); TestPrefObserver obs2(&prefs, pref_name, new_pref_value2); - registrar.Add(pref_name, &obs2); + prefs.AddPrefObserver(pref_name, &obs2); // This should fire the checks in obs and obs2. prefs.SetString(pref_name, new_pref_value2); EXPECT_TRUE(obs.observer_fired()); EXPECT_TRUE(obs2.observer_fired()); // Make sure obs2 still works after removing obs. - registrar.Remove(pref_name, &obs); + prefs.RemovePrefObserver(pref_name, &obs); obs.Reset(""); obs2.Reset(new_pref_value); // This should only fire the observer in obs2. prefs.SetString(pref_name, new_pref_value); EXPECT_FALSE(obs.observer_fired()); EXPECT_TRUE(obs2.observer_fired()); + + // Ok, clean up. + prefs.RemovePrefObserver(pref_name, &obs2); } class PrefServiceSetValueTest : public testing::Test { @@ -211,11 +211,7 @@ TEST_F(PrefServiceSetValueTest, SetStringValue) { const char default_string[] = "default"; scoped_ptr<Value> default_value(Value::CreateStringValue(default_string)); prefs_.RegisterStringPref(name_, default_string); - - PrefChangeRegistrar registrar; - registrar.Init(&prefs_); - registrar.Add(name_, &observer_); - + prefs_.AddPrefObserver(name_, &observer_); // Changing the controlling store from default to user triggers notification. SetExpectPrefChanged(); prefs_.Set(name_, *default_value); @@ -229,13 +225,13 @@ TEST_F(PrefServiceSetValueTest, SetStringValue) { SetExpectPrefChanged(); prefs_.Set(name_, *new_value); EXPECT_EQ(value_, prefs_.GetString(name_)); + + prefs_.RemovePrefObserver(name_, &observer_); } TEST_F(PrefServiceSetValueTest, SetDictionaryValue) { prefs_.RegisterDictionaryPref(name_); - PrefChangeRegistrar registrar; - registrar.Init(&prefs_); - registrar.Add(name_, &observer_); + prefs_.AddPrefObserver(name_, &observer_); // Dictionary values are special: setting one to NULL is the same as clearing // the user value, allowing the NULL default to take (or keep) control. @@ -263,13 +259,13 @@ TEST_F(PrefServiceSetValueTest, SetDictionaryValue) { Mock::VerifyAndClearExpectations(&observer_); dict = prefs_.GetMutableDictionary(name_); EXPECT_EQ(0U, dict->size()); + + prefs_.RemovePrefObserver(name_, &observer_); } TEST_F(PrefServiceSetValueTest, SetListValue) { prefs_.RegisterListPref(name_); - PrefChangeRegistrar registrar; - registrar.Init(&prefs_); - registrar.Add(name_, &observer_); + prefs_.AddPrefObserver(name_, &observer_); // List values are special: setting one to NULL is the same as clearing the // user value, allowing the NULL default to take (or keep) control. @@ -297,4 +293,6 @@ TEST_F(PrefServiceSetValueTest, SetListValue) { Mock::VerifyAndClearExpectations(&observer_); list = prefs_.GetMutableList(name_); EXPECT_EQ(0U, list->GetSize()); + + prefs_.RemovePrefObserver(name_, &observer_); } diff --git a/chrome/browser/prefs/pref_set_observer.cc b/chrome/browser/prefs/pref_set_observer.cc index dd067d3..a4ecf6f 100644 --- a/chrome/browser/prefs/pref_set_observer.cc +++ b/chrome/browser/prefs/pref_set_observer.cc @@ -11,19 +11,23 @@ PrefSetObserver::PrefSetObserver(PrefService* pref_service, NotificationObserver* observer) : pref_service_(pref_service), observer_(observer) { - registrar_.Init(pref_service); +} + +PrefSetObserver::~PrefSetObserver() { + for (PrefSet::const_iterator i(prefs_.begin()); i != prefs_.end(); ++i) + pref_service_->RemovePrefObserver(i->c_str(), this); } void PrefSetObserver::AddPref(const std::string& pref) { if (!prefs_.count(pref) && pref_service_->FindPreference(pref.c_str())) { prefs_.insert(pref); - registrar_.Add(pref.c_str(), this); + pref_service_->AddPrefObserver(pref.c_str(), this); } } void PrefSetObserver::RemovePref(const std::string& pref) { if (prefs_.erase(pref)) - registrar_.Remove(pref.c_str(), this); + pref_service_->RemovePrefObserver(pref.c_str(), this); } bool PrefSetObserver::IsObserved(const std::string& pref) { diff --git a/chrome/browser/prefs/pref_set_observer.h b/chrome/browser/prefs/pref_set_observer.h index ff350df..beaec01 100644 --- a/chrome/browser/prefs/pref_set_observer.h +++ b/chrome/browser/prefs/pref_set_observer.h @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/notification_observer.h" // Observes the state of a set of preferences and allows to query their combined @@ -20,7 +19,7 @@ class PrefSetObserver : public NotificationObserver { // Initialize with an empty set of preferences. PrefSetObserver(PrefService* pref_service, NotificationObserver* observer); - virtual ~PrefSetObserver() {} + virtual ~PrefSetObserver(); // Add a |pref| to the set of preferences to observe. void AddPref(const std::string& pref); @@ -52,7 +51,6 @@ class PrefSetObserver : public NotificationObserver { PrefSet prefs_; PrefService* pref_service_; - PrefChangeRegistrar registrar_; NotificationObserver* observer_; DISALLOW_COPY_AND_ASSIGN(PrefSetObserver); diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc index ad2b405..fb5f501 100644 --- a/chrome/browser/profile_impl.cc +++ b/chrome/browser/profile_impl.cc @@ -290,10 +290,9 @@ ProfileImpl::ProfileImpl(const FilePath& path) &ProfileImpl::EnsureSessionServiceCreated); PrefService* prefs = GetPrefs(); - pref_change_registrar_.Init(prefs); - pref_change_registrar_.Add(prefs::kSpellCheckDictionary, this); - pref_change_registrar_.Add(prefs::kEnableSpellCheck, this); - pref_change_registrar_.Add(prefs::kEnableAutoSpellCorrect, this); + prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this); + prefs->AddPrefObserver(prefs::kEnableSpellCheck, this); + prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this); #if defined(OS_MACOSX) // If the profile directory doesn't already have a cache directory and it @@ -500,8 +499,11 @@ ProfileImpl::~ProfileImpl() { // The theme provider provides bitmaps to whoever wants them. theme_provider_.reset(); - // Remove pref observers - pref_change_registrar_.RemoveAll(); + // Remove pref observers. + PrefService* prefs = GetPrefs(); + prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this); + prefs->RemovePrefObserver(prefs::kEnableSpellCheck, this); + prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this); // Delete the NTP resource cache so we can unregister pref observers. ntp_resource_cache_.reset(); diff --git a/chrome/browser/profile_impl.h b/chrome/browser/profile_impl.h index f324fbd..9331d34 100644 --- a/chrome/browser/profile_impl.h +++ b/chrome/browser/profile_impl.h @@ -13,7 +13,6 @@ #include "base/scoped_ptr.h" #include "base/timer.h" #include "chrome/browser/profile.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/spellcheck_host_observer.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -145,7 +144,6 @@ class ProfileImpl : public Profile, } NotificationRegistrar registrar_; - PrefChangeRegistrar pref_change_registrar_; FilePath path_; FilePath base_cache_path_; diff --git a/chrome/browser/sync/glue/preference_change_processor.cc b/chrome/browser/sync/glue/preference_change_processor.cc index 874f786..ec0eeb3 100644 --- a/chrome/browser/sync/glue/preference_change_processor.cc +++ b/chrome/browser/sync/glue/preference_change_processor.cc @@ -195,7 +195,6 @@ Value* PreferenceChangeProcessor::ReadPreference( void PreferenceChangeProcessor::StartImpl(Profile* profile) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); pref_service_ = profile->GetPrefs(); - registrar_.Init(pref_service_); StartObserving(); } @@ -211,7 +210,7 @@ void PreferenceChangeProcessor::StartObserving() { for (std::set<std::string>::const_iterator it = model_associator_->synced_preferences().begin(); it != model_associator_->synced_preferences().end(); ++it) { - registrar_.Add((*it).c_str(), this); + pref_service_->AddPrefObserver((*it).c_str(), this); } } @@ -220,7 +219,7 @@ void PreferenceChangeProcessor::StopObserving() { for (std::set<std::string>::const_iterator it = model_associator_->synced_preferences().begin(); it != model_associator_->synced_preferences().end(); ++it) { - registrar_.Remove((*it).c_str(), this); + pref_service_->RemovePrefObserver((*it).c_str(), this); } } diff --git a/chrome/browser/sync/glue/preference_change_processor.h b/chrome/browser/sync/glue/preference_change_processor.h index 1ef88da..cb25511 100644 --- a/chrome/browser/sync/glue/preference_change_processor.h +++ b/chrome/browser/sync/glue/preference_change_processor.h @@ -8,7 +8,6 @@ #include <string> -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/glue/change_processor.h" @@ -61,8 +60,6 @@ class PreferenceChangeProcessor : public ChangeProcessor, // Whether we are currently processing a preference change notification. bool processing_pref_change_; - PrefChangeRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(PreferenceChangeProcessor); }; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 8ed1017..5edfb32 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -399,10 +399,9 @@ TabContents::TabContents(Profile* profile, // Register for notifications about all interested prefs change. PrefService* prefs = profile->GetPrefs(); - pref_change_registrar_.Init(prefs); if (prefs) { for (int i = 0; i < kPrefsToObserveLength; ++i) - pref_change_registrar_.Add(kPrefsToObserve[i], this); + prefs->AddPrefObserver(kPrefsToObserve[i], this); } // Register for notifications about URL starredness changing on any profile. @@ -442,7 +441,13 @@ TabContents::~TabContents() { // We don't want any notifications while we're running our destructor. registrar_.RemoveAll(); - pref_change_registrar_.RemoveAll(); + + // Unregister the notifications of all observed prefs change. + PrefService* prefs = profile()->GetPrefs(); + if (prefs) { + for (int i = 0; i < kPrefsToObserveLength; ++i) + prefs->RemovePrefObserver(kPrefsToObserve[i], this); + } NotifyDisconnected(); hung_renderer_dialog::HideForTabContents(this); diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index d37aab8..90ded2e 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -24,7 +24,6 @@ #include "chrome/browser/find_bar_controller.h" #include "chrome/browser/find_notification_details.h" #include "chrome/browser/jsmessage_box_client.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/password_manager/password_manager_delegate.h" #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/tab_contents/constrained_window.h" @@ -1058,9 +1057,6 @@ class TabContents : public PageNavigator, // Registers and unregisters us for notifications. NotificationRegistrar registrar_; - // Registers and unregisters for pref notifications. - PrefChangeRegistrar pref_change_registrar_; - // Handles print preview and print job for this contents. scoped_ptr<printing::PrintViewManager> printing_; diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 336eb2a..1ea9fad 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -248,7 +248,7 @@ void TranslateManager::Observe(NotificationType type, // We should know about this profile since we are listening for // notifications on it. DCHECK(count > 0); - pref_change_registrar_.Remove(prefs::kAcceptLanguages, this); + profile->GetPrefs()->RemovePrefObserver(prefs::kAcceptLanguages, this); break; } case NotificationType::PREF_CHANGED: { @@ -341,8 +341,6 @@ void TranslateManager::InitiateTranslation(TabContents* tab, if (!prefs->GetBoolean(prefs::kEnableTranslate)) return; - pref_change_registrar_.Init(prefs); - // Allow disabling of translate from the command line to assist with // automated browser testing. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableTranslate)) @@ -535,7 +533,7 @@ bool TranslateManager::IsAcceptLanguage(TabContents* tab, notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, Source<Profile>(tab->profile())); // Also start listening for changes in the accept languages. - pref_change_registrar_.Add(prefs::kAcceptLanguages, this); + tab->profile()->GetPrefs()->AddPrefObserver(prefs::kAcceptLanguages, this); iter = accept_languages_.find(pref_service); } diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h index 3ddcabf..adec281 100644 --- a/chrome/browser/translate/translate_manager.h +++ b/chrome/browser/translate/translate_manager.h @@ -14,7 +14,6 @@ #include "base/lazy_instance.h" #include "base/singleton.h" #include "base/task.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/net/url_fetcher.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -154,7 +153,6 @@ class TranslateManager : public NotificationObserver, TabContents* tab); NotificationRegistrar notification_registrar_; - PrefChangeRegistrar pref_change_registrar_; // A map that associates a profile with its parsed "accept languages". typedef std::set<std::string> LanguageSet; diff --git a/chrome/browser/translate/translate_manager_unittest.cc b/chrome/browser/translate/translate_manager_unittest.cc index f578b3f..8f2b801 100644 --- a/chrome/browser/translate/translate_manager_unittest.cc +++ b/chrome/browser/translate/translate_manager_unittest.cc @@ -7,7 +7,6 @@ #include "base/utf_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/renderer_host/mock_render_process_host.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/render_view_context_menu.h" @@ -852,10 +851,8 @@ TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) { // Select never translate this language. PrefService* prefs = contents()->profile()->GetPrefs(); - PrefChangeRegistrar registrar; - registrar.Init(prefs); - registrar.Add(TranslatePrefs::kPrefTranslateLanguageBlacklist, - &pref_observer_); + prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateLanguageBlacklist, + &pref_observer_); TranslatePrefs translate_prefs(prefs); EXPECT_FALSE(translate_prefs.IsLanguageBlacklisted("fr")); EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); @@ -884,6 +881,8 @@ TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) { // There should be a translate infobar. EXPECT_TRUE(GetTranslateInfoBar() != NULL); + prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateLanguageBlacklist, + &pref_observer_); } // Tests the "Never translate this site" pref. @@ -898,10 +897,8 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) { // Select never translate this site. PrefService* prefs = contents()->profile()->GetPrefs(); - PrefChangeRegistrar registrar; - registrar.Init(prefs); - registrar.Add(TranslatePrefs::kPrefTranslateSiteBlacklist, - &pref_observer_); + prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateSiteBlacklist, + &pref_observer_); TranslatePrefs translate_prefs(prefs); EXPECT_FALSE(translate_prefs.IsSiteBlacklisted(host)); EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url)); @@ -930,16 +927,16 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) { // There should be a translate infobar. EXPECT_TRUE(GetTranslateInfoBar() != NULL); + prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateSiteBlacklist, + &pref_observer_); } // Tests the "Always translate this language" pref. TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) { // Select always translate French to English. PrefService* prefs = contents()->profile()->GetPrefs(); - PrefChangeRegistrar registrar; - registrar.Init(prefs); - registrar.Add(TranslatePrefs::kPrefTranslateWhitelists, - &pref_observer_); + prefs->AddPrefObserver(TranslatePrefs::kPrefTranslateWhitelists, + &pref_observer_); TranslatePrefs translate_prefs(prefs); SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists); translate_prefs.WhitelistLanguagePair("fr", "en"); @@ -988,6 +985,8 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) { infobar = GetTranslateInfoBar(); ASSERT_TRUE(infobar != NULL); EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); + prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateWhitelists, + &pref_observer_); } // Context menu. diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index f340967..8bf838f 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -202,6 +202,9 @@ GeneralPageView::GeneralPageView(Profile* profile) } GeneralPageView::~GeneralPageView() { + profile()->GetPrefs()->RemovePrefObserver(prefs::kRestoreOnStartup, this); + profile()->GetPrefs()->RemovePrefObserver( + prefs::kURLsToRestoreOnStartup, this); if (startup_custom_pages_table_) startup_custom_pages_table_->SetModel(NULL); default_browser_worker_->ObserverDestroyed(); @@ -338,9 +341,8 @@ void GeneralPageView::InitControlLayout() { #endif // Register pref observers that update the controls when a pref changes. - registrar_.Init(profile()->GetPrefs()); - registrar_.Add(prefs::kRestoreOnStartup, this); - registrar_.Add(prefs::kURLsToRestoreOnStartup, this); + profile()->GetPrefs()->AddPrefObserver(prefs::kRestoreOnStartup, this); + profile()->GetPrefs()->AddPrefObserver(prefs::kURLsToRestoreOnStartup, this); new_tab_page_is_home_page_.Init(prefs::kHomePageIsNewTabPage, profile()->GetPrefs(), this); diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h index f2b126f..93a7af5 100644 --- a/chrome/browser/views/options/general_page_view.h +++ b/chrome/browser/views/options/general_page_view.h @@ -6,7 +6,6 @@ #define CHROME_BROWSER_VIEWS_OPTIONS_GENERAL_PAGE_VIEW_H_ #pragma once -#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/prefs/pref_member.h" #include "chrome/browser/shell_integration.h" #include "chrome/browser/views/options/options_page_view.h" @@ -157,8 +156,6 @@ class GeneralPageView : public OptionsPageView, // The helper object that performs default browser set/check tasks. scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; - PrefChangeRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(GeneralPageView); }; diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index d9acdd7..6fd04fc 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -16,7 +16,6 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/dom_ui/ntp_resource_cache.h" -#include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/favicon_service.h" #include "chrome/browser/find_bar_state.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" @@ -208,8 +207,6 @@ TestingProfile::~TestingProfile() { if (top_sites_.get()) top_sites_->ClearProfile(); history::TopSites::DeleteTopSites(top_sites_); - if (extensions_service_.get()) - extensions_service_->DestroyingProfile(); } void TestingProfile::CreateFaviconService() { @@ -318,17 +315,6 @@ void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { theme_provider_.reset(theme_provider); } -scoped_refptr<ExtensionsService> TestingProfile::CreateExtensionsService( - const CommandLine* command_line, - const FilePath& install_directory) { - extensions_service_ = new ExtensionsService(this, - command_line, - GetPrefs(), - install_directory, - false); - return extensions_service_; -} - FilePath TestingProfile::GetPath() { DCHECK(temp_dir_.IsValid()); // TODO(phajdan.jr): do it better. return temp_dir_.path(); @@ -344,10 +330,6 @@ webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() { return db_tracker_; } -ExtensionsService* TestingProfile::GetExtensionsService() { - return extensions_service_.get(); -} - net::CookieMonster* TestingProfile::GetCookieMonster() { if (!GetRequestContext()) return NULL; diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 819fa03..d75b7c1 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -23,7 +23,6 @@ class CookieMonster; class AutocompleteClassifier; class BookmarkModel; class BrowserThemeProvider; -class CommandLine; class DesktopNotificationService; class FaviconService; class FindBarState; @@ -87,14 +86,6 @@ class TestingProfile : public Profile { // ownership of |theme_provider|. void UseThemeProvider(BrowserThemeProvider* theme_provider); - // Creates an ExtensionsService initialized with the testing profile and - // returns it. The profile keeps its own copy of a scoped_refptr to the - // ExtensionsService to make sure that is still alive to be notified when the - // profile is destroyed. - scoped_refptr<ExtensionsService> CreateExtensionsService( - const CommandLine* command_line, - const FilePath& install_directory); - TestingPrefService* GetTestingPrefService(); virtual ProfileId GetRuntimeId() { @@ -118,7 +109,7 @@ class TestingProfile : public Profile { virtual ChromeAppCacheService* GetAppCacheService() { return NULL; } virtual webkit_database::DatabaseTracker* GetDatabaseTracker(); virtual VisitedLinkMaster* GetVisitedLinkMaster() { return NULL; } - virtual ExtensionsService* GetExtensionsService(); + virtual ExtensionsService* GetExtensionsService() { return NULL; } virtual UserScriptMaster* GetUserScriptMaster() { return NULL; } virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { return NULL; @@ -355,10 +346,6 @@ class TestingProfile : public Profile { FilePath last_selected_directory_; scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. - // For properly notifying the ExtensionsService when the profile - // is disposed. - scoped_refptr<ExtensionsService> extensions_service_; - // We use a temporary directory to store testing profile data. ScopedTempDir temp_dir_; }; |