Chromium Code Reviews| Index: chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc |
| diff --git a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc |
| index 8f64c079393ae0495e3344bb9b04ca3610bcdd75..88eb6ea36af7a62996d231cbff37fa4eece3f646 100644 |
| --- a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc |
| +++ b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc |
| @@ -20,8 +20,13 @@ base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory = |
| } // namespace |
| -ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() |
| - : num_component_actions_(-1) {} |
| +// static |
| +const char ComponentToolbarActionsFactory::kMediaRouterActionId[] = |
| + "media_router_action"; |
| +const char ComponentToolbarActionsFactory::kActionIdForTesting[] = |
| + "mock_action"; |
| + |
| +ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() {} |
| ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} |
| // static |
| @@ -29,6 +34,30 @@ ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { |
| return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); |
| } |
| +// static |
| +scoped_ptr<std::vector<std::string>> |
| +ComponentToolbarActionsFactory::GetComponentIds() { |
|
Devlin
2015/08/13 21:21:10
Wait, why is this a scoped_ptr?
apacible
2015/08/15 08:46:41
We switched it from returning a raw ptr to a scope
Devlin
2015/08/17 16:32:21
But why return a ptr at all? Why not just std::ve
apacible
2015/08/17 18:23:32
Talked offline, switched to vector.
|
| + scoped_ptr<std::vector<std::string>> component_ids( |
| + new std::vector<std::string>); |
| + |
| + // This is currently behind the extension-action-redesign flag, as it is |
| + // designed for the new toolbar. |
| + if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) |
| + return component_ids.Pass(); |
| + |
| + if (testing_factory_) { |
| + component_ids->push_back( |
| + ComponentToolbarActionsFactory::kActionIdForTesting); |
| + } else { |
| + if (switches::MediaRouterEnabled()) { |
|
Devlin
2015/08/13 21:21:10
isn't this always the same as
else if (switches::M
apacible
2015/08/15 08:46:41
Yes, updated.
|
| + component_ids->push_back( |
| + ComponentToolbarActionsFactory::kMediaRouterActionId); |
| + } |
| + } |
| + |
| + return component_ids.Pass(); |
| +} |
| + |
| ScopedVector<ToolbarActionViewController> |
| ComponentToolbarActionsFactory::GetComponentToolbarActions(Browser* browser) { |
| ScopedVector<ToolbarActionViewController> component_actions; |
| @@ -45,23 +74,12 @@ ComponentToolbarActionsFactory::GetComponentToolbarActions(Browser* browser) { |
| // should be okay. If this changes, we should rethink this design to have, |
| // e.g., RegisterChromeAction(). |
| -#if defined(ENABLE_MEDIA_ROUTER) |
|
Devlin
2015/08/13 21:21:10
Do we not need the #if defined blocks anymore? (F
apacible
2015/08/15 08:46:41
No, pkasting@ gave some good feedback about minimi
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - ::switches::kEnableMediaRouter)) { |
| + if (switches::MediaRouterEnabled()) |
| component_actions.push_back(new MediaRouterAction(browser)); |
| - } |
| -#endif |
| return component_actions.Pass(); |
| } |
| -int ComponentToolbarActionsFactory::GetNumComponentActions(Browser* browser) { |
| - if (num_component_actions_ == -1) |
| - num_component_actions_ = GetComponentToolbarActions(browser).size(); |
| - |
| - return num_component_actions_; |
| -} |
| - |
| // static |
| void ComponentToolbarActionsFactory::SetTestingFactory( |
| ComponentToolbarActionsFactory* factory) { |