1 // Copyright (c) 2011 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 // Interface for objects providing content setting rules.
7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
10 #define NO_RESOURCE_IDENTIFIER std::string()
15 #include "base/values.h"
16 #include "chrome/common/content_settings_types.h"
18 class ContentSettingsPattern
;
20 namespace content_settings
{
25 typedef std::string ResourceIdentifier
;
27 class ProviderInterface
{
29 virtual ~ProviderInterface() {}
31 // Returns a |RuleIterator| over the content setting rules stored by this
32 // provider. If |incognito| is true, the iterator returns only the content
33 // settings which are applicable to the incognito mode and differ from the
34 // normal mode. Otherwise, it returns the content settings for the normal
35 // mode. The caller takes the ownership of the returned |RuleIterator|. It is
36 // not allowed to call other |ProviderInterface| functions (including
37 // |GetRuleIterator|) for the same provider until the |RuleIterator| is
39 virtual RuleIterator
* GetRuleIterator(
40 ContentSettingsType content_type
,
41 const ResourceIdentifier
& resource_identifier
,
42 bool incognito
) const = 0;
44 // Asks the provider to set the website setting for a particular
45 // |primary_pattern|, |secondary_pattern|, |content_type| tuple. If the
46 // provider accepts the setting it returns true and takes the ownership of the
47 // |value|. Otherwise false is returned and the ownership of the |value| stays
50 // This should only be called on the UI thread, and not after
51 // ShutdownOnUIThread has been called.
52 virtual bool SetWebsiteSetting(
53 const ContentSettingsPattern
& primary_pattern
,
54 const ContentSettingsPattern
& secondary_pattern
,
55 ContentSettingsType content_type
,
56 const ResourceIdentifier
& resource_identifier
,
57 base::Value
* value
) = 0;
59 // Resets all content settings for the given |content_type| and empty resource
60 // identifier to CONTENT_SETTING_DEFAULT.
62 // This should only be called on the UI thread, and not after
63 // ShutdownOnUIThread has been called.
64 virtual void ClearAllContentSettingsRules(
65 ContentSettingsType content_type
) = 0;
67 // Detaches the Provider from all Profile-related objects like PrefService.
68 // This methods needs to be called before destroying the Profile.
69 // Afterwards, none of the methods above that should only be called on the UI
70 // thread should be called anymore.
71 virtual void ShutdownOnUIThread() = 0;
74 } // namespace content_settings
76 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_