Clear webapp storage when site data is cleared
[chromium-blink-merge.git] / components / content_settings / core / browser / content_settings_provider.h
blobc3e63e772398ba24b39348be1d6e50126f8cfb8f
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 COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PROVIDER_H_
8 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PROVIDER_H_
10 #include <string>
12 #include "base/values.h"
13 #include "components/content_settings/core/common/content_settings.h"
15 class ContentSettingsPattern;
17 namespace content_settings {
19 struct Rule;
20 class RuleIterator;
22 class ProviderInterface {
23 public:
24 virtual ~ProviderInterface() {}
26 // Returns a |RuleIterator| over the content setting rules stored by this
27 // provider. If |incognito| is true, the iterator returns only the content
28 // settings which are applicable to the incognito mode and differ from the
29 // normal mode. Otherwise, it returns the content settings for the normal
30 // mode. The caller takes the ownership of the returned |RuleIterator|. It is
31 // not allowed to call other |ProviderInterface| functions (including
32 // |GetRuleIterator|) for the same provider until the |RuleIterator| is
33 // destroyed.
34 virtual RuleIterator* GetRuleIterator(
35 ContentSettingsType content_type,
36 const ResourceIdentifier& resource_identifier,
37 bool incognito) const = 0;
39 // Asks the provider to set the website setting for a particular
40 // |primary_pattern|, |secondary_pattern|, |content_type| tuple. If the
41 // provider accepts the setting it returns true and takes the ownership of the
42 // |value|. Otherwise false is returned and the ownership of the |value| stays
43 // with the caller.
45 // This should only be called on the UI thread, and not after
46 // ShutdownOnUIThread has been called.
47 virtual bool SetWebsiteSetting(
48 const ContentSettingsPattern& primary_pattern,
49 const ContentSettingsPattern& secondary_pattern,
50 ContentSettingsType content_type,
51 const ResourceIdentifier& resource_identifier,
52 base::Value* value) = 0;
54 // Resets all content settings for the given |content_type| and empty resource
55 // identifier to CONTENT_SETTING_DEFAULT.
57 // This should only be called on the UI thread, and not after
58 // ShutdownOnUIThread has been called.
59 virtual void ClearAllContentSettingsRules(
60 ContentSettingsType content_type) = 0;
62 // Detaches the Provider from all Profile-related objects like PrefService.
63 // This methods needs to be called before destroying the Profile.
64 // Afterwards, none of the methods above that should only be called on the UI
65 // thread should be called anymore.
66 virtual void ShutdownOnUIThread() = 0;
69 } // namespace content_settings
71 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PROVIDER_H_