Index: chrome/browser/ui/views/toolbar/chrome_actions_registry.cc |
diff --git a/chrome/browser/ui/views/toolbar/chrome_actions_registry.cc b/chrome/browser/ui/views/toolbar/chrome_actions_registry.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc3c270e45392d962b1ddb86a5b541a6dc865391 |
--- /dev/null |
+++ b/chrome/browser/ui/views/toolbar/chrome_actions_registry.cc |
@@ -0,0 +1,41 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/views/toolbar/chrome_actions_registry.h" |
+ |
+#include "chrome/browser/ui/views/toolbar/toolbar_action_view_controller.h" |
+#include "extensions/common/feature_switch.h" |
+ |
+namespace { |
+ChromeActionsRegistry::FactoryFunction testing_factory_function = nullptr; |
+} |
+ |
+// static |
+ScopedVector<ToolbarActionViewController> |
+ChromeActionsRegistry::GetChromeActions() { |
+ if (testing_factory_function != nullptr) |
+ return testing_factory_function(); |
+ |
+ ScopedVector<ToolbarActionViewController> chrome_actions; |
+ |
+ // 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 chrome_actions.Pass(); |
+ |
+ // Add chrome actions here. |
+ // This current design means that the ChromeActionsRegistry is aware of all |
+ // chrome actions (as opposed to an interface that had, e.g., |
+ // RegisterChromeAction()). This is because the latter requires a persistent |
+ // object, and because we should *not* have an excessive amount of these, as |
+ // each will have an action in the toolbar (or overflow menu). |
+ |
+ return chrome_actions.Pass(); |
+} |
+ |
+// static |
+void ChromeActionsRegistry::SetTestingChromeActionsFunction( |
+ FactoryFunction function) { |
+ testing_factory_function = function; |
+} |