Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc

Issue 1241063003: Support Component Actions in the toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch GetComponentActionId to unix_hacker_style. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..62b05a32da14aca1395aeff07a133d17cc57227d 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,26 @@ ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() {
return testing_factory_ ? testing_factory_ : &lazy_factory.Get();
}
+// static
+std::vector<std::string> ComponentToolbarActionsFactory::GetComponentIds() {
+ std::vector<std::string> component_ids;
+
+ // 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;
+
+ if (testing_factory_) {
+ component_ids.push_back(
+ ComponentToolbarActionsFactory::kActionIdForTesting);
+ } else if (switches::MediaRouterEnabled()) {
+ component_ids.push_back(
+ ComponentToolbarActionsFactory::kMediaRouterActionId);
+ }
+
+ return component_ids;
+}
+
ScopedVector<ToolbarActionViewController>
ComponentToolbarActionsFactory::GetComponentToolbarActions(Browser* browser) {
ScopedVector<ToolbarActionViewController> component_actions;
@@ -45,23 +70,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)
- 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) {
« no previous file with comments | « chrome/browser/ui/toolbar/component_toolbar_actions_factory.h ('k') | chrome/browser/ui/toolbar/media_router_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698