| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_INTERNAL_EXTENSION_PROV
IDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROV
IDER_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROV
IDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROV
IDER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "chrome/browser/content_settings/content_settings_observable_provider.h
" | 10 #include "chrome/browser/content_settings/content_settings_observable_provider.h
" |
| 11 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" | 11 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" |
| 12 #include "components/content_settings/core/common/content_settings.h" | 12 #include "components/content_settings/core/common/content_settings.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "extensions/browser/extension_registry_observer.h" | |
| 16 | 15 |
| 17 class ExtensionService; | 16 class ExtensionService; |
| 18 | 17 |
| 19 namespace extensions { | 18 namespace extensions { |
| 20 class Extension; | 19 class Extension; |
| 21 class ExtensionRegistry; | |
| 22 } | 20 } |
| 23 | 21 |
| 24 namespace content_settings { | 22 namespace content_settings { |
| 25 | 23 |
| 26 // A content settings provider which disables certain plugins for platform apps. | 24 // A content settings provider which disables certain plugins for platform apps. |
| 27 class InternalExtensionProvider : public ObservableProvider, | 25 class InternalExtensionProvider : public ObservableProvider, |
| 28 public content::NotificationObserver, | 26 public content::NotificationObserver { |
| 29 public extensions::ExtensionRegistryObserver { | |
| 30 public: | 27 public: |
| 31 explicit InternalExtensionProvider(ExtensionService* extension_service); | 28 explicit InternalExtensionProvider(ExtensionService* extension_service); |
| 32 | 29 |
| 33 virtual ~InternalExtensionProvider(); | 30 virtual ~InternalExtensionProvider(); |
| 34 | 31 |
| 35 // ProviderInterface methods: | 32 // ProviderInterface methods: |
| 36 virtual RuleIterator* GetRuleIterator( | 33 virtual RuleIterator* GetRuleIterator( |
| 37 ContentSettingsType content_type, | 34 ContentSettingsType content_type, |
| 38 const ResourceIdentifier& resource_identifier, | 35 const ResourceIdentifier& resource_identifier, |
| 39 bool incognito) const OVERRIDE; | 36 bool incognito) const OVERRIDE; |
| 40 | 37 |
| 41 virtual bool SetWebsiteSetting( | 38 virtual bool SetWebsiteSetting( |
| 42 const ContentSettingsPattern& primary_pattern, | 39 const ContentSettingsPattern& primary_pattern, |
| 43 const ContentSettingsPattern& secondary_pattern, | 40 const ContentSettingsPattern& secondary_pattern, |
| 44 ContentSettingsType content_type, | 41 ContentSettingsType content_type, |
| 45 const ResourceIdentifier& resource_identifier, | 42 const ResourceIdentifier& resource_identifier, |
| 46 base::Value* value) OVERRIDE; | 43 base::Value* value) OVERRIDE; |
| 47 | 44 |
| 48 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) | 45 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) |
| 49 OVERRIDE; | 46 OVERRIDE; |
| 50 | 47 |
| 51 virtual void ShutdownOnUIThread() OVERRIDE; | 48 virtual void ShutdownOnUIThread() OVERRIDE; |
| 52 | 49 |
| 53 // content::NotificationObserver implementation. | 50 // content::NotificationObserver implementation. |
| 54 virtual void Observe(int type, | 51 virtual void Observe(int type, |
| 55 const content::NotificationSource& source, | 52 const content::NotificationSource& source, |
| 56 const content::NotificationDetails& details) OVERRIDE; | 53 const content::NotificationDetails& details) OVERRIDE; |
| 57 | |
| 58 // extensions::ExtensionRegistryObserver implementation. | |
| 59 virtual void OnExtensionLoaded( | |
| 60 content::BrowserContext* browser_context, | |
| 61 const extensions::Extension* extension) OVERRIDE; | |
| 62 virtual void OnExtensionUnloaded( | |
| 63 content::BrowserContext* browser_context, | |
| 64 const extensions::Extension* extension, | |
| 65 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; | |
| 66 | |
| 67 private: | 54 private: |
| 68 void SetContentSettingForExtension(const extensions::Extension* extension, | 55 void SetContentSettingForExtension(const extensions::Extension* extension, |
| 69 ContentSetting setting); | 56 ContentSetting setting); |
| 70 void SetContentSettingForExtensionAndResource( | 57 void SetContentSettingForExtensionAndResource( |
| 71 const extensions::Extension* extension, | 58 const extensions::Extension* extension, |
| 72 const ResourceIdentifier& resource, | 59 const ResourceIdentifier& resource, |
| 73 ContentSetting setting); | 60 ContentSetting setting); |
| 74 | 61 |
| 75 OriginIdentifierValueMap value_map_; | 62 OriginIdentifierValueMap value_map_; |
| 76 | 63 |
| 77 // Used around accesses to the |value_map_| list to guarantee thread safety. | 64 // Used around accesses to the |value_map_| list to guarantee thread safety. |
| 78 mutable base::Lock lock_; | 65 mutable base::Lock lock_; |
| 79 scoped_ptr<content::NotificationRegistrar> registrar_; | 66 scoped_ptr<content::NotificationRegistrar> registrar_; |
| 80 | 67 |
| 81 extensions::ExtensionRegistry* extension_registry_; // Not owned. | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider); | 68 DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider); |
| 84 }; | 69 }; |
| 85 | 70 |
| 86 } // namespace content_settings | 71 } // namespace content_settings |
| 87 | 72 |
| 88 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_P
ROVIDER_H_ | 73 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_P
ROVIDER_H_ |
| OLD | NEW |