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 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" | 5 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "chrome/browser/ui/toolbar/media_router_action.h" | 9 #include "chrome/browser/ui/toolbar/media_router_action.h" |
10 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() | 23 ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() |
24 : num_component_actions_(-1) {} | 24 : num_component_actions_(-1) {} |
25 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} | 25 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} |
26 | 26 |
27 // static | 27 // static |
28 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { | 28 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { |
29 return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); | 29 return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); |
30 } | 30 } |
31 | 31 |
32 ScopedVector<ToolbarActionViewController> | 32 ScopedVector<ToolbarActionViewController> |
33 ComponentToolbarActionsFactory::GetComponentToolbarActions() { | 33 ComponentToolbarActionsFactory::GetComponentToolbarActions(Browser* browser) { |
34 ScopedVector<ToolbarActionViewController> component_actions; | 34 ScopedVector<ToolbarActionViewController> component_actions; |
35 | 35 |
36 // This is currently behind the extension-action-redesign flag, as it is | 36 // This is currently behind the extension-action-redesign flag, as it is |
37 // designed for the new toolbar. | 37 // designed for the new toolbar. |
38 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) | 38 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) |
39 return component_actions.Pass(); | 39 return component_actions.Pass(); |
40 | 40 |
41 // Add component toolbar actions here. | 41 // Add component toolbar actions here. |
42 // This current design means that the ComponentToolbarActionsFactory is aware | 42 // This current design means that the ComponentToolbarActionsFactory is aware |
43 // of all actions. Since we should *not* have an excessive amount of these | 43 // of all actions. Since we should *not* have an excessive amount of these |
44 // (since each will have an action in the toolbar or overflow menu), this | 44 // (since each will have an action in the toolbar or overflow menu), this |
45 // should be okay. If this changes, we should rethink this design to have, | 45 // should be okay. If this changes, we should rethink this design to have, |
46 // e.g., RegisterChromeAction(). | 46 // e.g., RegisterChromeAction(). |
47 | 47 |
48 #if defined(ENABLE_MEDIA_ROUTER) | 48 #if defined(ENABLE_MEDIA_ROUTER) |
49 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 49 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
50 ::switches::kEnableMediaRouter)) { | 50 ::switches::kEnableMediaRouter)) { |
51 component_actions.push_back(new MediaRouterAction()); | 51 component_actions.push_back(new MediaRouterAction(browser)); |
52 } | 52 } |
53 #endif | 53 #endif |
54 | 54 |
55 return component_actions.Pass(); | 55 return component_actions.Pass(); |
56 } | 56 } |
57 | 57 |
58 int ComponentToolbarActionsFactory::GetNumComponentActions() { | 58 int ComponentToolbarActionsFactory::GetNumComponentActions(Browser* browser) { |
59 if (num_component_actions_ == -1) | 59 if (num_component_actions_ == -1) |
60 num_component_actions_ = GetComponentToolbarActions().size(); | 60 num_component_actions_ = GetComponentToolbarActions(browser).size(); |
61 | 61 |
62 return num_component_actions_; | 62 return num_component_actions_; |
63 } | 63 } |
64 | 64 |
65 // static | 65 // static |
66 void ComponentToolbarActionsFactory::SetTestingFactory( | 66 void ComponentToolbarActionsFactory::SetTestingFactory( |
67 ComponentToolbarActionsFactory* factory) { | 67 ComponentToolbarActionsFactory* factory) { |
68 testing_factory_ = factory; | 68 testing_factory_ = factory; |
69 } | 69 } |
OLD | NEW |