Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1908)

Unified Diff: chrome/browser/geolocation/geolocation_content_settings_map.cc

Issue 5398001: Allow default desktop content settings to be managed via policy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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() {
}

Powered by Google App Engine
This is Rietveld 408576698