blob: f1b4a51bd0ac237b2d6c44a4353330495297c587 [file] [log] [blame]
[email protected]a636d8e52012-02-28 15:40:411// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]fb7da4132011-03-15 15:51:002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
blundellbde024d2015-09-30 13:47:075#ifndef CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_
6#define CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_
[email protected]fb7da4132011-03-15 15:51:007
8#include <string>
9#include <vector>
10
11#include "base/compiler_specific.h"
blundellbde024d2015-09-30 13:47:0712#include "components/sessions/core/live_tab_context.h"
Connie Wan866179b2019-12-18 21:39:3313#include "components/tab_groups/tab_group_id.h"
14#include "components/tab_groups/tab_group_visual_data.h"
chrishab1ba090f2017-08-18 22:00:5015#include "ui/base/ui_base_types.h"
[email protected]fb7da4132011-03-15 15:51:0016
17class Browser;
blundell7bf49a3d2015-09-14 18:38:1118class Profile;
[email protected]fb7da4132011-03-15 15:51:0019
blundell80c5b2a02015-09-17 18:22:1220namespace content {
21class WebContents;
22}
23
chrishab1ba090f2017-08-18 22:00:5024namespace gfx {
25class Rect;
26}
27
blundellbde024d2015-09-30 13:47:0728// Implementation of LiveTabContext which uses an instance of
[email protected]fb7da4132011-03-15 15:51:0029// Browser in order to fulfil its duties.
blundellbde024d2015-09-30 13:47:0730class BrowserLiveTabContext : public sessions::LiveTabContext {
[email protected]fb7da4132011-03-15 15:51:0031 public:
blundellbde024d2015-09-30 13:47:0732 explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {}
Peter Boström53c6c5952021-09-17 09:41:2633
34 BrowserLiveTabContext(const BrowserLiveTabContext&) = delete;
35 BrowserLiveTabContext& operator=(const BrowserLiveTabContext&) = delete;
36
blundellbde024d2015-09-30 13:47:0737 ~BrowserLiveTabContext() override {}
[email protected]fb7da4132011-03-15 15:51:0038
blundellbde024d2015-09-30 13:47:0739 // Overridden from LiveTabContext:
dcheng5dd5ff62014-10-21 12:42:3840 void ShowBrowserWindow() override;
Mikel Astize023c572018-03-28 07:56:5641 SessionID GetSessionID() const override;
dcheng5dd5ff62014-10-21 12:42:3842 int GetTabCount() const override;
43 int GetSelectedIndex() const override;
44 std::string GetAppName() const override;
Elly Fong-Jones8bdc12b2020-09-19 00:02:0045 std::string GetUserTitle() const override;
blundell80c5b2a02015-09-17 18:22:1246 sessions::LiveTab* GetLiveTabAt(int index) const override;
47 sessions::LiveTab* GetActiveLiveTab() const override;
dcheng5dd5ff62014-10-21 12:42:3848 bool IsTabPinned(int index) const override;
Anton Bikineev46bbb972021-05-15 17:53:5349 absl::optional<tab_groups::TabGroupId> GetTabGroupForTab(
Connie Wan866179b2019-12-18 21:39:3350 int index) const override;
Connie Wandfd8f832020-01-06 20:22:3051 const tab_groups::TabGroupVisualData* GetVisualDataForGroup(
52 const tab_groups::TabGroupId& group) const override;
Connie Wan866179b2019-12-18 21:39:3353 void SetVisualDataForGroup(
Connie Wandfd8f832020-01-06 20:22:3054 const tab_groups::TabGroupId& group,
55 const tab_groups::TabGroupVisualData& visual_data) override;
chrishab1ba090f2017-08-18 22:00:5056 const gfx::Rect GetRestoredBounds() const override;
57 ui::WindowShowState GetRestoredState() const override;
58 std::string GetWorkspace() const override;
59
blundell80c5b2a02015-09-17 18:22:1260 sessions::LiveTab* AddRestoredTab(
[email protected]40a7e412013-04-29 18:13:0161 const std::vector<sessions::SerializedNavigationEntry>& navigations,
[email protected]fb7da4132011-03-15 15:51:0062 int tab_index,
63 int selected_navigation,
64 const std::string& extension_app_id,
Anton Bikineev46bbb972021-05-15 17:53:5365 absl::optional<tab_groups::TabGroupId> group,
Connie Wandfd8f832020-01-06 20:22:3066 const tab_groups::TabGroupVisualData& group_visual_data,
[email protected]fb7da4132011-03-15 15:51:0067 bool select,
68 bool pin,
blundell579e373e2015-09-22 07:04:4369 const sessions::PlatformSpecificTabData* storage_namespace,
Sreeja Kamishetty673efca2020-12-02 08:08:0670 const sessions::SerializedUserAgentOverride& user_agent_override,
71 const SessionID* tab_id) override;
blundell80c5b2a02015-09-17 18:22:1272 sessions::LiveTab* ReplaceRestoredTab(
[email protected]40a7e412013-04-29 18:13:0173 const std::vector<sessions::SerializedNavigationEntry>& navigations,
Anton Bikineev46bbb972021-05-15 17:53:5374 absl::optional<tab_groups::TabGroupId> group,
[email protected]fb7da4132011-03-15 15:51:0075 int selected_navigation,
[email protected]fb7da4132011-03-15 15:51:0076 const std::string& extension_app_id,
blundell579e373e2015-09-22 07:04:4377 const sessions::PlatformSpecificTabData* tab_platform_data,
Maks Orlovich303126962020-04-06 21:34:2578 const sessions::SerializedUserAgentOverride& user_agent_override)
79 override;
dcheng5dd5ff62014-10-21 12:42:3880 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0081
blundell7bf49a3d2015-09-14 18:38:1182 // see Browser::Create
chrishab1ba090f2017-08-18 22:00:5083 static sessions::LiveTabContext* Create(Profile* profile,
84 const std::string& app_name,
85 const gfx::Rect& bounds,
86 ui::WindowShowState show_state,
Elly Fong-Jones8bdc12b2020-09-19 00:02:0087 const std::string& workspace,
88 const std::string& user_title);
blundell7bf49a3d2015-09-14 18:38:1189
90 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:0791 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:1192 const content::WebContents* contents);
93
94 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:0795 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:0196 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:2797 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:1198
Connie Wanb56d7e22020-08-01 00:54:4199 // see chrome::FindBrowserWithGroup
100 // Returns the LiveTabContext of the Browser containing the group with ID
101 // |group| if such a Browser exists within the given |profile|.
102 static sessions::LiveTabContext* FindContextWithGroup(
Connie Wane1deeafb2020-08-06 18:13:09103 tab_groups::TabGroupId group,
104 Profile* profile);
Connie Wanb56d7e22020-08-01 00:54:41105
[email protected]fb7da4132011-03-15 15:51:00106 private:
Lei Zhang8bd9882c2017-11-28 21:24:08107 Browser* const browser_;
[email protected]fb7da4132011-03-15 15:51:00108};
109
blundellbde024d2015-09-30 13:47:07110#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_