| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/arc/arc_service_manager.h" | 5 #include "components/arc/arc_service_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "components/arc/arc_bridge_bootstrap.h" | 12 #include "components/arc/arc_bridge_bootstrap.h" |
| 13 #include "components/arc/arc_bridge_service.h" | 13 #include "components/arc/arc_bridge_service.h" |
| 14 #include "components/arc/arc_bridge_service_impl.h" | 14 #include "components/arc/arc_bridge_service_impl.h" |
| 15 #include "components/arc/audio/arc_audio_bridge.h" | 15 #include "components/arc/audio/arc_audio_bridge.h" |
| 16 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" | 16 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" |
| 17 #include "components/arc/clipboard/arc_clipboard_bridge.h" | 17 #include "components/arc/clipboard/arc_clipboard_bridge.h" |
| 18 #include "components/arc/crash_collector/arc_crash_collector_bridge.h" | 18 #include "components/arc/crash_collector/arc_crash_collector_bridge.h" |
| 19 #include "components/arc/ime/arc_ime_service.h" | 19 #include "components/arc/ime/arc_ime_service.h" |
| 20 #include "components/arc/intent_helper/activity_icon_loader.h" | 20 #include "components/arc/intent_helper/activity_icon_loader.h" |
| 21 #include "components/arc/metrics/arc_metrics_service.h" | 21 #include "components/arc/metrics/arc_metrics_service.h" |
| 22 #include "components/arc/net/arc_net_host_impl.h" | 22 #include "components/arc/net/arc_net_host_impl.h" |
| 23 #include "components/arc/obb_mounter/arc_obb_mounter_bridge.h" | 23 #include "components/arc/obb_mounter/arc_obb_mounter_bridge.h" |
| 24 #include "components/arc/power/arc_power_bridge.h" | 24 #include "components/arc/power/arc_power_bridge.h" |
| 25 #include "components/arc/storage_manager/arc_storage_manager.h" | 25 #include "components/arc/storage_manager/arc_storage_manager.h" |
| 26 #include "components/arc/user_data/arc_user_data_service.h" | 26 #include "components/arc/user_data/arc_user_data_service.h" |
| 27 #include "components/arc/window_manager/arc_window_manager_bridge.h" | |
| 28 #include "components/prefs/pref_member.h" | 27 #include "components/prefs/pref_member.h" |
| 29 #include "ui/arc/notification/arc_notification_manager.h" | 28 #include "ui/arc/notification/arc_notification_manager.h" |
| 30 | 29 |
| 31 namespace arc { | 30 namespace arc { |
| 32 | 31 |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 // Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos. | 34 // Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos. |
| 36 ArcServiceManager* g_arc_service_manager = nullptr; | 35 ArcServiceManager* g_arc_service_manager = nullptr; |
| 37 | 36 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 std::unique_ptr<BooleanPrefMember> arc_enabled_pref) { | 100 std::unique_ptr<BooleanPrefMember> arc_enabled_pref) { |
| 102 DCHECK(thread_checker_.CalledOnValidThread()); | 101 DCHECK(thread_checker_.CalledOnValidThread()); |
| 103 | 102 |
| 104 AddService(base::WrapUnique(new ArcUserDataService( | 103 AddService(base::WrapUnique(new ArcUserDataService( |
| 105 arc_bridge_service(), std::move(arc_enabled_pref), account_id))); | 104 arc_bridge_service(), std::move(arc_enabled_pref), account_id))); |
| 106 | 105 |
| 107 AddService(base::WrapUnique( | 106 AddService(base::WrapUnique( |
| 108 new ArcNotificationManager(arc_bridge_service(), account_id))); | 107 new ArcNotificationManager(arc_bridge_service(), account_id))); |
| 109 } | 108 } |
| 110 | 109 |
| 111 void ArcServiceManager::OnAshStarted() { | |
| 112 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 113 // We might come here multiple times. As such we should only do this once. | |
| 114 if (on_ash_started_called_) | |
| 115 return; | |
| 116 | |
| 117 on_ash_started_called_ = true; | |
| 118 AddService( | |
| 119 base::WrapUnique(new ArcWindowManagerBridge(arc_bridge_service()))); | |
| 120 } | |
| 121 | |
| 122 void ArcServiceManager::Shutdown() { | 110 void ArcServiceManager::Shutdown() { |
| 123 icon_loader_ = nullptr; | 111 icon_loader_ = nullptr; |
| 124 activity_resolver_ = nullptr; | 112 activity_resolver_ = nullptr; |
| 125 services_.clear(); | 113 services_.clear(); |
| 126 } | 114 } |
| 127 | 115 |
| 128 // static | 116 // static |
| 129 void ArcServiceManager::SetArcBridgeServiceForTesting( | 117 void ArcServiceManager::SetArcBridgeServiceForTesting( |
| 130 std::unique_ptr<ArcBridgeService> arc_bridge_service) { | 118 std::unique_ptr<ArcBridgeService> arc_bridge_service) { |
| 131 if (g_arc_bridge_service_for_testing) { | 119 if (g_arc_bridge_service_for_testing) { |
| 132 delete g_arc_bridge_service_for_testing; | 120 delete g_arc_bridge_service_for_testing; |
| 133 } | 121 } |
| 134 g_arc_bridge_service_for_testing = arc_bridge_service.release(); | 122 g_arc_bridge_service_for_testing = arc_bridge_service.release(); |
| 135 } | 123 } |
| 136 | 124 |
| 137 } // namespace arc | 125 } // namespace arc |
| OLD | NEW |