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