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