| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // A content settings provider that takes its settings out of policies. | 9 // A content settings provider that takes its settings out of policies. |
| 10 | 10 |
| 11 #include <vector> |
| 12 |
| 11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 12 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/tuple.h" |
| 13 #include "chrome/browser/content_settings/content_settings_provider.h" | 16 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 17 #include "chrome/browser/content_settings/content_settings_base_provider.h" |
| 14 #include "chrome/browser/prefs/pref_change_registrar.h" | 18 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 15 #include "chrome/common/notification_observer.h" | 19 #include "chrome/common/notification_observer.h" |
| 16 #include "chrome/common/notification_registrar.h" | 20 #include "chrome/common/notification_registrar.h" |
| 17 | 21 |
| 18 class ContentSettingsDetails; | 22 class ContentSettingsDetails; |
| 19 class DictionaryValue; | 23 class DictionaryValue; |
| 20 class PrefService; | 24 class PrefService; |
| 21 class Profile; | 25 class Profile; |
| 22 | 26 |
| 23 namespace content_settings { | 27 namespace content_settings { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // Used around accesses to the managed_default_content_settings_ object to | 73 // Used around accesses to the managed_default_content_settings_ object to |
| 70 // guarantee thread safety. | 74 // guarantee thread safety. |
| 71 mutable base::Lock lock_; | 75 mutable base::Lock lock_; |
| 72 | 76 |
| 73 PrefChangeRegistrar pref_change_registrar_; | 77 PrefChangeRegistrar pref_change_registrar_; |
| 74 NotificationRegistrar notification_registrar_; | 78 NotificationRegistrar notification_registrar_; |
| 75 | 79 |
| 76 DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider); | 80 DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider); |
| 77 }; | 81 }; |
| 78 | 82 |
| 83 // PolicyProvider that provider managed content-settings. |
| 84 class PolicyProvider : public BaseProvider, |
| 85 public NotificationObserver { |
| 86 public: |
| 87 explicit PolicyProvider(Profile* profile); |
| 88 ~PolicyProvider(); |
| 89 static void RegisterUserPrefs(PrefService* prefs); |
| 90 |
| 91 // BaseProvider Implementation |
| 92 virtual void Init(); |
| 93 |
| 94 // ProviderInterface Implementation |
| 95 virtual bool ContentSettingsTypeIsManaged( |
| 96 ContentSettingsType content_type); |
| 97 |
| 98 virtual void SetContentSetting( |
| 99 const ContentSettingsPattern& requesting_pattern, |
| 100 const ContentSettingsPattern& embedding_pattern, |
| 101 ContentSettingsType content_type, |
| 102 const ResourceIdentifier& resource_identifier, |
| 103 ContentSetting content_setting); |
| 104 |
| 105 virtual ContentSetting GetContentSetting( |
| 106 const GURL& requesting_url, |
| 107 const GURL& embedding_url, |
| 108 ContentSettingsType content_type, |
| 109 const ResourceIdentifier& resource_identifier) const; |
| 110 |
| 111 virtual void ClearAllContentSettingsRules( |
| 112 ContentSettingsType content_type); |
| 113 |
| 114 virtual void ResetToDefaults(); |
| 115 |
| 116 // NotificationObserver implementation. |
| 117 virtual void Observe(NotificationType type, |
| 118 const NotificationSource& source, |
| 119 const NotificationDetails& details); |
| 120 private: |
| 121 typedef Tuple5< |
| 122 ContentSettingsPattern, |
| 123 ContentSettingsPattern, |
| 124 ContentSettingsType, |
| 125 content_settings::ProviderInterface::ResourceIdentifier, |
| 126 ContentSetting> ContentSettingsRule; |
| 127 |
| 128 typedef std::vector<ContentSettingsRule> ContentSettingsRules; |
| 129 |
| 130 void ReadManagedContentSettings(bool overwrite); |
| 131 |
| 132 void GetContentSettingsFromPreferences(PrefService* prefs, |
| 133 ContentSettingsRules* rules); |
| 134 |
| 135 void ReadManagedContentSettingsTypes( |
| 136 ContentSettingsType content_type); |
| 137 |
| 138 void NotifyObservers(const ContentSettingsDetails& details); |
| 139 |
| 140 void UnregisterObservers(); |
| 141 |
| 142 Profile* profile_; |
| 143 |
| 144 bool content_type_is_managed_[CONTENT_SETTINGS_NUM_TYPES]; |
| 145 |
| 146 PrefChangeRegistrar pref_change_registrar_; |
| 147 NotificationRegistrar notification_registrar_; |
| 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(PolicyProvider); |
| 150 }; |
| 151 |
| 79 } // namespace content_settings | 152 } // namespace content_settings |
| 80 | 153 |
| 81 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 154 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
| OLD | NEW |