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