| 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/media_router_action_controller.h" |
| 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 14 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.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; |
| (...skipping 14 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 (media_router::MediaRouterEnabled(profile) && |
| 49 MediaRouterActionController::IsActionShownByPolicy(profile)) { |
| 50 component_ids.insert(kMediaRouterActionId); |
| 51 } |
| 52 |
| 47 return component_ids; | 53 return component_ids; |
| 48 } | 54 } |
| 49 | 55 |
| 50 std::unique_ptr<ToolbarActionViewController> | 56 std::unique_ptr<ToolbarActionViewController> |
| 51 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( | 57 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( |
| 52 const std::string& id, | 58 const std::string& id, |
| 53 Browser* browser, | 59 Browser* browser, |
| 54 ToolbarActionsBar* bar) { | 60 ToolbarActionsBar* bar) { |
| 55 // This is currently behind the extension-action-redesign flag, as it is | 61 // This is currently behind the extension-action-redesign flag, as it is |
| 56 // designed for the new toolbar. | 62 // designed for the new toolbar. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 87 void ComponentToolbarActionsFactory::HandleComponentMigrations( | 93 void ComponentToolbarActionsFactory::HandleComponentMigrations( |
| 88 extensions::ComponentMigrationHelper* helper, | 94 extensions::ComponentMigrationHelper* helper, |
| 89 Profile* profile) const { | 95 Profile* profile) const { |
| 90 if (media_router::MediaRouterEnabled(profile)) { | 96 if (media_router::MediaRouterEnabled(profile)) { |
| 91 helper->OnFeatureEnabled(kMediaRouterActionId); | 97 helper->OnFeatureEnabled(kMediaRouterActionId); |
| 92 } else { | 98 } else { |
| 93 helper->OnFeatureDisabled(kMediaRouterActionId); | 99 helper->OnFeatureDisabled(kMediaRouterActionId); |
| 94 } | 100 } |
| 95 } | 101 } |
| 96 | 102 |
| OLD | NEW |