Chromium Code Reviews| Index: chrome/browser/content_settings/policy_content_settings_provider.h |
| diff --git a/chrome/browser/content_settings/policy_content_settings_provider.h b/chrome/browser/content_settings/policy_content_settings_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f7e749e00a515b1d9217d4006cb33d9f8163f2d0 |
| --- /dev/null |
| +++ b/chrome/browser/content_settings/policy_content_settings_provider.h |
| @@ -0,0 +1,81 @@ |
| +// 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_POLICY_CONTENT_SETTINGS_PROVIDER_H_ |
| +#define CHROME_BROWSER_CONTENT_SETTINGS_POLICY_CONTENT_SETTINGS_PROVIDER_H_ |
| +#pragma once |
| + |
| +// A content settings provider that takes its settings out of policies. |
| + |
| +#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 PolicyContentSettingsProvider : public ContentSettingsProviderInterface, |
| + public NotificationObserver { |
| + public: |
| + PolicyContentSettingsProvider(Profile* profile); |
| + virtual ~PolicyContentSettingsProvider(); |
| + |
| + // 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); |
| + |
| + private: |
| + // NotificationObserver implementation. |
| + virtual void Observe(NotificationType type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details); |
| + |
| + // 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 retrieved from |prefs|. |
| + void ReadDefaultSettingsFromPrefs(const PrefService* prefs, |
| + ContentSettings* settings); |
| + |
| + // Reads the policy controlled default settings for a specific content type. |
| + void UpdateManagedDefaultSetting(const PrefService* prefs, |
| + ContentSettingsType content_type, |
| + ContentSettings* settings); |
| + |
| + |
| + // Copies of the pref data, so that we can read it on the IO thread. |
| + ContentSettings managed_default_content_settings_; |
| + |
| + Profile* profile_; |
| + |
| + // Whether this settings map is for an OTR session. |
| + bool is_off_the_record_; |
| + |
| + // Used around accesses to the settings_ object to guarantee thread safety. |
|
gfeher
2010/12/08 13:59:17
s/settings_/managed_default_content_settings_/ ?
A
jochen (gone - plz use gerrit)
2010/12/08 14:54:01
Done.
|
| + mutable Lock lock_; |
| + |
| + PrefChangeRegistrar pref_change_registrar_; |
| + NotificationRegistrar notification_registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PolicyContentSettingsProvider); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_CONTENT_SETTINGS_POLICY_CONTENT_SETTINGS_PROVIDER_H_ |