BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / sessions / tab_restore_service_factory.cc
blobd1abc0a45dc06260ad2c8f39f33c6672474e614c
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sessions/tab_restore_service_factory.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/chrome_tab_restore_service_client.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #if defined(OS_ANDROID)
12 #include "components/sessions/core/in_memory_tab_restore_service.h"
13 #else
14 #include "components/sessions/core/persistent_tab_restore_service.h"
15 #endif
17 // static
18 sessions::TabRestoreService* TabRestoreServiceFactory::GetForProfile(
19 Profile* profile) {
20 return static_cast<sessions::TabRestoreService*>(
21 GetInstance()->GetServiceForBrowserContext(profile, true));
24 // static
25 sessions::TabRestoreService* TabRestoreServiceFactory::GetForProfileIfExisting(
26 Profile* profile) {
27 return static_cast<sessions::TabRestoreService*>(
28 GetInstance()->GetServiceForBrowserContext(profile, false));
31 // static
32 void TabRestoreServiceFactory::ResetForProfile(Profile* profile) {
33 TabRestoreServiceFactory* factory = GetInstance();
34 factory->BrowserContextShutdown(profile);
35 factory->BrowserContextDestroyed(profile);
38 TabRestoreServiceFactory* TabRestoreServiceFactory::GetInstance() {
39 return base::Singleton<TabRestoreServiceFactory>::get();
42 TabRestoreServiceFactory::TabRestoreServiceFactory()
43 : BrowserContextKeyedServiceFactory(
44 "sessions::TabRestoreService",
45 BrowserContextDependencyManager::GetInstance()) {}
47 TabRestoreServiceFactory::~TabRestoreServiceFactory() {
50 bool TabRestoreServiceFactory::ServiceIsNULLWhileTesting() const {
51 return true;
54 KeyedService* TabRestoreServiceFactory::BuildServiceInstanceFor(
55 content::BrowserContext* browser_context) const {
56 Profile* profile = Profile::FromBrowserContext(browser_context);
57 DCHECK(!profile->IsOffTheRecord());
58 scoped_ptr<sessions::TabRestoreServiceClient> client(
59 new ChromeTabRestoreServiceClient(profile));
61 #if defined(OS_ANDROID)
62 return new sessions::InMemoryTabRestoreService(client.Pass(), nullptr);
63 #else
64 return new sessions::PersistentTabRestoreService(client.Pass(), nullptr);
65 #endif