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

Unified Diff: chrome/browser/content_settings/content_settings_policy_provider.h

Issue 6542048: Add content_settings::PolicyProvider and a set of new policies to managed content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 10 months 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/content_settings/content_settings_policy_provider.h
diff --git a/chrome/browser/content_settings/content_settings_policy_provider.h b/chrome/browser/content_settings/content_settings_policy_provider.h
index 82aaf260fea9d71c81abb4ab2437c4f6aa514dfa..96dd11568ebb6afafb1a2391c8ebf04c452008d9 100644
--- a/chrome/browser/content_settings/content_settings_policy_provider.h
+++ b/chrome/browser/content_settings/content_settings_policy_provider.h
@@ -8,9 +8,13 @@
// A content settings provider that takes its settings out of policies.
+#include <vector>
+
#include "base/basictypes.h"
#include "base/synchronization/lock.h"
+#include "base/tuple.h"
#include "chrome/browser/content_settings/content_settings_provider.h"
+#include "chrome/browser/content_settings/content_settings_base_provider.h"
#include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
@@ -76,6 +80,75 @@ class PolicyDefaultProvider : public DefaultProviderInterface,
DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider);
};
+// PolicyProvider that provider managed content-settings.
+class PolicyProvider : public BaseProvider,
+ public NotificationObserver {
+ public:
+ explicit PolicyProvider(Profile* profile);
+ ~PolicyProvider();
+ static void RegisterUserPrefs(PrefService* prefs);
+
+ // BaseProvider Implementation
+ virtual void Init();
+
+ // ProviderInterface Implementation
+ virtual bool ContentSettingsTypeIsManaged(
+ ContentSettingsType content_type);
+
+ virtual void SetContentSetting(
+ const ContentSettingsPattern& requesting_pattern,
+ const ContentSettingsPattern& embedding_pattern,
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier,
+ ContentSetting content_setting);
+
+ virtual ContentSetting GetContentSetting(
+ const GURL& requesting_url,
+ const GURL& embedding_url,
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier) const;
+
+ virtual void ClearAllContentSettingsRules(
+ ContentSettingsType content_type);
+
+ virtual void ResetToDefaults();
+
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+ private:
+ typedef Tuple5<
+ ContentSettingsPattern,
+ ContentSettingsPattern,
+ ContentSettingsType,
+ content_settings::ProviderInterface::ResourceIdentifier,
+ ContentSetting> ContentSettingsRule;
+
+ typedef std::vector<ContentSettingsRule> ContentSettingsRules;
+
+ void ReadManagedContentSettings(bool overwrite);
+
+ void GetContentSettingsFromPreferences(PrefService* prefs,
+ ContentSettingsRules* rules);
+
+ void ReadManagedContentSettingsTypes(
+ ContentSettingsType content_type);
+
+ void NotifyObservers(const ContentSettingsDetails& details);
+
+ void UnregisterObservers();
+
+ Profile* profile_;
+
+ bool content_type_is_managed_[CONTENT_SETTINGS_NUM_TYPES];
+
+ PrefChangeRegistrar pref_change_registrar_;
+ NotificationRegistrar notification_registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyProvider);
+};
+
} // namespace content_settings
#endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698