OLD | NEW |
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/media/router/media_router_feature.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 if (!profile->IsOffTheRecord() && media_router::MediaRouterEnabled(profile)) | 49 if (!profile->IsOffTheRecord() && media_router::MediaRouterEnabled(profile)) |
50 component_ids.insert(kMediaRouterActionId); | 50 component_ids.insert(kMediaRouterActionId); |
51 | 51 |
52 return component_ids; | 52 return component_ids; |
53 } | 53 } |
54 | 54 |
55 scoped_ptr<ToolbarActionViewController> | 55 scoped_ptr<ToolbarActionViewController> |
56 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( | 56 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( |
57 const std::string& id, | 57 const std::string& id, |
58 Browser* browser) { | 58 Browser* browser, |
| 59 ToolbarActionsBar* bar) { |
59 // 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 |
60 // designed for the new toolbar. | 61 // designed for the new toolbar. |
61 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); | 62 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); |
62 DCHECK(GetInitialComponentIds(browser->profile()).count(id)); | 63 DCHECK(GetInitialComponentIds(browser->profile()).count(id)); |
63 | 64 |
64 // Add component toolbar actions here. | 65 // Add component toolbar actions here. |
65 // This current design means that the ComponentToolbarActionsFactory is aware | 66 // This current design means that the ComponentToolbarActionsFactory is aware |
66 // 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 |
67 // (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 |
68 // 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, |
69 // e.g., RegisterChromeAction(). | 70 // e.g., RegisterChromeAction(). |
70 #if defined(ENABLE_MEDIA_ROUTER) | 71 #if defined(ENABLE_MEDIA_ROUTER) |
71 if (id == kMediaRouterActionId) | 72 if (id == kMediaRouterActionId) |
72 return scoped_ptr<ToolbarActionViewController>( | 73 return scoped_ptr<ToolbarActionViewController>( |
73 new MediaRouterAction(browser)); | 74 new MediaRouterAction(browser, bar)); |
74 #endif // defined(ENABLE_MEDIA_ROUTER) | 75 #endif // defined(ENABLE_MEDIA_ROUTER) |
75 | 76 |
76 NOTREACHED(); | 77 NOTREACHED(); |
77 return scoped_ptr<ToolbarActionViewController>(); | 78 return scoped_ptr<ToolbarActionViewController>(); |
78 } | 79 } |
79 | 80 |
80 // static | 81 // static |
81 void ComponentToolbarActionsFactory::SetTestingFactory( | 82 void ComponentToolbarActionsFactory::SetTestingFactory( |
82 ComponentToolbarActionsFactory* factory) { | 83 ComponentToolbarActionsFactory* factory) { |
83 testing_factory_ = factory; | 84 testing_factory_ = factory; |
84 } | 85 } |
OLD | NEW |