| 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" | |
| 10 #include "chrome/browser/media/router/media_router_feature.h" | 9 #include "chrome/browser/media/router/media_router_feature.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/toolbar/media_router_action_controller.h" | 12 #include "chrome/browser/ui/toolbar/media_router_action_controller.h" |
| 14 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 13 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.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 |
| 25 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory = | 24 base::LazyInstance<ComponentToolbarActionsFactory> lazy_factory = |
| 26 LAZY_INSTANCE_INITIALIZER; | 25 LAZY_INSTANCE_INITIALIZER; |
| 27 | 26 |
| 28 const char kCastExtensionId[] = "boadgeojelhgndaghljhdicfkmllpafd"; | |
| 29 const char kCastBetaExtensionId[] = "dliochdbjfkdbacpmhlcpmleaejidimm"; | |
| 30 | |
| 31 } // namespace | 27 } // namespace |
| 32 | 28 |
| 33 // static | 29 // static |
| 34 const char ComponentToolbarActionsFactory::kMediaRouterActionId[] = | 30 const char ComponentToolbarActionsFactory::kMediaRouterActionId[] = |
| 35 "media_router_action"; | 31 "media_router_action"; |
| 36 | 32 |
| 37 ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() {} | 33 ComponentToolbarActionsFactory::ComponentToolbarActionsFactory() {} |
| 38 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} | 34 ComponentToolbarActionsFactory::~ComponentToolbarActionsFactory() {} |
| 39 | 35 |
| 40 // static | 36 // static |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 72 |
| 77 NOTREACHED(); | 73 NOTREACHED(); |
| 78 return std::unique_ptr<ToolbarActionViewController>(); | 74 return std::unique_ptr<ToolbarActionViewController>(); |
| 79 } | 75 } |
| 80 | 76 |
| 81 // static | 77 // static |
| 82 void ComponentToolbarActionsFactory::SetTestingFactory( | 78 void ComponentToolbarActionsFactory::SetTestingFactory( |
| 83 ComponentToolbarActionsFactory* factory) { | 79 ComponentToolbarActionsFactory* factory) { |
| 84 testing_factory_ = factory; | 80 testing_factory_ = factory; |
| 85 } | 81 } |
| 86 | |
| 87 void ComponentToolbarActionsFactory::RegisterComponentMigrations( | |
| 88 extensions::ComponentMigrationHelper* helper) const { | |
| 89 helper->Register(kMediaRouterActionId, kCastExtensionId); | |
| 90 helper->Register(kMediaRouterActionId, kCastBetaExtensionId); | |
| 91 } | |
| 92 | |
| 93 void ComponentToolbarActionsFactory::HandleComponentMigrations( | |
| 94 extensions::ComponentMigrationHelper* helper, | |
| 95 Profile* profile) const { | |
| 96 if (media_router::MediaRouterEnabled(profile)) { | |
| 97 helper->OnFeatureEnabled(kMediaRouterActionId); | |
| 98 } else { | |
| 99 helper->OnFeatureDisabled(kMediaRouterActionId); | |
| 100 } | |
| 101 } | |
| 102 | |
| OLD | NEW |