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..bec4bc367697da42b5d5e65285705bd7bf9a786d 100644 |
--- a/chrome/browser/geolocation/geolocation_content_settings_map.cc |
+++ b/chrome/browser/geolocation/geolocation_content_settings_map.cc |
@@ -21,7 +21,9 @@ |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/prefs/scoped_pref_update.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/content_settings_types.h" |
jochen (gone - plz use gerrit)
2010/12/07 09:43:52
why did you need this?
markusheintz_
2010/12/07 11:46:15
removed
|
#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 +37,9 @@ 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); |
} |
// static |
@@ -53,6 +58,12 @@ ContentSetting GeolocationContentSettingsMap::GetDefaultContentSetting() const { |
kDefaultSetting : default_content_setting; |
} |
+bool GeolocationContentSettingsMap::IsDefaultContentSettingManaged() const { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ return profile_->GetPrefs()->IsManagedPreference( |
jochen (gone - plz use gerrit)
2010/12/07 09:43:52
you should also watch for PROFILE_DESTROYED
markusheintz_
2010/12/07 11:46:15
Done.
|
+ prefs::kGeolocationDefaultContentSetting); |
+} |
+ |
ContentSetting GeolocationContentSettingsMap::GetContentSetting( |
const GURL& requesting_url, |
const GURL& embedding_url) const { |
@@ -167,6 +178,31 @@ 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) { |
jochen (gone - plz use gerrit)
2010/12/07 09:43:52
hum, why are you doing this here instead of sendin
markusheintz_
2010/12/07 11:46:15
Because I must listen for PREF_CHANGED events that
|
+ const std::string& name = *Details<std::string>(details).ptr(); |
+ if (name == prefs::kGeolocationDefaultContentSetting) { |
+ NotifyObservers(ContentSettingsDetails( |
+ ContentSettingsPattern(), |
+ CONTENT_SETTINGS_TYPE_DEFAULT, |
+ "")); |
+ } |
+ } else { |
+ NOTREACHED(); |
+ } |
+} |
+ |
GeolocationContentSettingsMap::~GeolocationContentSettingsMap() { |
} |