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

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

Issue 3517004: Revert 60997 - o Add user customizable launch type for apps by adding options... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/linked_ptr.h" 13 #include "base/linked_ptr.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 // Class for managing global and per-extension preferences. 19 // Class for managing global and per-extension preferences.
20 // This class is instantiated by ExtensionsService, so it should be accessed 20 // This class is instantiated by ExtensionsService, so it should be accessed
21 // from there. 21 // from there.
22 class ExtensionPrefs { 22 class ExtensionPrefs {
23 public: 23 public:
24 // Key name for a preference that keeps track of per-extension settings. This
25 // is a dictionary object read from the Preferences file, keyed off of
26 // extension ids.
27 static const char kExtensionsPref[];
28
29 typedef std::vector<linked_ptr<ExtensionInfo> > ExtensionsInfo; 24 typedef std::vector<linked_ptr<ExtensionInfo> > ExtensionsInfo;
30 25
31 // This enum is used for the launch type the user wants to use for an
32 // application.
33 enum LaunchType {
34 LAUNCH_PINNED,
35 LAUNCH_REGULAR,
36 LAUNCH_FULLSCREEN
37 };
38
39 explicit ExtensionPrefs(PrefService* prefs, const FilePath& root_dir_); 26 explicit ExtensionPrefs(PrefService* prefs, const FilePath& root_dir_);
40 27
41 // Returns a copy of the Extensions prefs. 28 // Returns a copy of the Extensions prefs.
42 // TODO(erikkay) Remove this so that external consumers don't need to be 29 // TODO(erikkay) Remove this so that external consumers don't need to be
43 // aware of the internal structure of the preferences. 30 // aware of the internal structure of the preferences.
44 DictionaryValue* CopyCurrentExtensions(); 31 DictionaryValue* CopyCurrentExtensions();
45 32
46 // Populate |killed_ids| with extension ids that have been killed. 33 // Populate |killed_ids| with extension ids that have been killed.
47 void GetKilledExtensionIds(std::set<std::string>* killed_ids); 34 void GetKilledExtensionIds(std::set<std::string>* killed_ids);
48 35
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Returns true if the user enabled this extension to be loaded in incognito 109 // Returns true if the user enabled this extension to be loaded in incognito
123 // mode. 110 // mode.
124 bool IsIncognitoEnabled(const std::string& extension_id); 111 bool IsIncognitoEnabled(const std::string& extension_id);
125 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); 112 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled);
126 113
127 // Returns true if the user has chosen to allow this extension to inject 114 // Returns true if the user has chosen to allow this extension to inject
128 // scripts into pages with file URLs. 115 // scripts into pages with file URLs.
129 bool AllowFileAccess(const std::string& extension_id); 116 bool AllowFileAccess(const std::string& extension_id);
130 void SetAllowFileAccess(const std::string& extension_id, bool allow); 117 void SetAllowFileAccess(const std::string& extension_id, bool allow);
131 118
132 ExtensionPrefs::LaunchType GetLaunchType(const std::string& extension_id);
133 void SetLaunchType(const std::string& extension_id, LaunchType launch_type);
134
135 // Saves ExtensionInfo for each installed extension with the path to the 119 // Saves ExtensionInfo for each installed extension with the path to the
136 // version directory and the location. Blacklisted extensions won't be saved 120 // version directory and the location. Blacklisted extensions won't be saved
137 // and neither will external extensions the user has explicitly uninstalled. 121 // and neither will external extensions the user has explicitly uninstalled.
138 // Caller takes ownership of returned structure. 122 // Caller takes ownership of returned structure.
139 ExtensionsInfo* GetInstalledExtensionsInfo(); 123 ExtensionsInfo* GetInstalledExtensionsInfo();
140 124
141 // Returns the ExtensionInfo from the prefs for the given extension. If the 125 // Returns the ExtensionInfo from the prefs for the given extension. If the
142 // extension is not present, NULL is returned. 126 // extension is not present, NULL is returned.
143 ExtensionInfo* GetInstalledExtensionInfo(const std::string& extension_id); 127 ExtensionInfo* GetInstalledExtensionInfo(const std::string& extension_id);
144 128
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void DeleteExtensionPrefs(const std::string& id); 178 void DeleteExtensionPrefs(const std::string& id);
195 179
196 // Reads a boolean pref from |ext| with key |pref_key|. 180 // Reads a boolean pref from |ext| with key |pref_key|.
197 // Return false if the value is false or kPrefBlacklist does not exist. 181 // Return false if the value is false or kPrefBlacklist does not exist.
198 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key); 182 bool ReadBooleanFromPref(DictionaryValue* ext, const std::string& pref_key);
199 183
200 // Reads a boolean pref |pref_key| from extension with id |extension_id|. 184 // Reads a boolean pref |pref_key| from extension with id |extension_id|.
201 bool ReadExtensionPrefBoolean(const std::string& extension_id, 185 bool ReadExtensionPrefBoolean(const std::string& extension_id,
202 const std::string& pref_key); 186 const std::string& pref_key);
203 187
204 // Reads an integer pref from |ext| with key |pref_key|.
205 // Return false if the value does not exist.
206 bool ReadIntegerFromPref(DictionaryValue* ext, const std::string& pref_key,
207 int* out_value);
208
209 // Reads an integer pref |pref_key| from extension with id |extension_id|.
210 bool ReadExtensionPrefInteger(const std::string& extension_id,
211 const std::string& pref_key,
212 int* out_value);
213
214 // Ensures and returns a mutable dictionary for extension |id|'s prefs. 188 // Ensures and returns a mutable dictionary for extension |id|'s prefs.
215 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); 189 DictionaryValue* GetOrCreateExtensionPref(const std::string& id);
216 190
217 // Same as above, but returns NULL if it doesn't exist. 191 // Same as above, but returns NULL if it doesn't exist.
218 DictionaryValue* GetExtensionPref(const std::string& id) const; 192 DictionaryValue* GetExtensionPref(const std::string& id) const;
219 193
220 // Serializes the data and schedules a persistent save via the |PrefService|.
221 // Additionally fires a PREF_CHANGED notification with the top-level
222 // |kExtensionsPref| path set.
223 // TODO(andybons): Switch this to EXTENSION_PREF_CHANGED to be more granular.
224 // TODO(andybons): Use a ScopedPrefUpdate to update observers on changes to
225 // the mutable extension dictionary.
226 void SavePrefsAndNotify();
227
228 // Checks if kPrefBlacklist is set to true in the DictionaryValue. 194 // Checks if kPrefBlacklist is set to true in the DictionaryValue.
229 // Return false if the value is false or kPrefBlacklist does not exist. 195 // Return false if the value is false or kPrefBlacklist does not exist.
230 // This is used to decide if an extension is blacklisted. 196 // This is used to decide if an extension is blacklisted.
231 bool IsBlacklistBitSet(DictionaryValue* ext); 197 bool IsBlacklistBitSet(DictionaryValue* ext);
232 198
233 // Helper methods for the public last ping day functions. 199 // Helper methods for the public last ping day functions.
234 base::Time LastPingDayImpl(const DictionaryValue* dictionary) const; 200 base::Time LastPingDayImpl(const DictionaryValue* dictionary) const;
235 void SetLastPingDayImpl(const base::Time& time, DictionaryValue* dictionary); 201 void SetLastPingDayImpl(const base::Time& time, DictionaryValue* dictionary);
236 202
237 // The pref service specific to this set of extension prefs. 203 // The pref service specific to this set of extension prefs.
238 PrefService* prefs_; 204 PrefService* prefs_;
239 205
240 // Base extensions install directory. 206 // Base extensions install directory.
241 FilePath install_directory_; 207 FilePath install_directory_;
242 208
243 // The URLs of all of the toolstrips. 209 // The URLs of all of the toolstrips.
244 URLList shelf_order_; 210 URLList shelf_order_;
245 211
246 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 212 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
247 }; 213 };
248 214
249 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ 215 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/ntp_resource_cache.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698