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 #include "chrome/browser/extensions/api/content_settings/content_settings_custom_extension_provider.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/api/content_settings/content_settings_store.h"
9 #include "components/content_settings/core/browser/content_settings_utils.h"
10 #include "components/content_settings/core/common/content_settings_pattern.h"
12 namespace content_settings
{
14 CustomExtensionProvider::CustomExtensionProvider(
15 const scoped_refptr
<extensions::ContentSettingsStore
>& extensions_settings
,
17 : incognito_(incognito
), extensions_settings_(extensions_settings
) {
18 extensions_settings_
->AddObserver(this);
21 CustomExtensionProvider::~CustomExtensionProvider() {
24 RuleIterator
* CustomExtensionProvider::GetRuleIterator(
25 ContentSettingsType content_type
,
26 const ResourceIdentifier
& resource_identifier
,
27 bool incognito
) const {
28 return extensions_settings_
->GetRuleIterator(content_type
,
33 bool CustomExtensionProvider::SetWebsiteSetting(
34 const ContentSettingsPattern
& primary_pattern
,
35 const ContentSettingsPattern
& secondary_pattern
,
36 ContentSettingsType content_type
,
37 const ResourceIdentifier
& resource_identifier
,
42 void CustomExtensionProvider::ShutdownOnUIThread() {
44 extensions_settings_
->RemoveObserver(this);
47 void CustomExtensionProvider::OnContentSettingChanged(
48 const std::string
& extension_id
,
50 if (incognito_
!= incognito
)
52 // TODO(markusheintz): Be more concise.
53 NotifyObservers(ContentSettingsPattern(),
54 ContentSettingsPattern(),
55 CONTENT_SETTINGS_TYPE_DEFAULT
,
59 } // namespace content_settings