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..82e2fe9298c6000e69b0ff0c0ef283741aea2251 100644 |
--- a/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc |
+++ b/chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc |
@@ -20,6 +20,12 @@ base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory = |
} // namespace |
+// static |
+const char ComponentToolbarActionsFactory::kMediaRouterActionId[] = |
+ "media_router_action"; |
+const char ComponentToolbarActionsFactory::kActionIdForTesting[] = |
+ "mock_action"; |
+ |
ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() |
: num_component_actions_(-1) {} |
ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} |
@@ -29,6 +35,32 @@ ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { |
return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); |
} |
+// static |
+scoped_ptr<std::vector<std::string>> |
+ComponentToolbarActionsFactory::GetComponentIds() { |
Peter Kasting
2015/08/11 19:10:49
It looks like this only ever returns 0 or 1 elemen
apacible
2015/08/12 05:26:44
In the future, we'll be returning more than one el
Peter Kasting
2015/08/12 07:13:45
OK. I still think returning the vector by copy mi
apacible
2015/08/15 08:46:40
Acknowledged.
|
+ 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 |
Peter Kasting
2015/08/11 19:10:49
Nit: Comments should have trailing periods.
apacible
2015/08/12 05:26:44
Done.
|
+ if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) |
+ return component_ids.Pass(); |
+ |
+ if (testing_factory_) { |
+ component_ids->push_back( |
+ ComponentToolbarActionsFactory::kActionIdForTesting); |
+ } else { |
+#if defined(ENABLE_MEDIA_ROUTER) |
+ if (switches::MediaRouterEnabled()) { |
+ component_ids->push_back( |
+ ComponentToolbarActionsFactory::kMediaRouterActionId); |
+ } |
+#endif // ENABLE_MEDIA_ROUTER |
+ } |
+ |
+ return component_ids.Pass(); |
+} |
+ |
ScopedVector<ToolbarActionViewController> |
ComponentToolbarActionsFactory::GetComponentToolbarActions(Browser* browser) { |
ScopedVector<ToolbarActionViewController> component_actions; |
@@ -46,18 +78,16 @@ ComponentToolbarActionsFactory::GetComponentToolbarActions(Browser* browser) { |
// e.g., RegisterChromeAction(). |
#if defined(ENABLE_MEDIA_ROUTER) |
- 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) { |
+int ComponentToolbarActionsFactory::GetNumComponentActions() { |
if (num_component_actions_ == -1) |
Peter Kasting
2015/08/11 19:10:49
This member variable seems like over-optimization.
apacible
2015/08/12 05:26:44
Eliminated GetNumComponentActions().
|
- num_component_actions_ = GetComponentToolbarActions(browser).size(); |
+ num_component_actions_ = GetComponentIds()->size(); |
return num_component_actions_; |
} |