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 void UnloadMigratedExtensions(ExtensionService* service, |
| 52 extensions::ExtensionRegistry* registry); |
| 53 |
42 // Sets the factory to use for testing purposes. | 54 // Sets the factory to use for testing purposes. |
43 // Ownership remains with the caller. | 55 // Ownership remains with the caller. |
44 static void SetTestingFactory(ComponentToolbarActionsFactory* factory); | 56 static void SetTestingFactory(ComponentToolbarActionsFactory* factory); |
45 | 57 |
46 private: | 58 private: |
| 59 // Unloads an extension if it is active. |
| 60 void UnloadExtension(ExtensionService* service, |
| 61 extensions::ExtensionRegistry* registry, |
| 62 const std::string& extension_id); |
| 63 |
47 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory); | 64 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactory); |
48 }; | 65 }; |
49 | 66 |
50 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ | 67 #endif // CHROME_BROWSER_UI_TOOLBAR_COMPONENT_TOOLBAR_ACTIONS_FACTORY_H_ |
OLD | NEW |