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 "components/content_settings/core/browser/content_settings_observable_p
rovider.h" | 10 #include "components/content_settings/core/browser/content_settings_observable_p
rovider.h" |
11 #include "components/content_settings/core/browser/content_settings_origin_ident
ifier_value_map.h" | 11 #include "components/content_settings/core/browser/content_settings_origin_ident
ifier_value_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 | 15 |
16 class ExtensionService; | 16 class ExtensionService; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 class Extension; | 19 class Extension; |
20 } | 20 } |
21 | 21 |
22 namespace content_settings { | 22 namespace content_settings { |
23 | 23 |
24 // A content settings provider which disables certain plugins for platform apps. | 24 // A content settings provider which disables certain plugins for platform apps. |
25 class InternalExtensionProvider : public ObservableProvider, | 25 class InternalExtensionProvider : public ObservableProvider, |
26 public content::NotificationObserver { | 26 public content::NotificationObserver { |
27 public: | 27 public: |
28 explicit InternalExtensionProvider(ExtensionService* extension_service); | 28 explicit InternalExtensionProvider(ExtensionService* extension_service); |
29 | 29 |
30 virtual ~InternalExtensionProvider(); | 30 ~InternalExtensionProvider() override; |
31 | 31 |
32 // ProviderInterface methods: | 32 // ProviderInterface methods: |
33 virtual RuleIterator* GetRuleIterator( | 33 RuleIterator* GetRuleIterator(ContentSettingsType content_type, |
34 ContentSettingsType content_type, | 34 const ResourceIdentifier& resource_identifier, |
35 const ResourceIdentifier& resource_identifier, | 35 bool incognito) const override; |
36 bool incognito) const override; | |
37 | 36 |
38 virtual bool SetWebsiteSetting( | 37 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, |
39 const ContentSettingsPattern& primary_pattern, | 38 const ContentSettingsPattern& secondary_pattern, |
40 const ContentSettingsPattern& secondary_pattern, | 39 ContentSettingsType content_type, |
41 ContentSettingsType content_type, | 40 const ResourceIdentifier& resource_identifier, |
42 const ResourceIdentifier& resource_identifier, | 41 base::Value* value) override; |
43 base::Value* value) override; | |
44 | 42 |
45 virtual void ClearAllContentSettingsRules(ContentSettingsType content_type) | 43 void ClearAllContentSettingsRules(ContentSettingsType content_type) override; |
46 override; | |
47 | 44 |
48 virtual void ShutdownOnUIThread() override; | 45 void ShutdownOnUIThread() override; |
49 | 46 |
50 // content::NotificationObserver implementation. | 47 // content::NotificationObserver implementation. |
51 virtual void Observe(int type, | 48 void Observe(int type, |
52 const content::NotificationSource& source, | 49 const content::NotificationSource& source, |
53 const content::NotificationDetails& details) override; | 50 const content::NotificationDetails& details) override; |
| 51 |
54 private: | 52 private: |
55 void SetContentSettingForExtension(const extensions::Extension* extension, | 53 void SetContentSettingForExtension(const extensions::Extension* extension, |
56 ContentSetting setting); | 54 ContentSetting setting); |
57 void SetContentSettingForExtensionAndResource( | 55 void SetContentSettingForExtensionAndResource( |
58 const extensions::Extension* extension, | 56 const extensions::Extension* extension, |
59 const ResourceIdentifier& resource, | 57 const ResourceIdentifier& resource, |
60 ContentSetting setting); | 58 ContentSetting setting); |
61 | 59 |
62 OriginIdentifierValueMap value_map_; | 60 OriginIdentifierValueMap value_map_; |
63 | 61 |
64 // Used around accesses to the |value_map_| list to guarantee thread safety. | 62 // Used around accesses to the |value_map_| list to guarantee thread safety. |
65 mutable base::Lock lock_; | 63 mutable base::Lock lock_; |
66 scoped_ptr<content::NotificationRegistrar> registrar_; | 64 scoped_ptr<content::NotificationRegistrar> registrar_; |
67 | 65 |
68 DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider); | 66 DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider); |
69 }; | 67 }; |
70 | 68 |
71 } // namespace content_settings | 69 } // namespace content_settings |
72 | 70 |
73 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_P
ROVIDER_H_ | 71 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_P
ROVIDER_H_ |
OLD | NEW |