Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/content_settings/content_settings_provider.h

Issue 6253012: Add ContentSettingsProvider Interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits and rename ContentSettingsProviderInterface to ProviderInterface Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Interface for objects providing content setting rules. 5 // Interface for objects providing content setting rules.
6 6
7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ 7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ 8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
9 #pragma once 9 #pragma once
10 10
11 #include <string>
12 #include <vector>
13
14 #include "chrome/browser/content_settings/content_settings_pattern.h"
11 #include "chrome/common/content_settings.h" 15 #include "chrome/common/content_settings.h"
12 16
13 class DefaultContentSettingsProvider { 17 class GURL;
18
19 namespace content_settings {
20
21 class DefaultContentSettingsProviderInterface {
14 public: 22 public:
15 virtual ~DefaultContentSettingsProvider() {} 23 virtual ~DefaultContentSettingsProviderInterface() {}
16 24
17 // True if this provider can provide a default setting for the |content_type|. 25 // True if this provider can provide a default setting for the |content_type|.
18 virtual bool CanProvideDefaultSetting( 26 virtual bool CanProvideDefaultSetting(
19 ContentSettingsType content_type) const = 0; 27 ContentSettingsType content_type) const = 0;
20 28
21 // Returns the default content setting this provider has for the given 29 // Returns the default content setting this provider has for the given
22 // |content_type|, or CONTENT_SETTING_DEFAULT if nothing be provided for this 30 // |content_type|, or CONTENT_SETTING_DEFAULT if nothing be provided for this
23 // type. 31 // type.
24 virtual ContentSetting ProvideDefaultSetting( 32 virtual ContentSetting ProvideDefaultSetting(
25 ContentSettingsType content_type) const = 0; 33 ContentSettingsType content_type) const = 0;
26 34
27 // Notifies the provider that the host content settings map would like to 35 // Notifies the provider that the host content settings map would like to
28 // update the default setting for the given |content_type|. The provider may 36 // update the default setting for the given |content_type|. The provider may
29 // ignore this. 37 // ignore this.
30 virtual void UpdateDefaultSetting(ContentSettingsType content_type, 38 virtual void UpdateDefaultSetting(ContentSettingsType content_type,
31 ContentSetting setting) = 0; 39 ContentSetting setting) = 0;
32 40
33 // Resets the state of the provider to the default. 41 // Resets the state of the provider to the default.
34 virtual void ResetToDefaults() = 0; 42 virtual void ResetToDefaults() = 0;
35 43
36 // True if the default setting for the |content_type| is policy managed, i.e., 44 // True if the default setting for the |content_type| is policy managed, i.e.,
37 // there shouldn't be any UI shown to modify this setting. 45 // there shouldn't be any UI shown to modify this setting.
38 virtual bool DefaultSettingIsManaged( 46 virtual bool DefaultSettingIsManaged(
39 ContentSettingsType content_type) const = 0; 47 ContentSettingsType content_type) const = 0;
40 }; 48 };
41 49
50 class ProviderInterface {
51 public:
52 typedef std::string ResourceIdentifier;
53
54 struct Rule {
Bernhard Bauer 2011/01/27 11:03:48 Sorry to create conflicts with jochen's comments,
55 Rule() {}
56 Rule(const ContentSettingsPattern& requesting_url_pattern,
57 const ContentSettingsPattern& embedding_url_pattern,
58 ContentSetting& setting)
59 : requesting_url_pattern_(requesting_url_pattern),
Bernhard Bauer 2011/01/27 11:03:48 Nit: Indent two more spaces :)
60 embedding_url_pattern_(embedding_url_pattern),
61 content_setting_(setting) {}
62
63 const ContentSettingsPattern requesting_url_pattern_;
64 const ContentSettingsPattern embedding_url_pattern_;
65 ContentSetting content_setting_;
66 };
67
68 typedef std::vector<Rule> Rules;
69
70 virtual ~ProviderInterface() {}
71
72 virtual bool ContentSettingsTypeIsManaged(
73 ContentSettingsType content_type) = 0;
74
75 // This may be called on any thread.
76 virtual ContentSetting GetContentSetting(
77 const GURL requesting_url,
78 const GURL embedding_url,
79 const ContentSettingsType& content_type,
80 const ResourceIdentifier& resource_identifier) const = 0;
81
82 // This should only be called on the UI thread.
83 virtual void SetContentSetting(
84 const ContentSettingsPattern& requesting_pattern,
85 const ContentSettingsPattern& embedding_pattern,
86 const ContentSettingsType& content_type,
87 const ResourceIdentifier& resource_identifier,
88 ContentSetting content_setting) = 0;
89
90 // This may be called on any thread.
91 virtual void GetAllContentSettingsRules(
92 const ContentSettingsType& content_type,
93 const ResourceIdentifier& resource_identifier,
94 Rules* content_setting_rules) const = 0;
95
96 // This should only be called on the UI thread.
97 virtual void ClearAllContentSettingsRules() = 0;
98 };
99
100 } // namespace content_settings
101
42 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ 102 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698