summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 21:55:36 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 21:55:36 +0000
commit3c6c0ca9c82ba0bcb975bfb0b42cfa2186de92e3 (patch)
treefc8e553f683104a0de014e5e1d1ecf0c436bf807
parentb671ef3ffa0bb016fed93529bae49fb89c683198 (diff)
downloadchromium_src-3c6c0ca9c82ba0bcb975bfb0b42cfa2186de92e3.zip
chromium_src-3c6c0ca9c82ba0bcb975bfb0b42cfa2186de92e3.tar.gz
chromium_src-3c6c0ca9c82ba0bcb975bfb0b42cfa2186de92e3.tar.bz2
Add geolocation and desktop notifications NotificationTypes.
Now geolocation should update live (i.e. if an exception is added or removed, the table will update without you needing to reload the page). BUG=57457 TEST=manual Review URL: http://codereview.chromium.org/3607005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61857 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/options/content_settings_handler.cc37
-rw-r--r--chrome/browser/geolocation/geolocation_content_settings_map.cc5
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc20
-rw-r--r--chrome/common/notification_type.h10
4 files changed, 56 insertions, 16 deletions
diff --git a/chrome/browser/dom_ui/options/content_settings_handler.cc b/chrome/browser/dom_ui/options/content_settings_handler.cc
index 6cab675..2a21f27 100644
--- a/chrome/browser/dom_ui/options/content_settings_handler.cc
+++ b/chrome/browser/dom_ui/options/content_settings_handler.cc
@@ -278,22 +278,37 @@ void ContentSettingsHandler::Initialize() {
notification_registrar_.Add(
this, NotificationType::CONTENT_SETTINGS_CHANGED,
Source<const HostContentSettingsMap>(settings_map));
+ notification_registrar_.Add(
+ this, NotificationType::GEOLOCATION_SETTINGS_CHANGED,
+ NotificationService::AllSources());
}
void ContentSettingsHandler::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- if (type != NotificationType::CONTENT_SETTINGS_CHANGED)
- return OptionsPageUIHandler::Observe(type, source, details);
-
- const ContentSettingsDetails* settings_details =
- static_cast<Details<const ContentSettingsDetails> >(details).ptr();
-
- // TODO(estade): we pretend update_all() is always true.
- if (settings_details->update_all_types())
- UpdateAllExceptionsViewsFromModel();
- else
- UpdateExceptionsViewFromModel(settings_details->type());
+ switch (type.value) {
+ case NotificationType::CONTENT_SETTINGS_CHANGED: {
+ const ContentSettingsDetails* settings_details =
+ static_cast<Details<const ContentSettingsDetails> >(details).ptr();
+
+ // TODO(estade): we pretend update_all() is always true.
+ if (settings_details->update_all_types())
+ UpdateAllExceptionsViewsFromModel();
+ else
+ UpdateExceptionsViewFromModel(settings_details->type());
+ break;
+ }
+ case NotificationType::GEOLOCATION_SETTINGS_CHANGED: {
+ UpdateGeolocationExceptionsView();
+ break;
+ }
+ case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: {
+ UpdateNotificationExceptionsView();
+ break;
+ }
+ default:
+ OptionsPageUIHandler::Observe(type, source, details);
+ }
}
void ContentSettingsHandler::UpdateSettingDefaultFromModel(
diff --git a/chrome/browser/geolocation/geolocation_content_settings_map.cc b/chrome/browser/geolocation/geolocation_content_settings_map.cc
index db8cd75..2d4ac0e 100644
--- a/chrome/browser/geolocation/geolocation_content_settings_map.cc
+++ b/chrome/browser/geolocation/geolocation_content_settings_map.cc
@@ -157,6 +157,11 @@ 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/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 1b3df09..99be401 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/worker_host/worker_process_host.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
@@ -296,9 +297,14 @@ void DesktopNotificationService::Observe(NotificationType type,
const NotificationDetails& details) {
DCHECK(NotificationType::PREF_CHANGED == type);
PrefService* prefs = profile_->GetPrefs();
- std::string* name = Details<std::string>(details).ptr();
+ const std::string& name = *Details<std::string>(details).ptr();
+
+ if (name == prefs::kDesktopNotificationAllowedOrigins) {
+ NotificationService::current()->Notify(
+ NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
+ Source<DesktopNotificationService>(this),
+ NotificationService::NoDetails());
- if (0 == name->compare(prefs::kDesktopNotificationAllowedOrigins)) {
std::vector<GURL> allowed_origins(GetAllowedOrigins());
// Schedule a cache update on the IO thread.
ChromeThread::PostTask(
@@ -307,7 +313,12 @@ void DesktopNotificationService::Observe(NotificationType type,
prefs_cache_.get(),
&NotificationsPrefsCache::SetCacheAllowedOrigins,
allowed_origins));
- } else if (0 == name->compare(prefs::kDesktopNotificationDeniedOrigins)) {
+ } else if (name == prefs::kDesktopNotificationDeniedOrigins) {
+ NotificationService::current()->Notify(
+ NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
+ Source<DesktopNotificationService>(this),
+ NotificationService::NoDetails());
+
std::vector<GURL> denied_origins(GetBlockedOrigins());
// Schedule a cache update on the IO thread.
ChromeThread::PostTask(
@@ -316,8 +327,7 @@ void DesktopNotificationService::Observe(NotificationType type,
prefs_cache_.get(),
&NotificationsPrefsCache::SetCacheDeniedOrigins,
denied_origins));
- } else if (0 == name->compare(
- prefs::kDesktopNotificationDefaultContentSetting)) {
+ } else if (name == prefs::kDesktopNotificationDefaultContentSetting) {
const ContentSetting default_content_setting = IntToContentSetting(
prefs->GetInteger(prefs::kDesktopNotificationDefaultContentSetting));
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 33418cf..3440538 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -1018,6 +1018,16 @@ class NotificationType {
// TabSpecificContentSettings object, there are no details.
COLLECTED_COOKIES_SHOWN,
+ // 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 a non-default setting in the the notification content settings
+ // map has changed. The source is the DesktopNotificationService, the
+ // details are None.
+ DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
+
// Sync --------------------------------------------------------------------
// Sent when the sync backend has been paused.