Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/sessions/tab_restore_service.h

Issue 3012001: Move implementation from header to source. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: blank line Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_
6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ 6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_
7 7
8 #include <list> 8 #include <list>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 30 matching lines...) Expand all
41 virtual void TabRestoreServiceChanged(TabRestoreService* service) = 0; 41 virtual void TabRestoreServiceChanged(TabRestoreService* service) = 0;
42 42
43 // Sent to all remaining Observers when TabRestoreService's 43 // Sent to all remaining Observers when TabRestoreService's
44 // destructor is run. 44 // destructor is run.
45 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) = 0; 45 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) = 0;
46 }; 46 };
47 47
48 // Interface used to allow the test to provide a custom time. 48 // Interface used to allow the test to provide a custom time.
49 class TimeFactory { 49 class TimeFactory {
50 public: 50 public:
51 virtual ~TimeFactory() {} 51 virtual ~TimeFactory();
52 virtual base::Time TimeNow() = 0; 52 virtual base::Time TimeNow() = 0;
53 }; 53 };
54 54
55 // The type of entry. 55 // The type of entry.
56 enum Type { 56 enum Type {
57 TAB, 57 TAB,
58 WINDOW 58 WINDOW
59 }; 59 };
60 60
61 struct Entry { 61 struct Entry {
62 Entry(); 62 Entry();
63 explicit Entry(Type type); 63 explicit Entry(Type type);
64 virtual ~Entry() {} 64 virtual ~Entry();
65 65
66 // Unique id for this entry. The id is guaranteed to be unique for a 66 // Unique id for this entry. The id is guaranteed to be unique for a
67 // session. 67 // session.
68 SessionID::id_type id; 68 SessionID::id_type id;
69 69
70 // The type of the entry. 70 // The type of the entry.
71 Type type; 71 Type type;
72 72
73 // The time when the window or tab was closed. 73 // The time when the window or tab was closed.
74 base::Time timestamp; 74 base::Time timestamp;
75 75
76 // Is this entry from the last session? This is set to true for entries that 76 // Is this entry from the last session? This is set to true for entries that
77 // were closed during the last session, and false for entries that were 77 // were closed during the last session, and false for entries that were
78 // closed during this session. 78 // closed during this session.
79 bool from_last_session; 79 bool from_last_session;
80 }; 80 };
81 81
82 // Represents a previously open tab. 82 // Represents a previously open tab.
83 struct Tab : public Entry { 83 struct Tab : public Entry {
84 Tab(); 84 Tab();
85 virtual ~Tab();
85 86
86 bool has_browser() const { return browser_id > 0; } 87 bool has_browser() const { return browser_id > 0; }
87 88
88 // The navigations. 89 // The navigations.
89 std::vector<TabNavigation> navigations; 90 std::vector<TabNavigation> navigations;
90 91
91 // Index of the selected navigation in navigations. 92 // Index of the selected navigation in navigations.
92 int current_navigation_index; 93 int current_navigation_index;
93 94
94 // The ID of the browser to which this tab belonged, so it can be restored 95 // The ID of the browser to which this tab belonged, so it can be restored
95 // there. May be 0 (an invalid SessionID) when restoring an entire session. 96 // there. May be 0 (an invalid SessionID) when restoring an entire session.
96 SessionID::id_type browser_id; 97 SessionID::id_type browser_id;
97 98
98 // Index within the tab strip. May be -1 for an unknown index. 99 // Index within the tab strip. May be -1 for an unknown index.
99 int tabstrip_index; 100 int tabstrip_index;
100 101
101 // True if the tab was pinned. 102 // True if the tab was pinned.
102 bool pinned; 103 bool pinned;
103 104
104 // If non-empty gives the id of the extension for the tab. 105 // If non-empty gives the id of the extension for the tab.
105 std::string extension_app_id; 106 std::string extension_app_id;
106 }; 107 };
107 108
108 // Represents a previously open window. 109 // Represents a previously open window.
109 struct Window : public Entry { 110 struct Window : public Entry {
110 Window(); 111 Window();
112 virtual ~Window();
111 113
112 // The tabs that comprised the window, in order. 114 // The tabs that comprised the window, in order.
113 std::vector<Tab> tabs; 115 std::vector<Tab> tabs;
114 116
115 // Index of the selected tab. 117 // Index of the selected tab.
116 int selected_tab_index; 118 int selected_tab_index;
117 }; 119 };
118 120
119 typedef std::list<Entry*> Entries; 121 typedef std::list<Entry*> Entries;
120 122
(...skipping 19 matching lines...) Expand all
140 142
141 // Invoked when the browser is done closing. 143 // Invoked when the browser is done closing.
142 void BrowserClosed(Browser* browser); 144 void BrowserClosed(Browser* browser);
143 145
144 // Removes all entries from the list and notifies observers the list 146 // Removes all entries from the list and notifies observers the list
145 // of tabs has changed. 147 // of tabs has changed.
146 void ClearEntries(); 148 void ClearEntries();
147 149
148 // Returns the entries, ordered with most recently closed entries at the 150 // Returns the entries, ordered with most recently closed entries at the
149 // front. 151 // front.
150 virtual const Entries& entries() const { return entries_; } 152 virtual const Entries& entries() const;
151 153
152 // Restores the most recently closed entry. Does nothing if there are no 154 // Restores the most recently closed entry. Does nothing if there are no
153 // entries to restore. If the most recently restored entry is a tab, it is 155 // entries to restore. If the most recently restored entry is a tab, it is
154 // added to |browser|. 156 // added to |browser|.
155 void RestoreMostRecentEntry(Browser* browser); 157 void RestoreMostRecentEntry(Browser* browser);
156 158
157 // Restores an entry by id. If there is no entry with an id matching |id|, 159 // Restores an entry by id. If there is no entry with an id matching |id|,
158 // this does nothing. If |replace_existing_tab| is true and id identifies a 160 // this does nothing. If |replace_existing_tab| is true and id identifies a
159 // tab, the newly created tab replaces the selected tab in |browser|. If 161 // tab, the newly created tab replaces the selected tab in |browser|. If
160 // |browser| is NULL, this creates a new window for the entry. 162 // |browser| is NULL, this creates a new window for the entry.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // entries_. 341 // entries_.
340 std::vector<Entry*> staging_entries_; 342 std::vector<Entry*> staging_entries_;
341 343
342 TimeFactory* time_factory_; 344 TimeFactory* time_factory_;
343 345
344 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); 346 DISALLOW_COPY_AND_ASSIGN(TabRestoreService);
345 }; 347 };
346 348
347 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ 349 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_
348 350
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698