diff options
author | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 02:09:36 +0000 |
---|---|---|
committer | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 02:09:36 +0000 |
commit | d78482a45263f6fb46af84a766f9407e54c2ede7 (patch) | |
tree | f957088f9319b864a1050ccc3f33636221532361 | |
parent | afd71834e71e66c3b290b1a67773ef640f15ba65 (diff) | |
download | chromium_src-d78482a45263f6fb46af84a766f9407e54c2ede7.zip chromium_src-d78482a45263f6fb46af84a766f9407e54c2ede7.tar.gz chromium_src-d78482a45263f6fb46af84a766f9407e54c2ede7.tar.bz2 |
Discard GEOLOCATION_* notifications, instead observe preference notifications.
BUG=61110
TEST=Verify that sync events result in location setting UI updates.
Review URL: http://codereview.chromium.org/4666002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65471 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 14 insertions, 33 deletions
diff --git a/chrome/browser/dom_ui/options/content_settings_handler.cc b/chrome/browser/dom_ui/options/content_settings_handler.cc index 8ba0982..bfb463d 100644 --- a/chrome/browser/dom_ui/options/content_settings_handler.cc +++ b/chrome/browser/dom_ui/options/content_settings_handler.cc @@ -19,6 +19,7 @@ #include "chrome/common/notification_service.h" #include "chrome/common/notification_source.h" #include "chrome/common/notification_type.h" +#include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -309,17 +310,16 @@ void ContentSettingsHandler::Initialize() { this, NotificationType::CONTENT_SETTINGS_CHANGED, Source<const HostContentSettingsMap>(settings_map)); notification_registrar_.Add( - this, NotificationType::GEOLOCATION_DEFAULT_CHANGED, - NotificationService::AllSources()); - notification_registrar_.Add( - this, NotificationType::GEOLOCATION_SETTINGS_CHANGED, - NotificationService::AllSources()); - notification_registrar_.Add( this, NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED, NotificationService::AllSources()); notification_registrar_.Add( this, NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, NotificationService::AllSources()); + + PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); + pref_change_registrar_.Init(prefs); + pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this); + pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this); } void ContentSettingsHandler::Observe(NotificationType type, @@ -350,14 +350,12 @@ void ContentSettingsHandler::Observe(NotificationType type, break; } - case NotificationType::GEOLOCATION_DEFAULT_CHANGED: { - UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); - break; - } - - case NotificationType::GEOLOCATION_SETTINGS_CHANGED: { - UpdateGeolocationExceptionsView(); - break; + case NotificationType::PREF_CHANGED: { + const std::string& pref_name = *Details<std::string>(details).ptr(); + if (pref_name == prefs::kGeolocationDefaultContentSetting) + UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION); + else if (pref_name == prefs::kGeolocationContentSettings) + UpdateGeolocationExceptionsView(); } case NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED: { diff --git a/chrome/browser/dom_ui/options/content_settings_handler.h b/chrome/browser/dom_ui/options/content_settings_handler.h index 7874dae..e18de26 100644 --- a/chrome/browser/dom_ui/options/content_settings_handler.h +++ b/chrome/browser/dom_ui/options/content_settings_handler.h @@ -7,6 +7,7 @@ #pragma once #include "chrome/browser/dom_ui/options/options_ui.h" +#include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/common/content_settings_types.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" @@ -98,6 +99,7 @@ class ContentSettingsHandler : public OptionsPageUIHandler { // Member variables --------------------------------------------------------- NotificationRegistrar notification_registrar_; + PrefChangeRegistrar pref_change_registrar_; DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler); }; diff --git a/chrome/browser/geolocation/geolocation_content_settings_map.cc b/chrome/browser/geolocation/geolocation_content_settings_map.cc index 0bf798c..31a0a21 100644 --- a/chrome/browser/geolocation/geolocation_content_settings_map.cc +++ b/chrome/browser/geolocation/geolocation_content_settings_map.cc @@ -117,11 +117,6 @@ void GeolocationContentSettingsMap::SetDefaultContentSetting( profile_->GetPrefs()->SetInteger(prefs::kGeolocationDefaultContentSetting, setting == CONTENT_SETTING_DEFAULT ? kDefaultSetting : setting); - - NotificationService::current()->Notify( - NotificationType::GEOLOCATION_DEFAULT_CHANGED, - Source<GeolocationContentSettingsMap>(this), - NotificationService::NoDetails()); } void GeolocationContentSettingsMap::SetContentSetting( @@ -162,11 +157,6 @@ void GeolocationContentSettingsMap::SetContentSetting( requesting_origin_settings_dictionary->SetWithoutPathExpansion( embedding_origin.spec(), Value::CreateIntegerValue(setting)); } - - NotificationService::current()->Notify( - NotificationType::GEOLOCATION_SETTINGS_CHANGED, - Source<GeolocationContentSettingsMap>(this), - NotificationService::NoDetails()); } void GeolocationContentSettingsMap::ResetToDefault() { diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index afbb5f6..ba8280d 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -1072,15 +1072,6 @@ class NotificationType { // TabSpecificContentSettings object, there are no details. COLLECTED_COOKIES_SHOWN, - // Sent when the default geolocation setting has changed. The source is the - // GeolocationContentSettingsMap, the details are None. - GEOLOCATION_DEFAULT_CHANGED, - - // Sent when a non-default setting in the the geolocation content settings - // map has changed. The source is the GeolocationContentSettingsMap, the - // details are None. - GEOLOCATION_SETTINGS_CHANGED, - // Sent when the default setting for desktop notifications has changed. // The source is the DesktopNotificationService, the details are None. DESKTOP_NOTIFICATION_DEFAULT_CHANGED, |