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

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

Issue 415813003: Improve extension icon prediction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor changes Created 6 years, 4 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) 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
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "chrome/common/extensions/api/extension_action/action_info.h"
12 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
13 #include "extensions/browser/extension_registry_observer.h" 14 #include "extensions/browser/extension_registry_observer.h"
14 15
15 class ExtensionAction; 16 class ExtensionAction;
16 class Profile; 17 class Profile;
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 class Extension; 21 class Extension;
21 class ExtensionRegistry; 22 class ExtensionRegistry;
(...skipping 12 matching lines...) Expand all
34 35
35 // Retrieves the page action, or browser action for |extension|. 36 // Retrieves the page action, or browser action for |extension|.
36 // If the result is not NULL, it remains valid until the extension is 37 // If the result is not NULL, it remains valid until the extension is
37 // unloaded. 38 // unloaded.
38 ExtensionAction* GetPageAction(const extensions::Extension& extension) const; 39 ExtensionAction* GetPageAction(const extensions::Extension& extension) const;
39 ExtensionAction* GetBrowserAction( 40 ExtensionAction* GetBrowserAction(
40 const extensions::Extension& extension) const; 41 const extensions::Extension& extension) const;
41 ExtensionAction* GetSystemIndicator( 42 ExtensionAction* GetSystemIndicator(
42 const extensions::Extension& extension) const; 43 const extensions::Extension& extension) const;
43 44
45 // Gets the best fit ExtensionAction for the given |extension|. This takes
46 // into account |extension|'s browser or page actions, if any, along with its
47 // name and any declared icons.
48 scoped_ptr<ExtensionAction> GetBestFitAction(
49 const extensions::Extension& extension,
50 extensions::ActionInfo::Type type) const;
51
44 private: 52 private:
45 // Implement ExtensionRegistryObserver. 53 // Implement ExtensionRegistryObserver.
46 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, 54 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context,
47 const Extension* extension, 55 const Extension* extension,
48 UnloadedExtensionInfo::Reason reason) 56 UnloadedExtensionInfo::Reason reason)
49 OVERRIDE; 57 OVERRIDE;
50 58
51 Profile* profile_; 59 Profile* profile_;
52 60
53 // Listen to extension unloaded notifications. 61 // Listen to extension unloaded notifications.
54 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 62 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
55 extension_registry_observer_; 63 extension_registry_observer_;
56 64
57 // Keyed by Extension ID. These maps are populated lazily when their 65 // Keyed by Extension ID. These maps are populated lazily when their
58 // ExtensionAction is first requested, and the entries are removed when the 66 // ExtensionAction is first requested, and the entries are removed when the
59 // extension is unloaded. Not every extension has a page action or browser 67 // extension is unloaded. Not every extension has a page action or browser
60 // action. 68 // action.
61 typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap; 69 typedef std::map<std::string, linked_ptr<ExtensionAction> > ExtIdToActionMap;
62 mutable ExtIdToActionMap page_actions_; 70 mutable ExtIdToActionMap page_actions_;
63 mutable ExtIdToActionMap browser_actions_; 71 mutable ExtIdToActionMap browser_actions_;
64 mutable ExtIdToActionMap system_indicators_; 72 mutable ExtIdToActionMap system_indicators_;
65 }; 73 };
66 74
67 } // namespace extensions 75 } // namespace extensions
68 76
69 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_ 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698