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