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

Side by Side Diff: chrome/browser/extensions/extension_content_settings_store.h

Issue 6927028: TODO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
OLDNEW
(Empty)
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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_
7
8 #include <list>
9 #include <map>
10 #include <string>
11
12 #include "base/observer_list.h"
13 #include "base/time.h"
14 #include "base/tuple.h"
15 #include "chrome/browser/content_settings/content_settings_base.h"
16 #include "chrome/browser/content_settings/content_settings_pattern.h"
17 #include "chrome/common/content_settings.h"
18 #include "googleurl/src/gurl.h"
19
20 class ExtensionContentSettingsStore {
21 public:
22
23 class Observer {
24 public:
25 virtual ~Observer();
26
27 // Called when a default setting changes in the
28 // ExtensionContentSettingsStore.
29 virtual void OnDefaultContentSettingChanged(
30 const ContentSettingsType& type,
31 ContentSetting setting) = 0;
32
33 // Called when a content setting changes in the
34 // ExtensionContentSettingsStore.
35 virtual void OnContentSettingChanged(
36 const ContentSettingsPattern& pattern,
37 const ContentSettingsPattern& embedder_pattern,
38 const ContentSettingsType& type,
39 const content_settings::ResourceIdentifier& identifier,
40 ContentSetting setting,
41 bool incognito) = 0;
42
43 // Called when the ExtensionContentSettingsStore is being destroyed. When
44 // called, observers must unsubscribe.
45 virtual void OnDestruction() = 0;
46 };
47
48 ExtensionContentSettingsStore();
49 virtual ~ExtensionContentSettingsStore();
50
51 // //////////////////////////////////////////////////////////////////////////
52
53 void SetExtensionDefaultContentSetting(ContentSettingsType content_type,
54 ContentSetting setting);
55
56 ContentSetting GetEffectiveDefaultContentSetting(
57 ContentSettingsType content_type);
58
59 // Sets the content |setting| for |pattern| of extension |ext_id|. The
60 // |incognito| flag allow to set whether the provided setting is for
61 // incognito mode only.
62 // Precondition: the extension must be registered.
63 void SetExtensionContentSetting(
64 const std::string& ext_id,
65 const ContentSettingsPattern& pattern,
66 const ContentSettingsPattern& embedder_pattern,
67 const ContentSettingsType& type,
68 const content_settings::ResourceIdentifier& identifier,
69 ContentSetting setting,
70 bool incognito);
71
72 ContentSetting GetEffectiveContentSetting(
73 const GURL& url,
74 const GURL& embedder_url,
75 const ContentSettingsType& type,
76 const content_settings::ResourceIdentifier& identifier,
77 bool incognito) const;
78
79 // TODO(markusheintz): More content settings API backend stuff goes here.
80
81 // //////////////////////////////////////////////////////////////////////////
82
83 // Registers the time when an extension |ext_id| is installed.
84 void RegisterExtension(const std::string& ext_id,
85 const base::Time& install_time,
86 bool is_enabled);
87
88 // Deletes all entries related to extension |ext_id|.
89 void UnregisterExtension(const std::string& ext_id);
90
91 // Hides or makes the extension content settings of the specified extension
92 // visible.
93 void SetExtensionState(const std::string& ext_id, bool is_enabled);
94
95 // Adds |observer|.
96 void AddObserver(Observer* observer);
97
98 // Remove |observer|.
99 void RemoveObserver(Observer* observer);
100
101 private:
102 struct ExtensionEntry;
103
104 typedef std::map<std::string, ExtensionEntry*> ExtensionEntryMap;
105
106 typedef Tuple5<ContentSettingsPattern,
107 ContentSettingsPattern,
108 ContentSettingsType,
109 content_settings::ResourceIdentifier,
110 ContentSetting> ContentSettingSpec;
111
112 typedef std::list<ContentSettingSpec> ContentSettingSpecList;
113
114 ContentSetting GetContentSettingFrom (
115 const GURL& url,
116 const GURL& embedder_url,
117 const ContentSettingsType& type,
118 const content_settings::ResourceIdentifier& identifier,
119 const ContentSettingSpecList* setting_spec_list) const;
120
121 ContentSettingSpecList* GetContentSettingSpecList(
122 const std::string& ext_id,
123 bool incognito);
124
125 const ContentSettingSpecList* GetContentSettingSpecList(
126 const std::string& ext_id,
127 bool incognito) const;
128
129 void NotifyOfContentSettingChanged(
130 const ContentSettingsPattern& pattern,
131 const ContentSettingsPattern& embedder_pattern,
132 const ContentSettingsType& type,
133 const content_settings::ResourceIdentifier& identifier,
134 ContentSetting setting,
135 bool incognito);
136
137 void NotifyOfDestruction();
138
139 ExtensionEntryMap entries_;
140
141 ObserverList<Observer, true> observers_;
142
143 DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsStore);
144 };
145
146 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698