Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_UI_BROWSER_TABRESTORE_H_ |
| 6 | #define CHROME_BROWSER_UI_BROWSER_TABRESTORE_H_ |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 7 | |
Roman Arora | 6d9ab14 | 2021-12-06 17:46:09 | [diff] [blame] | 8 | #include <map> |
Lukasz Anforowicz | 3caa837 | 2018-06-05 17:22:07 | [diff] [blame] | 9 | #include <string> |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
Collin Baker | 81999fd | 2019-06-05 23:12:27 | [diff] [blame] | 12 | #include "base/token.h" |
blundell | 47c6d8a | 2015-09-24 11:06:40 | [diff] [blame] | 13 | #include "components/sessions/core/session_types.h" |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 14 | |
| 15 | class Browser; |
| 16 | |
| 17 | namespace content { |
| 18 | class SessionStorageNamespace; |
| 19 | class WebContents; |
Aran Gilman | d217b5b | 2019-04-11 17:45:43 | [diff] [blame] | 20 | } // namespace content |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 21 | |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 22 | namespace sessions { |
| 23 | class SerializedNavigationEntry; |
Maks Orlovich | 30312696 | 2020-04-06 21:34:25 | [diff] [blame] | 24 | struct SerializedUserAgentOverride; |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 25 | } |
| 26 | |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 27 | namespace chrome { |
| 28 | |
Duc Bui | 70c5972 | 2017-08-09 15:25:09 | [diff] [blame] | 29 | // Add a tab with its session history restored from the SessionRestore and |
Xiyuan Xia | cf018c7 | 2024-07-18 15:23:39 | [diff] [blame] | 30 | // TabRestoreService systems. If `select` is true, the tab is selected. |
Duc Bui | 70c5972 | 2017-08-09 15:25:09 | [diff] [blame] | 31 | // |tab_index| gives the index to insert the tab at. |selected_navigation| is |
| 32 | // the index of the SerializedNavigationEntry in |navigations| to select. If |
| 33 | // |extension_app_id| is non-empty the tab is an app tab and |extension_app_id| |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 34 | // is the id of the extension. If |group| has a value, it specifies the |
| 35 | // ID corresponding to the tab's group. If |pin| is true and |tab_index|/ is |
Lukasz Anforowicz | 0de0f45 | 2020-12-02 19:57:15 | [diff] [blame] | 36 | // the last pinned tab, then the newly created tab is pinned. |
Collin Baker | 81999fd | 2019-06-05 23:12:27 | [diff] [blame] | 37 | // |user_agent_override| contains the string being used as the user agent for |
| 38 | // all of the tab's navigations when the regular user agent is overridden. If |
Duc Bui | 70c5972 | 2017-08-09 15:25:09 | [diff] [blame] | 39 | // |from_session_restore| is true, the restored tab is created by session |
Sebastien Marchand | 28cf2318 | 2018-06-20 02:39:35 | [diff] [blame] | 40 | // restore. |last_active_time| is the value to use to indicate the last time the |
| 41 | // WebContents was made active, if this is left default initialized then the |
Xiyuan Xia | cf018c7 | 2024-07-18 15:23:39 | [diff] [blame] | 42 | // creation time will be used. If `is_active_browser` is set, it indicates |
| 43 | // whether `browser` is (or will be) the active browser. |
| 44 | // Returns the WebContents of the restored tab. |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 45 | content::WebContents* AddRestoredTab( |
| 46 | Browser* browser, |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 47 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 48 | int tab_index, |
| 49 | int selected_navigation, |
| 50 | const std::string& extension_app_id, |
Mohamed Mansour | bc07189 | 2023-12-07 04:08:03 | [diff] [blame] | 51 | std::optional<tab_groups::TabGroupId> group, |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 52 | bool select, |
| 53 | bool pin, |
Olivier ROBIN | 4b58dd93 | 2024-08-06 13:30:32 | [diff] [blame] | 54 | base::TimeTicks last_active_time_ticks, |
Olivier ROBIN | da292fb | 2024-08-07 14:32:29 | [diff] [blame] | 55 | base::Time last_active_time, |
[email protected] | 8d0f331 | 2012-08-18 01:47:53 | [diff] [blame] | 56 | content::SessionStorageNamespace* storage_namespace, |
Maks Orlovich | 30312696 | 2020-04-06 21:34:25 | [diff] [blame] | 57 | const sessions::SerializedUserAgentOverride& user_agent_override, |
Roman Arora | 6d9ab14 | 2021-12-06 17:46:09 | [diff] [blame] | 58 | const std::map<std::string, std::string>& extra_data, |
Xiyuan Xia | cf018c7 | 2024-07-18 15:23:39 | [diff] [blame] | 59 | bool from_session_restore, |
| 60 | std::optional<bool> is_active_browser); |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 61 | |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 62 | // Replaces the state of the currently selected tab with the session |
Duc Bui | 70c5972 | 2017-08-09 15:25:09 | [diff] [blame] | 63 | // history restored from the SessionRestore and TabRestoreService systems. |
| 64 | // Returns the WebContents of the restored tab. |
[email protected] | 38eae4b | 2013-08-06 19:46:54 | [diff] [blame] | 65 | content::WebContents* ReplaceRestoredTab( |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 66 | Browser* browser, |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 67 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 68 | int selected_navigation, |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 69 | const std::string& extension_app_id, |
[email protected] | 8d0f331 | 2012-08-18 01:47:53 | [diff] [blame] | 70 | content::SessionStorageNamespace* session_storage_namespace, |
Maks Orlovich | 30312696 | 2020-04-06 21:34:25 | [diff] [blame] | 71 | const sessions::SerializedUserAgentOverride& user_agent_override, |
Roman Arora | 6d9ab14 | 2021-12-06 17:46:09 | [diff] [blame] | 72 | const std::map<std::string, std::string>& extra_data, |
Duc Bui | 70c5972 | 2017-08-09 15:25:09 | [diff] [blame] | 73 | bool from_session_restore); |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 74 | |
| 75 | } // namespace chrome |
| 76 | |
| 77 | #endif // CHROME_BROWSER_UI_BROWSER_TABRESTORE_H_ |