in_memory_tab_restore_service.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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.
4
5#include "chrome/browser/sessions/in_memory_tab_restore_service.h"
6
7#include "base/compiler_specific.h"
8#include "chrome/browser/profiles/profile.h"
9#include "chrome/browser/sessions/tab_restore_service_factory.h"
10
11InMemoryTabRestoreService::InMemoryTabRestoreService(
12    Profile* profile,
13    TabRestoreService::TimeFactory* time_factory)
14    : helper_(this, NULL, profile, time_factory) {
15}
16
17InMemoryTabRestoreService::~InMemoryTabRestoreService() {}
18
19void InMemoryTabRestoreService::AddObserver(
20    TabRestoreServiceObserver* observer) {
21  helper_.AddObserver(observer);
22}
23
24void InMemoryTabRestoreService::RemoveObserver(
25    TabRestoreServiceObserver* observer) {
26  helper_.RemoveObserver(observer);
27}
28
29void InMemoryTabRestoreService::CreateHistoricalTab(
30    content::WebContents* contents,
31    int index) {
32  helper_.CreateHistoricalTab(contents, index);
33}
34
35void InMemoryTabRestoreService::BrowserClosing(
36    TabRestoreServiceDelegate* delegate) {
37  helper_.BrowserClosing(delegate);
38}
39
40void InMemoryTabRestoreService::BrowserClosed(
41    TabRestoreServiceDelegate* delegate) {
42  helper_.BrowserClosed(delegate);
43}
44
45void InMemoryTabRestoreService::ClearEntries() {
46  helper_.ClearEntries();
47}
48
49const TabRestoreService::Entries& InMemoryTabRestoreService::entries() const {
50  return helper_.entries();
51}
52
53void InMemoryTabRestoreService::RestoreMostRecentEntry(
54    TabRestoreServiceDelegate* delegate,
55    chrome::HostDesktopType host_desktop_type) {
56  helper_.RestoreMostRecentEntry(delegate, host_desktop_type);
57}
58
59TabRestoreService::Tab* InMemoryTabRestoreService::RemoveTabEntryById(
60    SessionID::id_type id) {
61  return helper_.RemoveTabEntryById(id);
62}
63
64void InMemoryTabRestoreService::RestoreEntryById(
65    TabRestoreServiceDelegate* delegate,
66    SessionID::id_type id,
67    chrome::HostDesktopType host_desktop_type,
68    WindowOpenDisposition disposition) {
69  helper_.RestoreEntryById(delegate, id, host_desktop_type, disposition);
70}
71
72void InMemoryTabRestoreService::LoadTabsFromLastSession() {
73  // Do nothing. This relies on tab persistence which is implemented in Java on
74  // the application side on Android.
75}
76
77bool InMemoryTabRestoreService::IsLoaded() const {
78  // See comment above.
79  return true;
80}
81
82void InMemoryTabRestoreService::DeleteLastSession() {
83  // See comment above.
84}
85
86void InMemoryTabRestoreService::Shutdown() {
87}
88
89ProfileKeyedService* TabRestoreServiceFactory::BuildServiceInstanceFor(
90    content::BrowserContext* profile) const {
91  return new InMemoryTabRestoreService(static_cast<Profile*>(profile), NULL);
92}
93