- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / content_settings / content_settings_provider.h
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.
4
5 // Interface for objects providing content setting rules.
6
7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
9
10 #define NO_RESOURCE_IDENTIFIER std::string()
11
12 #include <string>
13 #include <vector>
14
15 #include "base/values.h"
16 #include "chrome/common/content_settings_types.h"
17
18 class ContentSettingsPattern;
19
20 namespace content_settings {
21
22 struct Rule;
23 class RuleIterator;
24
25 typedef std::string ResourceIdentifier;
26
27 class ProviderInterface {
28  public:
29   virtual ~ProviderInterface() {}
30
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
38   // destroyed.
39   virtual RuleIterator* GetRuleIterator(
40       ContentSettingsType content_type,
41       const ResourceIdentifier& resource_identifier,
42       bool incognito) const = 0;
43
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
48   // with the caller.
49   //
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;
58
59   // Resets all content settings for the given |content_type| and empty resource
60   // identifier to CONTENT_SETTING_DEFAULT.
61   //
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;
66
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;
72 };
73
74 }  // namespace content_settings
75
76 #endif  // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_