OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
14 | 14 |
15 class Browser; | 15 class Browser; |
16 class ExtensionService; | |
16 class Profile; | 17 class Profile; |
17 class ToolbarActionViewController; | 18 class ToolbarActionViewController; |
18 | 19 |
20 namespace extensions { | |
21 class ExtensionRegistry; | |
22 } | |
23 | |
19 // The registry for all component toolbar actions. Component toolbar actions | 24 // The registry for all component toolbar actions. Component toolbar actions |
20 // are actions that live in the toolbar (like extension actions), but are | 25 // are actions that live in the toolbar (like extension actions), but are |
21 // components of chrome, such as ChromeCast. | 26 // components of chrome, such as ChromeCast. |
22 class ComponentToolbarActionsFactory { | 27 class ComponentToolbarActionsFactory { |
23 public: | 28 public: |
24 // Component action IDs. | 29 // Extension and component action IDs. |
30 static const char kCastBetaExtensionId[]; | |
31 static const char kCastExtensionId[]; | |
25 static const char kMediaRouterActionId[]; | 32 static const char kMediaRouterActionId[]; |
26 | 33 |
27 ComponentToolbarActionsFactory(); | 34 ComponentToolbarActionsFactory(); |
28 virtual ~ComponentToolbarActionsFactory(); | 35 virtual ~ComponentToolbarActionsFactory(); |
29 | 36 |
30 static ComponentToolbarActionsFactory* GetInstance(); | 37 static ComponentToolbarActionsFactory* GetInstance(); |
31 | 38 |
32 // Returns a vector of IDs of the component actions. | 39 // Returns a vector of IDs of the component actions. |
33 virtual std::set<std::string> GetInitialComponentIds(Profile* profile); | 40 virtual std::set<std::string> GetInitialComponentIds(Profile* profile); |
34 | 41 |
35 // Returns a collection of controllers for component actions. Declared | 42 // Returns a collection of controllers for component actions. Declared |
36 // virtual for testing. | 43 // virtual for testing. |
37 virtual std::unique_ptr<ToolbarActionViewController> | 44 virtual std::unique_ptr<ToolbarActionViewController> |
38 GetComponentToolbarActionForId(const std::string& id, | 45 GetComponentToolbarActionForId(const std::string& id, |
39 Browser* browser, | 46 Browser* browser, |
40 ToolbarActionsBar* bar); | 47 ToolbarActionsBar* bar); |
41 | 48 |
49 // Unloads extensions that were migrated to component actions and therefore | |
50 // are no longer needed. | |
51 virtual void UnloadMigratedExtensions( | |
Devlin
2017/02/14 23:58:43
Does this need to be virtual?
takumif
2017/02/15 18:13:46
No. Removed.
| |
52 ExtensionService* service, | |
53 extensions::ExtensionRegistry* registry); | |
54 | |
42 // Sets the factory to use for testing purposes. | 55 // Sets the factory to use for testing purposes. |
43 // Ownership remains with the caller. | 56 // Ownership remains with the caller. |
44 static void SetTestingFactory(ComponentToolbarActionsFactory* factory); | 57 static void SetTestingFactory(ComponentToolbarActionsFactory* factory); |
45 | 58 |
46 private: | 59 private: |
60 // Unloads an extension if it is active. | |
61 void UnloadExtension(ExtensionService* service, | |
62 extensions::ExtensionRegistry* registry, | |
63 const std::string& extension_id); | |
64 | |
47 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory); | 65 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory); |
48 }; | 66 }; |
49 | 67 |
50 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ | 68 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ |
OLD | NEW |