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

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: Fix tests and indentation changes. 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..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) {

Powered by Google App Engine
This is Rietveld 408576698