summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_prefs.h
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 22:08:35 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-17 22:08:35 +0000
commite9e7fcf685c04dd864fe43f2eda17177ced50760 (patch)
tree9be846229063ae252516b96173cade3662b229ea /chrome/browser/extensions/extension_prefs.h
parent955ee6d6f9ef04b29a1fde4ea20091e424c4911e (diff)
downloadchromium_src-e9e7fcf685c04dd864fe43f2eda17177ced50760.zip
chromium_src-e9e7fcf685c04dd864fe43f2eda17177ced50760.tar.gz
chromium_src-e9e7fcf685c04dd864fe43f2eda17177ced50760.tar.bz2
Pull Extension-related prefs into its own class. Also add a notification for when the extensions service has finished its initial load of extensions, separate from EXTENSIONS_LOADED.TEST=noneBUG=none
Review URL: http://codereview.chromium.org/126281 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_prefs.h')
-rw-r--r--chrome/browser/extensions/extension_prefs.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_prefs.h b/chrome/browser/extensions/extension_prefs.h
new file mode 100644
index 0000000..db5847b
--- /dev/null
+++ b/chrome/browser/extensions/extension_prefs.h
@@ -0,0 +1,85 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/task.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/pref_service.h"
+#include "googleurl/src/gurl.h"
+
+// Class for managing global and per-extension preferences.
+// This class is instantiated by ExtensionsService, so it should be accessed
+// from there.
+class ExtensionPrefs {
+ public:
+ explicit ExtensionPrefs(PrefService* prefs);
+
+ // Returns a copy of the Extensions prefs.
+ // TODO(erikkay) Remove this so that external consumers don't need to be
+ // aware of the internal structure of the preferences.
+ DictionaryValue* CopyCurrentExtensions();
+
+ // Populate |killed_ids| with extension ids that have been killed.
+ void GetKilledExtensionIds(std::set<std::string>* killed_ids);
+
+ // Get the order that toolstrip URLs appear in the shelf.
+ typedef std::vector<GURL> URLList;
+ URLList GetShelfToolstripOrder();
+
+ // Called when an extension is installed, so that prefs get created.
+ void OnExtensionInstalled(Extension* extension);
+
+ // Called when an extension is uninstalled, so that prefs get cleaned up.
+ void OnExtensionUninstalled(const Extension* extension);
+
+ private:
+ // Sets the pref |key| for extension |id| to |value|.
+ bool UpdateExtensionPref(const std::string& id,
+ const std::wstring& key,
+ Value* value);
+
+ // Deletes the pref dictionary for extension |id|.
+ void DeleteExtensionPrefs(const std::string& id);
+
+ // Ensures and returns a mutable dictionary for extension |id|'s prefs.
+ DictionaryValue* GetOrCreateExtensionPref(const std::string& id);
+
+ // The pref service specific to this set of extension prefs.
+ PrefService* prefs_;
+
+ // The URLs of all of the toolstrips.
+ URLList shelf_order_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
+};
+
+// A helper class that has a list of the currently installed extensions
+// and can iterate over them to a provided callback.
+class InstalledExtensions {
+ public:
+ explicit InstalledExtensions(ExtensionPrefs* prefs);
+
+ typedef Callback3<const std::string&,
+ const FilePath&,
+ Extension::Location>::Type Callback;
+
+ // Runs |callback| for each installed extension with the path to the
+ // version directory and the location.
+ void VisitInstalledExtensions(Callback *callback);
+
+ private:
+ // A copy of the extensions pref dictionary so that this can be passed
+ // around without a dependency on prefs.
+ DictionaryValue* extension_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstalledExtensions);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H