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

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: Rebase 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"
12 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
13 #include "extensions/common/feature_switch.h"
14
15 #if defined(ENABLE_MEDIA_ROUTER)
11 #include "chrome/browser/ui/toolbar/media_router_action.h" 16 #include "chrome/browser/ui/toolbar/media_router_action.h"
12 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 17 #endif
13 #include "chrome/common/chrome_switches.h"
14 #include "extensions/common/feature_switch.h"
15 18
16 namespace { 19 namespace {
17 20
18 ComponentToolbarActionsFactory* testing_factory_ = nullptr; 21 ComponentToolbarActionsFactory* testing_factory_ = nullptr;
19 22
20 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory = 23 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory =
21 LAZY_INSTANCE_INITIALIZER; 24 LAZY_INSTANCE_INITIALIZER;
22 25
23 } // namespace 26 } // namespace
24 27
(...skipping 11 matching lines...) Expand all
36 39
37 std::set<std::string> ComponentToolbarActionsFactory::GetComponentIds( 40 std::set<std::string> ComponentToolbarActionsFactory::GetComponentIds(
38 Profile* profile) { 41 Profile* profile) {
39 std::set<std::string> component_ids; 42 std::set<std::string> component_ids;
40 43
41 // This is currently behind the extension-action-redesign flag, as it is 44 // This is currently behind the extension-action-redesign flag, as it is
42 // designed for the new toolbar. 45 // designed for the new toolbar.
43 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) 46 if (!extensions::FeatureSwitch::extension_action_redesign()->IsEnabled())
44 return component_ids; 47 return component_ids;
45 48
46 if (switches::MediaRouterEnabled() && !profile->IsOffTheRecord()) 49 if (media_router::MediaRouterEnabled() && !profile->IsOffTheRecord())
47 component_ids.insert(kMediaRouterActionId); 50 component_ids.insert(kMediaRouterActionId);
48 51
49 return component_ids; 52 return component_ids;
50 } 53 }
51 54
52 scoped_ptr<ToolbarActionViewController> 55 scoped_ptr<ToolbarActionViewController>
53 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( 56 ComponentToolbarActionsFactory::GetComponentToolbarActionForId(
54 const std::string& id, 57 const std::string& id,
55 Browser* browser) { 58 Browser* browser) {
56 // This is currently behind the extension-action-redesign flag, as it is 59 // This is currently behind the extension-action-redesign flag, as it is
57 // designed for the new toolbar. 60 // designed for the new toolbar.
58 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); 61 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled());
59 DCHECK(GetComponentIds(browser->profile()).count(id)); 62 DCHECK(GetComponentIds(browser->profile()).count(id));
60 63
61 // Add component toolbar actions here. 64 // Add component toolbar actions here.
62 // This current design means that the ComponentToolbarActionsFactory is aware 65 // This current design means that the ComponentToolbarActionsFactory is aware
63 // of all actions. Since we should *not* have an excessive amount of these 66 // 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 67 // (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, 68 // should be okay. If this changes, we should rethink this design to have,
66 // e.g., RegisterChromeAction(). 69 // e.g., RegisterChromeAction().
70 #if defined(ENABLE_MEDIA_ROUTER)
67 if (id == kMediaRouterActionId) 71 if (id == kMediaRouterActionId)
68 return scoped_ptr<ToolbarActionViewController>( 72 return scoped_ptr<ToolbarActionViewController>(
69 new MediaRouterAction(browser)); 73 new MediaRouterAction(browser));
74 #endif // defined(ENABLE_MEDIA_ROUTER)
70 75
71 NOTREACHED(); 76 NOTREACHED();
72 return scoped_ptr<ToolbarActionViewController>(); 77 return scoped_ptr<ToolbarActionViewController>();
73 } 78 }
74 79
75 // static 80 // static
76 void ComponentToolbarActionsFactory::SetTestingFactory( 81 void ComponentToolbarActionsFactory::SetTestingFactory(
77 ComponentToolbarActionsFactory* factory) { 82 ComponentToolbarActionsFactory* factory) {
78 testing_factory_ = factory; 83 testing_factory_ = factory;
79 } 84 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/app_menu_model.cc ('k') | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698