Index: chrome/browser/geolocation/geolocation_content_settings_map.cc |
diff --git a/chrome/browser/geolocation/geolocation_content_settings_map.cc b/chrome/browser/geolocation/geolocation_content_settings_map.cc |
index 2eb2f747760b08cf4b410c373beaa1468a82dc73..7878fe1113f0eda7e5b980f46a521ed24a387baa 100644 |
--- a/chrome/browser/geolocation/geolocation_content_settings_map.cc |
+++ b/chrome/browser/geolocation/geolocation_content_settings_map.cc |
@@ -18,10 +18,13 @@ |
#include "base/string_piece.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/browser_thread.h" |
+#include "chrome/browser/content_settings/content_settings_details.h" |
+#include "chrome/browser/content_settings/content_settings_pattern.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/prefs/scoped_pref_update.h" |
#include "chrome/browser/profiles/profile.h" |
#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" |
@@ -35,6 +38,11 @@ const ContentSetting |
GeolocationContentSettingsMap::GeolocationContentSettingsMap(Profile* profile) |
: profile_(profile) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ prefs_registrar_.Init(profile_->GetPrefs()); |
+ prefs_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this); |
+ prefs_registrar_.Add(prefs::kGeolocationContentSettings, this); |
+ notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, |
+ Source<Profile>(profile_)); |
} |
// static |
@@ -53,6 +61,12 @@ ContentSetting GeolocationContentSettingsMap::GetDefaultContentSetting() const { |
kDefaultSetting : default_content_setting; |
} |
+bool GeolocationContentSettingsMap::IsDefaultContentSettingManaged() const { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ return profile_->GetPrefs()->IsManagedPreference( |
+ prefs::kGeolocationDefaultContentSetting); |
+} |
+ |
ContentSetting GeolocationContentSettingsMap::GetContentSetting( |
const GURL& requesting_url, |
const GURL& embedding_url) const { |
@@ -167,6 +181,43 @@ void GeolocationContentSettingsMap::ResetToDefault() { |
prefs->ClearPref(prefs::kGeolocationContentSettings); |
} |
+void GeolocationContentSettingsMap::NotifyObservers( |
+ const ContentSettingsDetails& details) { |
+ NotificationService::current()->Notify( |
+ NotificationType::CONTENT_SETTINGS_CHANGED, |
+ Source<GeolocationContentSettingsMap>(this), |
+ Details<const ContentSettingsDetails>(&details)); |
+} |
+ |
+void GeolocationContentSettingsMap::Observe( |
+ NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) { |
+ if (NotificationType::PREF_CHANGED == type) { |
+ const std::string& name = *Details<std::string>(details).ptr(); |
+ if (name == prefs::kGeolocationDefaultContentSetting) { |
+ NotifyObservers(ContentSettingsDetails( |
jochen (gone - plz use gerrit)
2010/12/07 18:55:55
Since this map always reads the settings out of th
markusheintz_
2010/12/08 14:41:39
If you don't mind I'd like to keep it separate.
|
+ ContentSettingsPattern(), |
+ CONTENT_SETTINGS_TYPE_DEFAULT, |
+ "")); |
+ } |
+ } if (NotificationType::PROFILE_DESTROYED == type) { |
+ UnregisterObservers(); |
+ }else { |
+ NOTREACHED(); |
+ } |
+} |
+ |
+void GeolocationContentSettingsMap::UnregisterObservers() { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (!profile_) |
+ return; |
+ prefs_registrar_.RemoveAll(); |
+ notification_registrar_.Remove(this, NotificationType::PROFILE_DESTROYED, |
+ Source<Profile>(profile_)); |
+ profile_ = NULL; |
+} |
+ |
GeolocationContentSettingsMap::~GeolocationContentSettingsMap() { |
} |