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_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/synchronization/lock.h"
10 #include "components/content_settings/core/browser/content_settings_observable_provider.h"
11 #include "components/content_settings/core/browser/content_settings_origin_identifier_value_map.h"
12 #include "components/content_settings/core/common/content_settings.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
18 namespace extensions
{
22 namespace content_settings
{
24 // A content settings provider which disables certain plugins for platform apps.
25 class InternalExtensionProvider
: public ObservableProvider
,
26 public content::NotificationObserver
{
28 explicit InternalExtensionProvider(Profile
* profile
);
30 ~InternalExtensionProvider() override
;
32 // ProviderInterface methods:
33 RuleIterator
* GetRuleIterator(ContentSettingsType content_type
,
34 const ResourceIdentifier
& resource_identifier
,
35 bool incognito
) const override
;
37 bool SetWebsiteSetting(const ContentSettingsPattern
& primary_pattern
,
38 const ContentSettingsPattern
& secondary_pattern
,
39 ContentSettingsType content_type
,
40 const ResourceIdentifier
& resource_identifier
,
41 base::Value
* value
) override
;
43 void ClearAllContentSettingsRules(ContentSettingsType content_type
) override
;
45 void ShutdownOnUIThread() override
;
47 // content::NotificationObserver implementation.
48 void Observe(int type
,
49 const content::NotificationSource
& source
,
50 const content::NotificationDetails
& details
) override
;
53 void SetContentSettingForExtension(const extensions::Extension
* extension
,
54 ContentSetting setting
);
55 void SetContentSettingForExtensionAndResource(
56 const extensions::Extension
* extension
,
57 const ResourceIdentifier
& resource
,
58 ContentSetting setting
);
60 OriginIdentifierValueMap value_map_
;
62 // Used around accesses to the |value_map_| list to guarantee thread safety.
63 mutable base::Lock lock_
;
64 scoped_ptr
<content::NotificationRegistrar
> registrar_
;
66 DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider
);
69 } // namespace content_settings
71 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_