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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h"
13 #include "components/content_settings/core/browser/content_settings_observable_provider.h"
14 #include "components/content_settings/core/browser/content_settings_origin_identifier_value_map.h"
15 #include "components/content_settings/core/common/content_settings.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
21 namespace extensions
{
25 namespace content_settings
{
27 // A content settings provider which disables certain plugins for platform apps.
28 class InternalExtensionProvider
: public ObservableProvider
,
29 public content::NotificationObserver
{
31 explicit InternalExtensionProvider(Profile
* profile
);
33 ~InternalExtensionProvider() override
;
35 // ProviderInterface methods:
36 RuleIterator
* GetRuleIterator(ContentSettingsType content_type
,
37 const ResourceIdentifier
& resource_identifier
,
38 bool incognito
) const override
;
40 bool SetWebsiteSetting(const ContentSettingsPattern
& primary_pattern
,
41 const ContentSettingsPattern
& secondary_pattern
,
42 ContentSettingsType content_type
,
43 const ResourceIdentifier
& resource_identifier
,
44 base::Value
* value
) override
;
46 void ClearAllContentSettingsRules(ContentSettingsType content_type
) override
;
48 void ShutdownOnUIThread() override
;
50 // content::NotificationObserver implementation.
51 void Observe(int type
,
52 const content::NotificationSource
& source
,
53 const content::NotificationDetails
& details
) override
;
56 void ApplyPluginContentSettingsForExtension(
57 const extensions::Extension
* extension
,
58 ContentSetting setting
);
59 void SetContentSettingForExtension(const extensions::Extension
* extension
,
60 ContentSetting setting
);
61 void SetContentSettingForExtensionAndResource(
62 const extensions::Extension
* extension
,
63 const ResourceIdentifier
& resource
,
64 ContentSetting setting
);
66 OriginIdentifierValueMap value_map_
;
68 // Used around accesses to the |value_map_| list to guarantee thread safety.
69 mutable base::Lock lock_
;
70 scoped_ptr
<content::NotificationRegistrar
> registrar_
;
72 // Extension IDs used by the Chrome Remote Desktop app.
73 std::set
<std::string
> chrome_remote_desktop_
;
75 DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider
);
78 } // namespace content_settings
80 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_