1 // Copyright 2019 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 #include "chrome/browser/send_tab_to_self/receiving_ui_handler_registry.h" 6 7 #include <vector> 8 9 #include "base/memory/singleton.h" 10 #include "build/build_config.h" 11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/send_tab_to_self/receiving_ui_handler.h" 13 14 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_BSD) || \ 15 defined(OS_WIN) 16 #include "chrome/browser/send_tab_to_self/desktop_notification_handler.h" 17 #endif 18 19 #if defined(OS_ANDROID) 20 #include "chrome/browser/android/send_tab_to_self/android_notification_handler.h" 21 #endif 22 23 namespace send_tab_to_self { 24 ReceivingUiHandlerRegistry()25ReceivingUiHandlerRegistry::ReceivingUiHandlerRegistry() {} ~ReceivingUiHandlerRegistry()26ReceivingUiHandlerRegistry::~ReceivingUiHandlerRegistry() {} 27 28 // static GetInstance()29ReceivingUiHandlerRegistry* ReceivingUiHandlerRegistry::GetInstance() { 30 return base::Singleton<ReceivingUiHandlerRegistry>::get(); 31 } 32 33 // Instantiates all the handlers relevant to this platform. InstantiatePlatformSpecificHandlers(Profile * profile)34void ReceivingUiHandlerRegistry::InstantiatePlatformSpecificHandlers( 35 Profile* profile) { 36 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_BSD) || \ 37 defined(OS_WIN) 38 applicable_handlers_.push_back( 39 std::make_unique<send_tab_to_self::DesktopNotificationHandler>(profile)); 40 #elif defined(OS_ANDROID) 41 applicable_handlers_.push_back( 42 std::make_unique<AndroidNotificationHandler>()); 43 #endif 44 } 45 46 const std::vector<std::unique_ptr<ReceivingUiHandler>>& GetHandlers() const47ReceivingUiHandlerRegistry::GetHandlers() const { 48 return applicable_handlers_; 49 } 50 51 } // namespace send_tab_to_self 52