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/extensions/component_migration_helper.h" | 9 #include "chrome/browser/extensions/component_migration_helper.h" |
10 #include "chrome/browser/media/router/media_router_feature.h" | 10 #include "chrome/browser/media/router/media_router_feature.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
14 #include "chrome/common/pref_names.h" | |
15 #include "extensions/common/feature_switch.h" | 14 #include "extensions/common/feature_switch.h" |
16 | 15 |
17 #if defined(ENABLE_MEDIA_ROUTER) | 16 #if defined(ENABLE_MEDIA_ROUTER) |
18 #include "chrome/browser/ui/toolbar/media_router_action.h" | 17 #include "chrome/browser/ui/toolbar/media_router_action.h" |
19 #endif | 18 #endif |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
23 ComponentToolbarActionsFactory* testing_factory_ = nullptr; | 22 ComponentToolbarActionsFactory* testing_factory_ = nullptr; |
24 | 23 |
(...skipping 13 matching lines...) Expand all Loading... |
38 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} | 37 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} |
39 | 38 |
40 // static | 39 // static |
41 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { | 40 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { |
42 return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); | 41 return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); |
43 } | 42 } |
44 | 43 |
45 std::set<std::string> ComponentToolbarActionsFactory::GetInitialComponentIds( | 44 std::set<std::string> ComponentToolbarActionsFactory::GetInitialComponentIds( |
46 Profile* profile) { | 45 Profile* profile) { |
47 std::set<std::string> component_ids; | 46 std::set<std::string> component_ids; |
48 #if defined(ENABLE_MEDIA_ROUTER) | |
49 if (profile->GetPrefs()->GetBoolean(prefs::kMediaRouterAlwaysShowActionIcon)) | |
50 component_ids.insert(kMediaRouterActionId); | |
51 #endif // defined(ENABLE_MEDIA_ROUTER) | |
52 return component_ids; | 47 return component_ids; |
53 } | 48 } |
54 | 49 |
55 std::unique_ptr<ToolbarActionViewController> | 50 std::unique_ptr<ToolbarActionViewController> |
56 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( | 51 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( |
57 const std::string& id, | 52 const std::string& id, |
58 Browser* browser, | 53 Browser* browser, |
59 ToolbarActionsBar* bar) { | 54 ToolbarActionsBar* bar) { |
60 // This is currently behind the extension-action-redesign flag, as it is | 55 // This is currently behind the extension-action-redesign flag, as it is |
61 // designed for the new toolbar. | 56 // designed for the new toolbar. |
(...skipping 29 matching lines...) Expand all Loading... |
91 | 86 |
92 void ComponentToolbarActionsFactory::HandleComponentMigrations( | 87 void ComponentToolbarActionsFactory::HandleComponentMigrations( |
93 extensions::ComponentMigrationHelper* helper, | 88 extensions::ComponentMigrationHelper* helper, |
94 Profile* profile) const { | 89 Profile* profile) const { |
95 if (media_router::MediaRouterEnabled(profile)) { | 90 if (media_router::MediaRouterEnabled(profile)) { |
96 helper->OnFeatureEnabled(kMediaRouterActionId); | 91 helper->OnFeatureEnabled(kMediaRouterActionId); |
97 } else { | 92 } else { |
98 helper->OnFeatureDisabled(kMediaRouterActionId); | 93 helper->OnFeatureDisabled(kMediaRouterActionId); |
99 } | 94 } |
100 } | 95 } |
| 96 |
OLD | NEW |