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

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

Issue 6242013: Add LegacyContentSettingsProvider Interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 10 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 | no next file » | 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 <utility>
13 #include <vector>
14
15 #include "chrome/browser/content_settings/content_settings_pattern.h"
11 #include "chrome/common/content_settings.h" 16 #include "chrome/common/content_settings.h"
12 17
18 class GURL;
19
13 class DefaultContentSettingsProvider { 20 class DefaultContentSettingsProvider {
14 public: 21 public:
15 virtual ~DefaultContentSettingsProvider() {} 22 virtual ~DefaultContentSettingsProvider() {}
16 23
17 // True if this provider can provide a default setting for the |content_type|. 24 // True if this provider can provide a default setting for the |content_type|.
18 virtual bool CanProvideDefaultSetting( 25 virtual bool CanProvideDefaultSetting(
19 ContentSettingsType content_type) const = 0; 26 ContentSettingsType content_type) const = 0;
20 27
21 // Returns the default content setting this provider has for the given 28 // Returns the default content setting this provider has for the given
22 // |content_type|, or CONTENT_SETTING_DEFAULT if nothing be provided for this 29 // |content_type|, or CONTENT_SETTING_DEFAULT if nothing be provided for this
23 // type. 30 // type.
24 virtual ContentSetting ProvideDefaultSetting( 31 virtual ContentSetting ProvideDefaultSetting(
25 ContentSettingsType content_type) const = 0; 32 ContentSettingsType content_type) const = 0;
26 33
27 // Notifies the provider that the host content settings map would like to 34 // 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 35 // update the default setting for the given |content_type|. The provider may
29 // ignore this. 36 // ignore this.
30 virtual void UpdateDefaultSetting(ContentSettingsType content_type, 37 virtual void UpdateDefaultSetting(ContentSettingsType content_type,
31 ContentSetting setting) = 0; 38 ContentSetting setting) = 0;
32 39
33 // Resets the state of the provider to the default. 40 // Resets the state of the provider to the default.
34 virtual void ResetToDefaults() = 0; 41 virtual void ResetToDefaults() = 0;
35 42
36 // True if the default setting for the |content_type| is policy managed, i.e., 43 // 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. 44 // there shouldn't be any UI shown to modify this setting.
38 virtual bool DefaultSettingIsManaged( 45 virtual bool DefaultSettingIsManaged(
39 ContentSettingsType content_type) const = 0; 46 ContentSettingsType content_type) const = 0;
40 }; 47 };
41 48
49 class LegacyContentSettingsProvider {
50 public:
51 // LEGACY ContentSettingsProvider interface
52 typedef std::pair<ContentSettingsPattern, ContentSetting> PatternSettingPair;
53 typedef std::vector<PatternSettingPair> SettingsForOneType;
54
55 virtual ~LegacyContentSettingsProvider() {}
56
57 // Returns a single ContentSetting which applies to a given URL. Note that
58 // certain internal schemes are whitelisted. For ContentSettingsTypes that
59 // require an resource identifier to be specified, the |resource_identifier|
60 // must be non-empty.
61 //
62 // This may be called on any thread.
63 virtual ContentSetting GetContentSetting(
64 const GURL& url,
65 ContentSettingsType content_type,
66 const std::string& resource_identifier) const = 0;
67
68 // Returns a single ContentSetting which applies to a given URL or
69 // CONTENT_SETTING_DEFAULT, if no exception applies. Note that certain
70 // internal schemes are whitelisted. For ContentSettingsTypes that require an
71 // resource identifier to be specified, the |resource_identifier| must be
72 // non-empty.
73 //
74 // This may be called on any thread.
75 virtual ContentSetting GetNonDefaultContentSetting(
76 const GURL& url,
77 ContentSettingsType content_type,
78 const std::string& resource_identifier) const = 0;
79
80 // Returns all ContentSettings which apply to a given URL. For content
81 // setting types that require an additional resource identifier, the default
82 // content setting is returned.
83 //
84 // This may be called on any thread.
85 virtual ContentSettings GetContentSettings(const GURL& url) const = 0;
86
87 // Returns all non-default ContentSettings which apply to a given URL. For
88 // content setting types that require an additional resource identifier,
89 // CONTENT_SETTING_DEFAULT is returned.
90 //
91 // This may be called on any thread.
92 virtual ContentSettings GetNonDefaultContentSettings(
93 const GURL& url) const = 0;
94
95 // For a given content type, returns all patterns with a non-default setting,
96 // mapped to their actual settings, in lexicographical order. |settings|
97 // must be a non-NULL outparam. If this map was created for the
98 // off-the-record profile, it will only return those settings differing from
99 // the main map. For ContentSettingsTypes that require an resource identifier
100 // to be specified, the |resource_identifier| must be non-empty.
101 //
102 // This may be called on any thread.
103 virtual void GetSettingsForOneType(ContentSettingsType content_type,
104 const std::string& resource_identifier,
105 SettingsForOneType* settings) const = 0;
106
107 // Sets the blocking setting for a particular pattern and content type.
108 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting
109 // for that type to be used when loading pages matching this pattern. For
110 // ContentSettingsTypes that require an resource identifier to be specified,
111 // the |resource_identifier| must be non-empty.
112 //
113 // This should only be called on the UI thread.
114 virtual void SetContentSetting(const ContentSettingsPattern& pattern,
115 ContentSettingsType content_type,
116 const std::string& resource_identifier,
117 ContentSetting setting) = 0;
118
119 // Convenience method to add a content setting for a given URL, making sure
120 // that there is no setting overriding it. For ContentSettingsTypes that
121 // require an resource identifier to be specified, the |resource_identifier|
122 // must be non-empty.
123 //
124 // This should only be called on the UI thread.
125 virtual void AddExceptionForURL(const GURL& url,
126 ContentSettingsType content_type,
127 const std::string& resource_identifier,
128 ContentSetting setting) = 0;
129
130 // Clears all host-specific settings for one content type.
131 //
132 // This should only be called on the UI thread.
133 virtual void ClearSettingsForOneType(ContentSettingsType content_type) = 0;
134
135 // Resets all settings levels.
136 //
137 // This should only be called on the UI thread.
138 virtual void ResetToDefaults() = 0;
139 };
140
42 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ 141 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698