/ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.cc

https://gitlab.com/jonnialva90/iridium-browser · C++ · 62 lines · 43 code · 13 blank · 6 comment · 0 complexity · 65376a2ad53b8d11f61ab4bdadb8bfcb MD5 · raw file

  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
  3. // found in the LICENSE file.
  4. #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
  5. #include "base/memory/singleton.h"
  6. #include "components/keyed_service/ios/browser_state_dependency_manager.h"
  7. #include "components/sessions/core/persistent_tab_restore_service.h"
  8. #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_client.h"
  9. #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
  10. namespace {
  11. scoped_ptr<KeyedService> BuildTabRestoreService(web::BrowserState* context) {
  12. DCHECK(!context->IsOffTheRecord());
  13. ios::ChromeBrowserState* browser_state =
  14. ios::ChromeBrowserState::FromBrowserState(context);
  15. return make_scoped_ptr(new sessions::PersistentTabRestoreService(
  16. make_scoped_ptr(new IOSChromeTabRestoreServiceClient(browser_state)),
  17. nullptr));
  18. }
  19. } // namespace
  20. // static
  21. sessions::TabRestoreService*
  22. IOSChromeTabRestoreServiceFactory::GetForBrowserState(
  23. ios::ChromeBrowserState* browser_state) {
  24. return static_cast<sessions::TabRestoreService*>(
  25. GetInstance()->GetServiceForBrowserState(browser_state, true));
  26. }
  27. // static
  28. IOSChromeTabRestoreServiceFactory*
  29. IOSChromeTabRestoreServiceFactory::GetInstance() {
  30. return base::Singleton<IOSChromeTabRestoreServiceFactory>::get();
  31. }
  32. // static
  33. BrowserStateKeyedServiceFactory::TestingFactoryFunction
  34. IOSChromeTabRestoreServiceFactory::GetDefaultFactory() {
  35. return &BuildTabRestoreService;
  36. }
  37. IOSChromeTabRestoreServiceFactory::IOSChromeTabRestoreServiceFactory()
  38. : BrowserStateKeyedServiceFactory(
  39. "TabRestoreService",
  40. BrowserStateDependencyManager::GetInstance()) {}
  41. IOSChromeTabRestoreServiceFactory::~IOSChromeTabRestoreServiceFactory() {}
  42. bool IOSChromeTabRestoreServiceFactory::ServiceIsNULLWhileTesting() const {
  43. return true;
  44. }
  45. scoped_ptr<KeyedService>
  46. IOSChromeTabRestoreServiceFactory::BuildServiceInstanceFor(
  47. web::BrowserState* context) const {
  48. return BuildTabRestoreService(context);
  49. }