OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sessions/tab_restore_service_factory.h" | 5 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/sessions/tab_restore_service.h" | 8 #include "chrome/browser/sessions/chrome_tab_restore_service_client.h" |
9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
10 | 10 |
| 11 #if defined(OS_ANDROID) |
| 12 #include "chrome/browser/sessions/in_memory_tab_restore_service.h" |
| 13 #else |
| 14 #include "chrome/browser/sessions/persistent_tab_restore_service.h" |
| 15 #endif |
| 16 |
11 // static | 17 // static |
12 TabRestoreService* TabRestoreServiceFactory::GetForProfile(Profile* profile) { | 18 TabRestoreService* TabRestoreServiceFactory::GetForProfile(Profile* profile) { |
13 return static_cast<TabRestoreService*>( | 19 return static_cast<TabRestoreService*>( |
14 GetInstance()->GetServiceForBrowserContext(profile, true)); | 20 GetInstance()->GetServiceForBrowserContext(profile, true)); |
15 } | 21 } |
16 | 22 |
17 // static | 23 // static |
18 TabRestoreService* TabRestoreServiceFactory::GetForProfileIfExisting( | 24 TabRestoreService* TabRestoreServiceFactory::GetForProfileIfExisting( |
19 Profile* profile) { | 25 Profile* profile) { |
20 return static_cast<TabRestoreService*>( | 26 return static_cast<TabRestoreService*>( |
(...skipping 16 matching lines...) Expand all Loading... |
37 "TabRestoreService", | 43 "TabRestoreService", |
38 BrowserContextDependencyManager::GetInstance()) { | 44 BrowserContextDependencyManager::GetInstance()) { |
39 } | 45 } |
40 | 46 |
41 TabRestoreServiceFactory::~TabRestoreServiceFactory() { | 47 TabRestoreServiceFactory::~TabRestoreServiceFactory() { |
42 } | 48 } |
43 | 49 |
44 bool TabRestoreServiceFactory::ServiceIsNULLWhileTesting() const { | 50 bool TabRestoreServiceFactory::ServiceIsNULLWhileTesting() const { |
45 return true; | 51 return true; |
46 } | 52 } |
| 53 |
| 54 KeyedService* TabRestoreServiceFactory::BuildServiceInstanceFor( |
| 55 content::BrowserContext* browser_context) const { |
| 56 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 57 scoped_ptr<sessions::TabRestoreServiceClient> client( |
| 58 new ChromeTabRestoreServiceClient(profile)); |
| 59 |
| 60 #if defined(OS_ANDROID) |
| 61 return new InMemoryTabRestoreService(profile, nullptr); |
| 62 #else |
| 63 return new PersistentTabRestoreService(profile, client.Pass(), nullptr); |
| 64 #endif |
| 65 } |
OLD | NEW |