| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 15 #include "components/sessions/core/tab_restore_service_client.h" | 15 #include "components/sessions/core/tab_restore_service_client.h" |
| 16 #include "components/sessions/serialized_navigation_entry.h" | 16 #include "components/sessions/serialized_navigation_entry.h" |
| 17 #include "components/sessions/session_id.h" | 17 #include "components/sessions/session_id.h" |
| 18 #include "components/sessions/session_types.h" | 18 #include "components/sessions/session_types.h" |
| 19 #include "ui/base/window_open_disposition.h" | 19 #include "ui/base/window_open_disposition.h" |
| 20 | 20 |
| 21 class TabRestoreServiceDelegate; | 21 class TabRestoreServiceDelegate; |
| 22 class TabRestoreServiceObserver; | 22 class TabRestoreServiceObserver; |
| 23 | 23 |
| 24 namespace content { | 24 namespace sessions { |
| 25 class WebContents; | 25 class LiveTab; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // TabRestoreService is responsible for maintaining the most recently closed | 28 // TabRestoreService is responsible for maintaining the most recently closed |
| 29 // tabs and windows. When a tab is closed | 29 // tabs and windows. When a tab is closed |
| 30 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to | 30 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to |
| 31 // represent the tab. Similarly, when a browser is closed, BrowserClosing is | 31 // represent the tab. Similarly, when a browser is closed, BrowserClosing is |
| 32 // invoked and a Window is created to represent the window. | 32 // invoked and a Window is created to represent the window. |
| 33 // | 33 // |
| 34 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById | 34 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById |
| 35 // or RestoreMostRecentEntry. | 35 // or RestoreMostRecentEntry. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 typedef std::list<Entry*> Entries; | 126 typedef std::list<Entry*> Entries; |
| 127 | 127 |
| 128 ~TabRestoreService() override; | 128 ~TabRestoreService() override; |
| 129 | 129 |
| 130 // Adds/removes an observer. TabRestoreService does not take ownership of | 130 // Adds/removes an observer. TabRestoreService does not take ownership of |
| 131 // the observer. | 131 // the observer. |
| 132 virtual void AddObserver(TabRestoreServiceObserver* observer) = 0; | 132 virtual void AddObserver(TabRestoreServiceObserver* observer) = 0; |
| 133 virtual void RemoveObserver(TabRestoreServiceObserver* observer) = 0; | 133 virtual void RemoveObserver(TabRestoreServiceObserver* observer) = 0; |
| 134 | 134 |
| 135 // Creates a Tab to represent |contents| and notifies observers the list of | 135 // Creates a Tab to represent |live_tab| and notifies observers the list of |
| 136 // entries has changed. | 136 // entries has changed. |
| 137 virtual void CreateHistoricalTab(content::WebContents* contents, | 137 virtual void CreateHistoricalTab(sessions::LiveTab* live_tab, int index) = 0; |
| 138 int index) = 0; | |
| 139 | 138 |
| 140 // Invoked when a browser is closing. If |delegate| is a tabbed browser with | 139 // Invoked when a browser is closing. If |delegate| is a tabbed browser with |
| 141 // at least one tab, a Window is created, added to entries and observers are | 140 // at least one tab, a Window is created, added to entries and observers are |
| 142 // notified. | 141 // notified. |
| 143 virtual void BrowserClosing(TabRestoreServiceDelegate* delegate) = 0; | 142 virtual void BrowserClosing(TabRestoreServiceDelegate* delegate) = 0; |
| 144 | 143 |
| 145 // Invoked when the browser is done closing. | 144 // Invoked when the browser is done closing. |
| 146 virtual void BrowserClosed(TabRestoreServiceDelegate* delegate) = 0; | 145 virtual void BrowserClosed(TabRestoreServiceDelegate* delegate) = 0; |
| 147 | 146 |
| 148 // Removes all entries from the list and notifies observers the list | 147 // Removes all entries from the list and notifies observers the list |
| 149 // of tabs has changed. | 148 // of tabs has changed. |
| 150 virtual void ClearEntries() = 0; | 149 virtual void ClearEntries() = 0; |
| 151 | 150 |
| 152 // Returns the entries, ordered with most recently closed entries at the | 151 // Returns the entries, ordered with most recently closed entries at the |
| 153 // front. | 152 // front. |
| 154 virtual const Entries& entries() const = 0; | 153 virtual const Entries& entries() const = 0; |
| 155 | 154 |
| 156 // Restores the most recently closed entry. Does nothing if there are no | 155 // Restores the most recently closed entry. Does nothing if there are no |
| 157 // entries to restore. If the most recently restored entry is a tab, it is | 156 // entries to restore. If the most recently restored entry is a tab, it is |
| 158 // added to |delegate|. |host_desktop_type| is a value that is opaque to this | 157 // added to |delegate|. |host_desktop_type| is a value that is opaque to this |
| 159 // class and will be used only to pass back to the embedder via | 158 // class and will be used only to pass back to the embedder via |
| 160 // TabRestoreServiceClient if necessary. Returns the WebContents of the | 159 // TabRestoreServiceClient if necessary. Returns the LiveTab instances of the |
| 161 // restored tab(s). | 160 // restored tab(s). |
| 162 virtual std::vector<content::WebContents*> RestoreMostRecentEntry( | 161 virtual std::vector<sessions::LiveTab*> RestoreMostRecentEntry( |
| 163 TabRestoreServiceDelegate* delegate, | 162 TabRestoreServiceDelegate* delegate, |
| 164 int host_desktop_type) = 0; | 163 int host_desktop_type) = 0; |
| 165 | 164 |
| 166 // Removes the Tab with id |id| from the list and returns it; ownership is | 165 // Removes the Tab with id |id| from the list and returns it; ownership is |
| 167 // passed to the caller. | 166 // passed to the caller. |
| 168 virtual Tab* RemoveTabEntryById(SessionID::id_type id) = 0; | 167 virtual Tab* RemoveTabEntryById(SessionID::id_type id) = 0; |
| 169 | 168 |
| 170 // Restores an entry by id. If there is no entry with an id matching |id|, | 169 // Restores an entry by id. If there is no entry with an id matching |id|, |
| 171 // this does nothing. If |delegate| is NULL, this creates a new window for the | 170 // this does nothing. If |delegate| is NULL, this creates a new window for the |
| 172 // entry. |disposition| is respected, but the attributes (tabstrip index, | 171 // entry. |disposition| is respected, but the attributes (tabstrip index, |
| 173 // browser window) of the tab when it was closed will be respected if | 172 // browser window) of the tab when it was closed will be respected if |
| 174 // disposition is UNKNOWN. |host_desktop_type| is a value that is opaque to | 173 // disposition is UNKNOWN. |host_desktop_type| is a value that is opaque to |
| 175 // this class and will be used only to pass back to the embedder via | 174 // this class and will be used only to pass back to the embedder via |
| 176 // TabRestoreServiceClient if necessary. Returns the WebContents of the | 175 // TabRestoreServiceClient if necessary. Returns the LiveTab instances of the |
| 177 // restored tab(s). | 176 // restored tab(s). |
| 178 virtual std::vector<content::WebContents*> RestoreEntryById( | 177 virtual std::vector<sessions::LiveTab*> RestoreEntryById( |
| 179 TabRestoreServiceDelegate* delegate, | 178 TabRestoreServiceDelegate* delegate, |
| 180 SessionID::id_type id, | 179 SessionID::id_type id, |
| 181 int host_desktop_type, | 180 int host_desktop_type, |
| 182 WindowOpenDisposition disposition) = 0; | 181 WindowOpenDisposition disposition) = 0; |
| 183 | 182 |
| 184 // Loads the tabs and previous session. This does nothing if the tabs | 183 // Loads the tabs and previous session. This does nothing if the tabs |
| 185 // from the previous session have already been loaded. | 184 // from the previous session have already been loaded. |
| 186 virtual void LoadTabsFromLastSession() = 0; | 185 virtual void LoadTabsFromLastSession() = 0; |
| 187 | 186 |
| 188 // Returns true if the tab entries have been loaded. | 187 // Returns true if the tab entries have been loaded. |
| 189 virtual bool IsLoaded() const = 0; | 188 virtual bool IsLoaded() const = 0; |
| 190 | 189 |
| 191 // Deletes the last session. | 190 // Deletes the last session. |
| 192 virtual void DeleteLastSession() = 0; | 191 virtual void DeleteLastSession() = 0; |
| 193 }; | 192 }; |
| 194 | 193 |
| 195 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 194 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
| OLD | NEW |