Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / component_toolbar_actions_factory.cc
blob9764ea82f7e9745da08116abdb06e33073564e08
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
7 #include "base/lazy_instance.h"
8 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
9 #include "extensions/common/feature_switch.h"
11 namespace {
13 ComponentToolbarActionsFactory* testing_factory_ = nullptr;
15 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory =
16 LAZY_INSTANCE_INITIALIZER;
18 } // namespace
20 ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() {}
21 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {}
23 // static
24 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() {
25 return testing_factory_ ? testing_factory_ : &lazy_factory.Get();
28 ScopedVector<ToolbarActionViewController>
29 ComponentToolbarActionsFactory::GetComponentToolbarActions() {
30 ScopedVector<ToolbarActionViewController> component_actions;
32 // This is currently behind the extension-action-redesign flag, as it is
33 // designed for the new toolbar.
34 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled())
35 return component_actions.Pass();
37 // Add component toolbar actions here.
38 // This current design means that the ComponentToolbarActionsFactory is aware
39 // of all actions. Since we should *not* have an excessive amount of these
40 // (since each will have an action in the toolbar or overflow menu), this
41 // should be okay. If this changes, we should rethink this design to have,
42 // e.g., RegisterChromeAction().
44 return component_actions.Pass();
47 // static
48 void ComponentToolbarActionsFactory::SetTestingFactory(
49 ComponentToolbarActionsFactory* factory) {
50 testing_factory_ = factory;