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

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

Issue 140018: Make ExtensionPrefs paths relative, re-enable 2 ExtensionsService unit_tests (Closed)
Patch Set: final changes Created 11 years, 6 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/pref_service.h" 14 #include "chrome/common/pref_service.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 16
17 // Class for managing global and per-extension preferences. 17 // Class for managing global and per-extension preferences.
18 // This class is instantiated by ExtensionsService, so it should be accessed 18 // This class is instantiated by ExtensionsService, so it should be accessed
19 // from there. 19 // from there.
20 class ExtensionPrefs { 20 class ExtensionPrefs {
21 public: 21 public:
22 explicit ExtensionPrefs(PrefService* prefs); 22 explicit ExtensionPrefs(PrefService* prefs, const FilePath& root_dir_);
23 23
24 // Returns a copy of the Extensions prefs. 24 // Returns a copy of the Extensions prefs.
25 // TODO(erikkay) Remove this so that external consumers don't need to be 25 // TODO(erikkay) Remove this so that external consumers don't need to be
26 // aware of the internal structure of the preferences. 26 // aware of the internal structure of the preferences.
27 DictionaryValue* CopyCurrentExtensions(); 27 DictionaryValue* CopyCurrentExtensions();
28 28
29 // Populate |killed_ids| with extension ids that have been killed. 29 // Populate |killed_ids| with extension ids that have been killed.
30 void GetKilledExtensionIds(std::set<std::string>* killed_ids); 30 void GetKilledExtensionIds(std::set<std::string>* killed_ids);
31 31
32 // Get the order that toolstrip URLs appear in the shelf. 32 // Get the order that toolstrip URLs appear in the shelf.
33 typedef std::vector<GURL> URLList; 33 typedef std::vector<GURL> URLList;
34 URLList GetShelfToolstripOrder(); 34 URLList GetShelfToolstripOrder();
35 35
36 // Sets the order that toolstrip URLs appear in the shelf. 36 // Sets the order that toolstrip URLs appear in the shelf.
37 void SetShelfToolstripOrder(const URLList& urls); 37 void SetShelfToolstripOrder(const URLList& urls);
38 38
39 // Called when an extension is installed, so that prefs get created. 39 // Called when an extension is installed, so that prefs get created.
40 void OnExtensionInstalled(Extension* extension); 40 void OnExtensionInstalled(Extension* extension);
41 41
42 // Called when an extension is uninstalled, so that prefs get cleaned up. 42 // Called when an extension is uninstalled, so that prefs get cleaned up.
43 void OnExtensionUninstalled(const Extension* extension, 43 void OnExtensionUninstalled(const Extension* extension,
44 bool external_uninstall); 44 bool external_uninstall);
45 45
46 // Returns base extensions install directory.
47 const FilePath& install_directory() const { return install_directory_; }
48
46 private: 49 private:
50
51 // Converts absolute paths in the pref to paths relative to the
52 // install_directory_.
53 void MakePathsRelative();
54
55 // Converts internal relative paths to be absolute. Used for export to
56 // consumers who expect full paths.
57 void MakePathsAbsolute(DictionaryValue* dict);
58
47 // Sets the pref |key| for extension |id| to |value|. 59 // Sets the pref |key| for extension |id| to |value|.
48 bool UpdateExtensionPref(const std::string& id, 60 bool UpdateExtensionPref(const std::string& id,
49 const std::wstring& key, 61 const std::wstring& key,
50 Value* value); 62 Value* value);
51 63
52 // Deletes the pref dictionary for extension |id|. 64 // Deletes the pref dictionary for extension |id|.
53 void DeleteExtensionPrefs(const std::string& id); 65 void DeleteExtensionPrefs(const std::string& id);
54 66
55 // Ensures and returns a mutable dictionary for extension |id|'s prefs. 67 // Ensures and returns a mutable dictionary for extension |id|'s prefs.
56 DictionaryValue* GetOrCreateExtensionPref(const std::string& id); 68 DictionaryValue* GetOrCreateExtensionPref(const std::string& id);
57 69
58 // The pref service specific to this set of extension prefs. 70 // The pref service specific to this set of extension prefs.
59 PrefService* prefs_; 71 PrefService* prefs_;
60 72
73 // Base extensions install directory.
74 FilePath install_directory_;
75
61 // The URLs of all of the toolstrips. 76 // The URLs of all of the toolstrips.
62 URLList shelf_order_; 77 URLList shelf_order_;
63 78
64 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 79 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
65 }; 80 };
66 81
67 // A helper class that has a list of the currently installed extensions 82 // A helper class that has a list of the currently installed extensions
68 // and can iterate over them to a provided callback. 83 // and can iterate over them to a provided callback.
69 class InstalledExtensions { 84 class InstalledExtensions {
70 public: 85 public:
(...skipping 10 matching lines...) Expand all
81 96
82 private: 97 private:
83 // A copy of the extensions pref dictionary so that this can be passed 98 // A copy of the extensions pref dictionary so that this can be passed
84 // around without a dependency on prefs. 99 // around without a dependency on prefs.
85 scoped_ptr<DictionaryValue> extension_data_; 100 scoped_ptr<DictionaryValue> extension_data_;
86 101
87 DISALLOW_COPY_AND_ASSIGN(InstalledExtensions); 102 DISALLOW_COPY_AND_ASSIGN(InstalledExtensions);
88 }; 103 };
89 104
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H 105 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698