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