diff options
author | jyasskin@chromium.org <jyasskin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-08 19:16:44 +0000 |
---|---|---|
committer | jyasskin@chromium.org <jyasskin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-08 19:16:44 +0000 |
commit | 0f34d9082e0b16e83d3e4c8fbf296a09509e4702 (patch) | |
tree | e7f63013bfa2e4a30f94e03d5082bcfe5090a701 /chrome/browser/extensions/extension_action_manager.h | |
parent | 9bab0bbdf66d73e5a7ec81e9ef18f2be2387499c (diff) | |
download | chromium_src-0f34d9082e0b16e83d3e4c8fbf296a09509e4702.zip chromium_src-0f34d9082e0b16e83d3e4c8fbf296a09509e4702.tar.gz chromium_src-0f34d9082e0b16e83d3e4c8fbf296a09509e4702.tar.bz2 |
Move ownership of ExtensionAction into ExtensionSystem.
ExtensionActions will be created by ExtensionActionManager during the
EXTENSION_LOADED notification and destroyed during EXTENSION_UNLOADED. In this
change, the ExtensionActionManager inserts pointers to the ExtensionActions into
their Extension, but those pointers will go away in the next refactoring step.
This is part of a 4-part refactoring to clean up ExtensionAction icon handling.
The subsequent parts are:
2) Change ExtensionAction accesses from using Extension::*action() to using
ExtensionSystem.
3) Move ExtensionAction from common/ to browser/
4) Make the icon-loading and -caching classes into ExtensionAction methods.
BUG=153463
Review URL: https://chromiumcodereview.appspot.com/11032013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_action_manager.h')
-rw-r--r-- | chrome/browser/extensions/extension_action_manager.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_action_manager.h b/chrome/browser/extensions/extension_action_manager.h new file mode 100644 index 0000000..4219dec --- /dev/null +++ b/chrome/browser/extensions/extension_action_manager.h @@ -0,0 +1,54 @@ +// Copyright (c) 2012 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_ACTION_MANAGER_H_ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ + +#include <map> +#include <string> + +#include "base/memory/linked_ptr.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" + +class ExtensionAction; +class Profile; + +namespace extensions { + +class Extension; + +// Owns the ExtensionActions associated with each extension. These actions live +// while an extension is loaded and are destroyed on unload. +class ExtensionActionManager : public content::NotificationObserver { + public: + explicit ExtensionActionManager(Profile* profile); + virtual ~ExtensionActionManager(); + + // Called during ExtensionSystem::Shutdown(), when the associated + // Profile is going to be destroyed. + void Shutdown(); + + private: + // Implement content::NotificationObserver. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + + Profile* const profile_; + content::NotificationRegistrar registrar_; + + // Keyed by Extension ID. These maps are populated when the extension is + // loaded, and the entries are removed when the extension is unloaded. Not + // every extension has a page action or browser action, but all have a script + // badge. + typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap; + ExtIdToActionMap page_actions_; + ExtIdToActionMap browser_actions_; + ExtIdToActionMap script_badges_; +}; + +} + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ |