| 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/serialized_navigation_entry.h" | 16 #include "components/sessions/serialized_navigation_entry.h" |
| 16 #include "components/sessions/session_id.h" | 17 #include "components/sessions/session_id.h" |
| 17 #include "components/sessions/session_types.h" | 18 #include "components/sessions/session_types.h" |
| 18 #include "content/public/browser/session_storage_namespace.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 content { |
| 25 class SessionStorageNamespace; | |
| 26 class WebContents; | 25 class WebContents; |
| 27 } | 26 } |
| 28 | 27 |
| 29 // TabRestoreService is responsible for maintaining the most recently closed | 28 // TabRestoreService is responsible for maintaining the most recently closed |
| 30 // tabs and windows. When a tab is closed | 29 // tabs and windows. When a tab is closed |
| 31 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to | 30 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to |
| 32 // represent the tab. Similarly, when a browser is closed, BrowserClosing is | 31 // represent the tab. Similarly, when a browser is closed, BrowserClosing is |
| 33 // invoked and a Window is created to represent the window. | 32 // invoked and a Window is created to represent the window. |
| 34 // | 33 // |
| 35 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById | 34 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 68 |
| 70 // Is this entry from the last session? This is set to true for entries that | 69 // Is this entry from the last session? This is set to true for entries that |
| 71 // were closed during the last session, and false for entries that were | 70 // were closed during the last session, and false for entries that were |
| 72 // closed during this session. | 71 // closed during this session. |
| 73 bool from_last_session; | 72 bool from_last_session; |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 // Represents a previously open tab. | 75 // Represents a previously open tab. |
| 77 struct Tab : public Entry { | 76 struct Tab : public Entry { |
| 78 Tab(); | 77 Tab(); |
| 78 Tab(const Tab& tab); |
| 79 ~Tab() override; | 79 ~Tab() override; |
| 80 | 80 |
| 81 Tab& operator=(const Tab& tab); |
| 82 |
| 81 bool has_browser() const { return browser_id > 0; } | 83 bool has_browser() const { return browser_id > 0; } |
| 82 | 84 |
| 83 // The navigations. | 85 // The navigations. |
| 84 std::vector<sessions::SerializedNavigationEntry> navigations; | 86 std::vector<sessions::SerializedNavigationEntry> navigations; |
| 85 | 87 |
| 86 // Index of the selected navigation in navigations. | 88 // Index of the selected navigation in navigations. |
| 87 int current_navigation_index; | 89 int current_navigation_index; |
| 88 | 90 |
| 89 // The ID of the browser to which this tab belonged, so it can be restored | 91 // The ID of the browser to which this tab belonged, so it can be restored |
| 90 // there. May be 0 (an invalid SessionID) when restoring an entire session. | 92 // there. May be 0 (an invalid SessionID) when restoring an entire session. |
| 91 SessionID::id_type browser_id; | 93 SessionID::id_type browser_id; |
| 92 | 94 |
| 93 // Index within the tab strip. May be -1 for an unknown index. | 95 // Index within the tab strip. May be -1 for an unknown index. |
| 94 int tabstrip_index; | 96 int tabstrip_index; |
| 95 | 97 |
| 96 // True if the tab was pinned. | 98 // True if the tab was pinned. |
| 97 bool pinned; | 99 bool pinned; |
| 98 | 100 |
| 99 // If non-empty gives the id of the extension for the tab. | 101 // If non-empty gives the id of the extension for the tab. |
| 100 std::string extension_app_id; | 102 std::string extension_app_id; |
| 101 | 103 |
| 102 // The associated session storage namespace (if any). | 104 // The associated client data. |
| 103 scoped_refptr<content::SessionStorageNamespace> session_storage_namespace; | 105 scoped_ptr<sessions::TabClientData> client_data; |
| 104 | 106 |
| 105 // The user agent override used for the tab's navigations (if applicable). | 107 // The user agent override used for the tab's navigations (if applicable). |
| 106 std::string user_agent_override; | 108 std::string user_agent_override; |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 // Represents a previously open window. | 111 // Represents a previously open window. |
| 110 struct Window : public Entry { | 112 struct Window : public Entry { |
| 111 Window(); | 113 Window(); |
| 112 ~Window() override; | 114 ~Window() override; |
| 113 | 115 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 virtual void LoadTabsFromLastSession() = 0; | 186 virtual void LoadTabsFromLastSession() = 0; |
| 185 | 187 |
| 186 // Returns true if the tab entries have been loaded. | 188 // Returns true if the tab entries have been loaded. |
| 187 virtual bool IsLoaded() const = 0; | 189 virtual bool IsLoaded() const = 0; |
| 188 | 190 |
| 189 // Deletes the last session. | 191 // Deletes the last session. |
| 190 virtual void DeleteLastSession() = 0; | 192 virtual void DeleteLastSession() = 0; |
| 191 }; | 193 }; |
| 192 | 194 |
| 193 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 195 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
| OLD | NEW |