[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; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 42 | sessions::LiveTab* GetLiveTabAt(int index) const override; |
| 43 | sessions::LiveTab* GetActiveLiveTab() const override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 44 | bool IsTabPinned(int index) const override; |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 45 | base::Optional<tab_groups::TabGroupId> GetTabGroupForTab( |
| 46 | int index) const override; |
Connie Wan | dfd8f83 | 2020-01-06 20:22:30 | [diff] [blame] | 47 | const tab_groups::TabGroupVisualData* GetVisualDataForGroup( |
| 48 | const tab_groups::TabGroupId& group) const override; |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 49 | void SetVisualDataForGroup( |
Connie Wan | dfd8f83 | 2020-01-06 20:22:30 | [diff] [blame] | 50 | const tab_groups::TabGroupId& group, |
| 51 | const tab_groups::TabGroupVisualData& visual_data) override; |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame] | 52 | const gfx::Rect GetRestoredBounds() const override; |
| 53 | ui::WindowShowState GetRestoredState() const override; |
| 54 | std::string GetWorkspace() const override; |
| 55 | |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 56 | sessions::LiveTab* AddRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 57 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 58 | int tab_index, |
| 59 | int selected_navigation, |
| 60 | const std::string& extension_app_id, |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 61 | base::Optional<tab_groups::TabGroupId> group, |
Connie Wan | dfd8f83 | 2020-01-06 20:22:30 | [diff] [blame] | 62 | const tab_groups::TabGroupVisualData& group_visual_data, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 63 | bool select, |
| 64 | bool pin, |
| 65 | bool from_last_session, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 66 | const sessions::PlatformSpecificTabData* storage_namespace, |
Maks Orlovich | 30312696 | 2020-04-06 21:34:25 | [diff] [blame^] | 67 | const sessions::SerializedUserAgentOverride& user_agent_override) |
| 68 | override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 69 | sessions::LiveTab* ReplaceRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 70 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
Connie Wan | 866179b | 2019-12-18 21:39:33 | [diff] [blame] | 71 | base::Optional<tab_groups::TabGroupId> group, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 72 | int selected_navigation, |
| 73 | bool from_last_session, |
| 74 | const std::string& extension_app_id, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 75 | const sessions::PlatformSpecificTabData* tab_platform_data, |
Maks Orlovich | 30312696 | 2020-04-06 21:34:25 | [diff] [blame^] | 76 | const sessions::SerializedUserAgentOverride& user_agent_override) |
| 77 | override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 78 | void CloseTab() override; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 79 | |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 80 | // see Browser::Create |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame] | 81 | static sessions::LiveTabContext* Create(Profile* profile, |
| 82 | const std::string& app_name, |
| 83 | const gfx::Rect& bounds, |
| 84 | ui::WindowShowState show_state, |
| 85 | const std::string& workspace); |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 86 | |
| 87 | // see browser::FindBrowserForWebContents |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 88 | static sessions::LiveTabContext* FindContextForWebContents( |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 89 | const content::WebContents* contents); |
| 90 | |
| 91 | // see chrome::FindBrowserWithID |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 92 | // Returns the LiveTabContext of the Browser with |desired_id| if |
scottmg | d161e6c | 2016-02-17 02:08:01 | [diff] [blame] | 93 | // such a Browser exists. |
Mikel Astiz | 2f127c42 | 2018-04-05 19:10:27 | [diff] [blame] | 94 | static sessions::LiveTabContext* FindContextWithID(SessionID desired_id); |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 95 | |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 96 | private: |
Lei Zhang | 8bd9882c | 2017-11-28 21:24:08 | [diff] [blame] | 97 | Browser* const browser_; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 98 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 99 | DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext); |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 100 | }; |
| 101 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 102 | #endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |