[email protected] | a636d8e5 | 2012-02-28 15:40:41 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [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 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |
| 6 | #define CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 7 | |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 8 | #include <map> |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 12 | #include "components/sessions/core/live_tab_context.h" |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 13 | #include "components/tab_groups/tab_group_id.h" |
| 14 | #include "components/tab_groups/tab_group_visual_data.h" |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame] | 15 | #include "ui/base/ui_base_types.h" |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 16 | |
| 17 | class Browser; |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 18 | class Profile; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 19 | |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 20 | namespace base { |
| 21 | class Value; |
| 22 | } |
| 23 | |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 24 | namespace content { |
| 25 | class WebContents; |
| 26 | } |
| 27 | |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame] | 28 | namespace gfx { |
| 29 | class Rect; |
| 30 | } |
| 31 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 32 | // Implementation of LiveTabContext which uses an instance of |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 33 | // Browser in order to fulfil its duties. |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 34 | class BrowserLiveTabContext : public sessions::LiveTabContext { |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 35 | public: |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 36 | explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {} |
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 37 | |
| 38 | BrowserLiveTabContext(const BrowserLiveTabContext&) = delete; |
| 39 | BrowserLiveTabContext& operator=(const BrowserLiveTabContext&) = delete; |
| 40 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 41 | ~BrowserLiveTabContext() override {} |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 42 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 43 | // Overridden from LiveTabContext: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 44 | void ShowBrowserWindow() override; |
Mikel Astiz | e023c57 | 2018-03-28 07:56:56 | [diff] [blame] | 45 | SessionID GetSessionID() const override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 46 | int GetTabCount() const override; |
| 47 | int GetSelectedIndex() const override; |
| 48 | std::string GetAppName() const override; |
Elly Fong-Jones | 8bdc12b | 2020-09-19 00:02:00 | [diff] [blame] | 49 | std::string GetUserTitle() const override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 50 | sessions::LiveTab* GetLiveTabAt(int index) const override; |
| 51 | sessions::LiveTab* GetActiveLiveTab() const override; |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 52 | std::map<std::string, base::Value> GetExtraDataForTab( |
| 53 | int index) const override; |
| 54 | std::map<std::string, base::Value> GetExtraDataForWindow() const override; |
Anton Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 55 | absl::optional<tab_groups::TabGroupId> GetTabGroupForTab( |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 56 | int index) const override; |
Connie Wan | dfd8f83 | 2020-01-06 20:22:30 | [diff] [blame] | 57 | const tab_groups::TabGroupVisualData* GetVisualDataForGroup( |
| 58 | const tab_groups::TabGroupId& group) const override; |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 59 | bool IsTabPinned(int index) const override; |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 60 | void SetVisualDataForGroup( |
Connie Wan | dfd8f83 | 2020-01-06 20:22:30 | [diff] [blame] | 61 | const tab_groups::TabGroupId& group, |
| 62 | const tab_groups::TabGroupVisualData& visual_data) override; |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame] | 63 | const gfx::Rect GetRestoredBounds() const override; |
| 64 | ui::WindowShowState GetRestoredState() const override; |
| 65 | std::string GetWorkspace() const override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 66 | sessions::LiveTab* AddRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 67 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 68 | int tab_index, |
| 69 | int selected_navigation, |
| 70 | const std::string& extension_app_id, |
Anton Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 71 | absl::optional<tab_groups::TabGroupId> group, |
Connie Wan | dfd8f83 | 2020-01-06 20:22:30 | [diff] [blame] | 72 | const tab_groups::TabGroupVisualData& group_visual_data, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 73 | bool select, |
| 74 | bool pin, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 75 | const sessions::PlatformSpecificTabData* storage_namespace, |
Sreeja Kamishetty | 673efca | 2020-12-02 08:08:06 | [diff] [blame] | 76 | const sessions::SerializedUserAgentOverride& user_agent_override, |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 77 | const std::map<std::string, base::Value>& extra_data, |
Sreeja Kamishetty | 673efca | 2020-12-02 08:08:06 | [diff] [blame] | 78 | const SessionID* tab_id) override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 79 | sessions::LiveTab* ReplaceRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 80 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
Anton Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 81 | absl::optional<tab_groups::TabGroupId> group, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 82 | int selected_navigation, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 83 | const std::string& extension_app_id, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 84 | const sessions::PlatformSpecificTabData* tab_platform_data, |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 85 | const sessions::SerializedUserAgentOverride& user_agent_override, |
| 86 | const std::map<std::string, base::Value>& extra_data) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 87 | void CloseTab() override; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 88 | |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 89 | // see Browser::Create |
Roman Arora | fa79458 | 2021-11-12 00:42:37 | [diff] [blame] | 90 | static sessions::LiveTabContext* Create( |
| 91 | Profile* profile, |
| 92 | const std::string& app_name, |
| 93 | const gfx::Rect& bounds, |
| 94 | ui::WindowShowState show_state, |
| 95 | const std::string& workspace, |
| 96 | const std::string& user_title, |
| 97 | const std::map<std::string, base::Value>& extra_data); |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 98 | |
| 99 | // see browser::FindBrowserForWebContents |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 100 | static sessions::LiveTabContext* FindContextForWebContents( |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 101 | const content::WebContents* contents); |
| 102 | |
| 103 | // see chrome::FindBrowserWithID |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 104 | // Returns the LiveTabContext of the Browser with |desired_id| if |
scottmg | d161e6c | 2016-02-17 02:08:01 | [diff] [blame] | 105 | // such a Browser exists. |
Mikel Astiz | 2f127c42 | 2018-04-05 19:10:27 | [diff] [blame] | 106 | static sessions::LiveTabContext* FindContextWithID(SessionID desired_id); |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 107 | |
Connie Wan | b56d7e2 | 2020-08-01 00:54:41 | [diff] [blame] | 108 | // see chrome::FindBrowserWithGroup |
| 109 | // Returns the LiveTabContext of the Browser containing the group with ID |
| 110 | // |group| if such a Browser exists within the given |profile|. |
| 111 | static sessions::LiveTabContext* FindContextWithGroup( |
Connie Wan | e1deeafb | 2020-08-06 18:13:09 | [diff] [blame] | 112 | tab_groups::TabGroupId group, |
| 113 | Profile* profile); |
Connie Wan | b56d7e2 | 2020-08-01 00:54:41 | [diff] [blame] | 114 | |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 115 | private: |
Lei Zhang | 8bd9882c | 2017-11-28 21:24:08 | [diff] [blame] | 116 | Browser* const browser_; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 117 | }; |
| 118 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 119 | #endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |