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

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

Issue 1415333002: [Media Router] Add experiment control logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" 5 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "chrome/browser/media/router/media_router_feature.h"
9 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/toolbar/media_router_action.h"
12 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 12 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
msw 2015/10/29 18:41:13 nit: remove?
imcheng 2015/10/29 21:44:56 Done.
14 #include "extensions/common/feature_switch.h" 14 #include "extensions/common/feature_switch.h"
15 15
16 #if defined(ENABLE_MEDIA_ROUTER)
17 #include "chrome/browser/ui/toolbar/media_router_action.h"
18 #endif
19
16 namespace { 20 namespace {
17 21
18 ComponentToolbarActionsFactory* testing_factory_ = nullptr; 22 ComponentToolbarActionsFactory* testing_factory_ = nullptr;
19 23
20 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory = 24 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory =
21 LAZY_INSTANCE_INITIALIZER; 25 LAZY_INSTANCE_INITIALIZER;
22 26
23 } // namespace 27 } // namespace
24 28
25 // static 29 // static
(...skipping 10 matching lines...) Expand all
36 40
37 std::set<std::string> ComponentToolbarActionsFactory::GetComponentIds( 41 std::set<std::string> ComponentToolbarActionsFactory::GetComponentIds(
38 Profile* profile) { 42 Profile* profile) {
39 std::set<std::string> component_ids; 43 std::set<std::string> component_ids;
40 44
41 // This is currently behind the extension-action-redesign flag, as it is 45 // This is currently behind the extension-action-redesign flag, as it is
42 // designed for the new toolbar. 46 // designed for the new toolbar.
43 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) 47 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled())
44 return component_ids; 48 return component_ids;
45 49
46 if (switches::MediaRouterEnabled() && !profile->IsOffTheRecord()) 50 if (media_router::MediaRouterEnabled() && !profile->IsOffTheRecord())
47 component_ids.insert(kMediaRouterActionId); 51 component_ids.insert(kMediaRouterActionId);
48 52
49 return component_ids; 53 return component_ids;
50 } 54 }
51 55
52 scoped_ptr<ToolbarActionViewController> 56 scoped_ptr<ToolbarActionViewController>
53 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( 57 ComponentToolbarActionsFactory::GetComponentToolbarActionForId(
54 const std::string& id, 58 const std::string& id,
55 Browser* browser) { 59 Browser* browser) {
56 // This is currently behind the extension-action-redesign flag, as it is 60 // This is currently behind the extension-action-redesign flag, as it is
57 // designed for the new toolbar. 61 // designed for the new toolbar.
58 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); 62 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled());
59 DCHECK(GetComponentIds(browser->profile()).count(id)); 63 DCHECK(GetComponentIds(browser->profile()).count(id));
60 64
61 // Add component toolbar actions here. 65 // Add component toolbar actions here.
62 // This current design means that the ComponentToolbarActionsFactory is aware 66 // This current design means that the ComponentToolbarActionsFactory is aware
63 // of all actions. Since we should *not* have an excessive amount of these 67 // of all actions. Since we should *not* have an excessive amount of these
64 // (since each will have an action in the toolbar or overflow menu), this 68 // (since each will have an action in the toolbar or overflow menu), this
65 // should be okay. If this changes, we should rethink this design to have, 69 // should be okay. If this changes, we should rethink this design to have,
66 // e.g., RegisterChromeAction(). 70 // e.g., RegisterChromeAction().
71 #if defined(ENABLE_MEDIA_ROUTER)
67 if (id == kMediaRouterActionId) 72 if (id == kMediaRouterActionId)
68 return scoped_ptr<ToolbarActionViewController>( 73 return scoped_ptr<ToolbarActionViewController>(
69 new MediaRouterAction(browser)); 74 new MediaRouterAction(browser));
75 #endif // defined(ENABLE_MEDIA_ROUTER)
70 76
71 NOTREACHED(); 77 NOTREACHED();
72 return scoped_ptr<ToolbarActionViewController>(); 78 return scoped_ptr<ToolbarActionViewController>();
73 } 79 }
74 80
75 // static 81 // static
76 void ComponentToolbarActionsFactory::SetTestingFactory( 82 void ComponentToolbarActionsFactory::SetTestingFactory(
77 ComponentToolbarActionsFactory* factory) { 83 ComponentToolbarActionsFactory* factory) {
78 testing_factory_ = factory; 84 testing_factory_ = factory;
79 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698