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

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

Issue 5528010: Implement preference and policy based content settings providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/content_settings
Patch Set: updates 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/content_settings/pref_content_settings_provider.h
diff --git a/chrome/browser/content_settings/pref_content_settings_provider.h b/chrome/browser/content_settings/pref_content_settings_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..178e903b97bb22127f324dc5dc0406e0d1b9a0fd
--- /dev/null
+++ b/chrome/browser/content_settings/pref_content_settings_provider.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_
+#define CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_
+#pragma once
+
+// A content settings provider that takes its settings out of the pref service.
+
+#include "base/basictypes.h"
+#include "base/lock.h"
+#include "chrome/browser/content_settings/content_settings_provider.h"
+#include "chrome/browser/prefs/pref_change_registrar.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+
+class ContentSettingsDetails;
+class DictionaryValue;
+class PrefService;
+class Profile;
+
+class PrefContentSettingsProvider : public ContentSettingsProviderInterface,
+ public NotificationObserver {
+ public:
+ explicit PrefContentSettingsProvider(Profile* profile);
+ virtual ~PrefContentSettingsProvider();
+
+ // ContentSettingsProviderInterface implementation.
+ virtual bool CanProvideDefaultSetting(ContentSettingsType content_type) const;
+ virtual ContentSetting ProvideDefaultSetting(
+ ContentSettingsType content_type) const;
+ virtual void UpdateDefaultSetting(ContentSettingsType content_type,
+ ContentSetting setting);
+ virtual void ResetToDefaults();
+ virtual bool DefaultSettingIsManaged(ContentSettingsType content_type) const;
+
+ static void RegisterUserPrefs(PrefService* prefs);
+
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ // Informs observers that content settings have changed. Make sure that
+ // |lock_| is not held when calling this, as listeners will usually call one
+ // of the GetSettings functions in response, which would then lead to a
+ // mutex deadlock.
+ void NotifyObservers(const ContentSettingsDetails& details);
+
+ void UnregisterObservers();
+
+ // Sets the fields of |settings| based on the values in |dictionary|.
+ void GetSettingsFromDictionary(const DictionaryValue* dictionary,
+ ContentSettings* settings);
+
+ // Forces the default settings to be explicitly set instead of themselves
+ // being CONTENT_SETTING_DEFAULT.
+ void ForceDefaultsToBeExplicit();
+
+ // Reads the default settings from the preferences service. If |overwrite| is
+ // true and the preference is missing, the local copy will be cleared as well.
+ void ReadDefaultSettings(bool overwrite);
+
+ // Copies of the pref data, so that we can read it on the IO thread.
+ ContentSettings default_content_settings_;
+
+ Profile* profile_;
+
+ // Whether this settings map is for an OTR session.
+ bool is_off_the_record_;
+
+ // Used around accesses to the default_content_settings_ object to guarantee
+ // thread safety.
+ mutable Lock lock_;
+
+ PrefChangeRegistrar pref_change_registrar_;
+ NotificationRegistrar notification_registrar_;
+
+ // Whether we are currently updating preferences, this is used to ignore
+ // notifications from the preferences service that we triggered ourself.
+ bool updating_preferences_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrefContentSettingsProvider);
+};
+
+#endif // CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698