OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ACTION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // Retrieves the page action, or browser action for |extension|. | 35 // Retrieves the page action, or browser action for |extension|. |
36 // If the result is not NULL, it remains valid until the extension is | 36 // If the result is not NULL, it remains valid until the extension is |
37 // unloaded. | 37 // unloaded. |
38 ExtensionAction* GetPageAction(const extensions::Extension& extension) const; | 38 ExtensionAction* GetPageAction(const extensions::Extension& extension) const; |
39 ExtensionAction* GetBrowserAction( | 39 ExtensionAction* GetBrowserAction( |
40 const extensions::Extension& extension) const; | 40 const extensions::Extension& extension) const; |
41 ExtensionAction* GetSystemIndicator( | 41 ExtensionAction* GetSystemIndicator( |
42 const extensions::Extension& extension) const; | 42 const extensions::Extension& extension) const; |
43 | 43 |
| 44 // Gets the best fit ExtensionAction for the given |extension|. |
| 45 // Excludes system indicators. |
| 46 ExtensionAction* GetBestFitAction( |
| 47 const extensions::Extension& extension) const; |
| 48 |
44 private: | 49 private: |
45 // Implement ExtensionRegistryObserver. | 50 // Implement ExtensionRegistryObserver. |
46 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, | 51 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, |
47 const Extension* extension, | 52 const Extension* extension, |
48 UnloadedExtensionInfo::Reason reason) | 53 UnloadedExtensionInfo::Reason reason) |
49 OVERRIDE; | 54 OVERRIDE; |
50 | 55 |
51 Profile* profile_; | 56 Profile* profile_; |
52 | 57 |
53 // Listen to extension unloaded notifications. | 58 // Listen to extension unloaded notifications. |
54 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 59 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
55 extension_registry_observer_; | 60 extension_registry_observer_; |
56 | 61 |
57 // Keyed by Extension ID. These maps are populated lazily when their | 62 // Keyed by Extension ID. These maps are populated lazily when their |
58 // ExtensionAction is first requested, and the entries are removed when the | 63 // ExtensionAction is first requested, and the entries are removed when the |
59 // extension is unloaded. Not every extension has a page action or browser | 64 // extension is unloaded. Not every extension has a page action or browser |
60 // action. | 65 // action. |
61 typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap; | 66 typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap; |
62 mutable ExtIdToActionMap page_actions_; | 67 mutable ExtIdToActionMap page_actions_; |
63 mutable ExtIdToActionMap browser_actions_; | 68 mutable ExtIdToActionMap browser_actions_; |
64 mutable ExtIdToActionMap system_indicators_; | 69 mutable ExtIdToActionMap system_indicators_; |
65 }; | 70 }; |
66 | 71 |
67 } // namespace extensions | 72 } // namespace extensions |
68 | 73 |
69 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ | 74 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ |
OLD | NEW |