1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_ANDROID_SMS_ANDROID_SMS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_ANDROID_SMS_ANDROID_SMS_SERVICE_H_ 7 8 #include <memory> 9 #include "chrome/browser/chromeos/android_sms/android_sms_app_manager_impl.h" 10 #include "chrome/browser/chromeos/android_sms/android_sms_pairing_state_tracker_impl.h" 11 #include "components/keyed_service/core/keyed_service.h" 12 #include "components/session_manager/core/session_manager_observer.h" 13 14 class HostContentSettingsMap; 15 class Profile; 16 17 namespace app_list { 18 class AppListSyncableService; 19 } // namespace app_list 20 21 namespace web_app { 22 class WebAppProvider; 23 } // namespace web_app 24 25 namespace chromeos { 26 27 namespace multidevice_setup { 28 class AndroidSmsPairingStateTracker; 29 class MultiDeviceSetupClient; 30 } // namespace multidevice_setup 31 32 namespace android_sms { 33 34 class AndroidSmsAppManager; 35 class AndroidSmsAppSetupController; 36 class ConnectionManager; 37 class PairingLostNotifier; 38 39 // KeyedService which manages Android Messages integration. This service 40 // has four main responsibilities: 41 // (1) Maintaining a connection with the Messages ServiceWorker, 42 // (2) Managing installation/launching of the Messages PWA, 43 // (3) Tracking the pairing state of the PWA, and 44 // (4) Notifying users when their phones need to be re-paired. 45 class AndroidSmsService : public KeyedService, 46 public session_manager::SessionManagerObserver { 47 public: 48 AndroidSmsService( 49 Profile* profile, 50 HostContentSettingsMap* host_content_settings_map, 51 multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client, 52 web_app::WebAppProvider* web_app_provider, 53 app_list::AppListSyncableService* app_list_syncable_service); 54 ~AndroidSmsService() override; 55 android_sms_app_manager()56 AndroidSmsAppManager* android_sms_app_manager() { 57 return android_sms_app_manager_.get(); 58 } 59 60 multidevice_setup::AndroidSmsPairingStateTracker* android_sms_pairing_state_tracker()61 android_sms_pairing_state_tracker() { 62 return android_sms_pairing_state_tracker_.get(); 63 } 64 65 private: 66 // KeyedService: 67 void Shutdown() override; 68 69 // session_manager::SessionManagerObserver 70 void OnSessionStateChanged() override; 71 72 Profile* profile_; 73 multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client_; 74 75 std::unique_ptr<AndroidSmsAppSetupController> 76 andoid_sms_app_setup_controller_; 77 std::unique_ptr<AndroidSmsAppManager> android_sms_app_manager_; 78 std::unique_ptr<AndroidSmsPairingStateTrackerImpl> 79 android_sms_pairing_state_tracker_; 80 std::unique_ptr<PairingLostNotifier> pairing_lost_notifier_; 81 std::unique_ptr<ConnectionManager> connection_manager_; 82 83 DISALLOW_COPY_AND_ASSIGN(AndroidSmsService); 84 }; 85 86 } // namespace android_sms 87 88 } // namespace chromeos 89 90 #endif // CHROME_BROWSER_CHROMEOS_ANDROID_SMS_ANDROID_SMS_SERVICE_H_ 91