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