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

Side by Side Diff: chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc

Issue 661493004: Add infrastructure for Chrome Actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
6
7 #include "base/lazy_instance.h"
8 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
9 #include "extensions/common/feature_switch.h"
10
11 namespace {
12
13 ComponentToolbarActionsFactory* testing_factory_ = nullptr;
14
15 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory =
16 LAZY_INSTANCE_INITIALIZER;
17
18 } // namespace
19
20 ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() {}
21 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {}
22
23 // static
24 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() {
25 return testing_factory_ ? testing_factory_ : &lazy_factory.Get();
26 }
27
28 ScopedVector<ToolbarActionViewController>
29 ComponentToolbarActionsFactory::GetComponentToolbarActions() {
30 ScopedVector<ToolbarActionViewController> component_actions;
31
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();
36
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().
43
44 return component_actions.Pass();
45 }
46
47 // static
48 void ComponentToolbarActionsFactory::SetTestingFactory(
49 ComponentToolbarActionsFactory* factory) {
50 testing_factory_ = factory;
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698