| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { | 40 ComponentToolbarActionsFactory* ComponentToolbarActionsFactory::GetInstance() { |
| 41 return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); | 41 return testing_factory_ ? testing_factory_ : &lazy_factory.Get(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 std::set<std::string> ComponentToolbarActionsFactory::GetInitialComponentIds( | 44 std::set<std::string> ComponentToolbarActionsFactory::GetInitialComponentIds( |
| 45 Profile* profile) { | 45 Profile* profile) { |
| 46 std::set<std::string> component_ids; | 46 std::set<std::string> component_ids; |
| 47 return component_ids; | 47 return component_ids; |
| 48 } | 48 } |
| 49 | 49 |
| 50 scoped_ptr<ToolbarActionViewController> | 50 std::unique_ptr<ToolbarActionViewController> |
| 51 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( | 51 ComponentToolbarActionsFactory::GetComponentToolbarActionForId( |
| 52 const std::string& id, | 52 const std::string& id, |
| 53 Browser* browser, | 53 Browser* browser, |
| 54 ToolbarActionsBar* bar) { | 54 ToolbarActionsBar* bar) { |
| 55 // 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 |
| 56 // designed for the new toolbar. | 56 // designed for the new toolbar. |
| 57 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); | 57 DCHECK(extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()); |
| 58 | 58 |
| 59 // Add component toolbar actions here. | 59 // Add component toolbar actions here. |
| 60 // This current design means that the ComponentToolbarActionsFactory is aware | 60 // This current design means that the ComponentToolbarActionsFactory is aware |
| 61 // of all actions. Since we should *not* have an excessive amount of these | 61 // of all actions. Since we should *not* have an excessive amount of these |
| 62 // (since each will have an action in the toolbar or overflow menu), this | 62 // (since each will have an action in the toolbar or overflow menu), this |
| 63 // should be okay. If this changes, we should rethink this design to have, | 63 // should be okay. If this changes, we should rethink this design to have, |
| 64 // e.g., RegisterChromeAction(). | 64 // e.g., RegisterChromeAction(). |
| 65 #if defined(ENABLE_MEDIA_ROUTER) | 65 #if defined(ENABLE_MEDIA_ROUTER) |
| 66 if (id == kMediaRouterActionId) | 66 if (id == kMediaRouterActionId) |
| 67 return scoped_ptr<ToolbarActionViewController>( | 67 return std::unique_ptr<ToolbarActionViewController>( |
| 68 new MediaRouterAction(browser, bar)); | 68 new MediaRouterAction(browser, bar)); |
| 69 #endif // defined(ENABLE_MEDIA_ROUTER) | 69 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 70 | 70 |
| 71 NOTREACHED(); | 71 NOTREACHED(); |
| 72 return scoped_ptr<ToolbarActionViewController>(); | 72 return std::unique_ptr<ToolbarActionViewController>(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // static | 75 // static |
| 76 void ComponentToolbarActionsFactory::SetTestingFactory( | 76 void ComponentToolbarActionsFactory::SetTestingFactory( |
| 77 ComponentToolbarActionsFactory* factory) { | 77 ComponentToolbarActionsFactory* factory) { |
| 78 testing_factory_ = factory; | 78 testing_factory_ = factory; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void ComponentToolbarActionsFactory::RegisterComponentMigrations( | 81 void ComponentToolbarActionsFactory::RegisterComponentMigrations( |
| 82 extensions::ComponentMigrationHelper* helper) const { | 82 extensions::ComponentMigrationHelper* helper) const { |
| 83 helper->Register(kMediaRouterActionId, kCastExtensionId); | 83 helper->Register(kMediaRouterActionId, kCastExtensionId); |
| 84 helper->Register(kMediaRouterActionId, kCastBetaExtensionId); | 84 helper->Register(kMediaRouterActionId, kCastBetaExtensionId); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void ComponentToolbarActionsFactory::HandleComponentMigrations( | 87 void ComponentToolbarActionsFactory::HandleComponentMigrations( |
| 88 extensions::ComponentMigrationHelper* helper, | 88 extensions::ComponentMigrationHelper* helper, |
| 89 Profile* profile) const { | 89 Profile* profile) const { |
| 90 if (media_router::MediaRouterEnabled(profile)) { | 90 if (media_router::MediaRouterEnabled(profile)) { |
| 91 helper->OnFeatureEnabled(kMediaRouterActionId); | 91 helper->OnFeatureEnabled(kMediaRouterActionId); |
| 92 } else { | 92 } else { |
| 93 helper->OnFeatureDisabled(kMediaRouterActionId); | 93 helper->OnFeatureDisabled(kMediaRouterActionId); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| OLD | NEW |