blob: d9299eaf53c313bf58e0650455f3add8b289c104 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[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
Roman Arorafa794582021-11-12 00:42:378#include <map>
[email protected]fb7da4132011-03-15 15:51:009#include <string>
10#include <vector>
11
Keishi Hattori0e45c022021-11-27 09:25:5212#include "base/memory/raw_ptr.h"
blundellbde024d2015-09-30 13:47:0713#include "components/sessions/core/live_tab_context.h"
Connie Wan866179b2019-12-18 21:39:3314#include "components/tab_groups/tab_group_id.h"
15#include "components/tab_groups/tab_group_visual_data.h"
chrishab1ba090f2017-08-18 22:00:5016#include "ui/base/ui_base_types.h"
[email protected]fb7da4132011-03-15 15:51:0017
18class Browser;
blundell7bf49a3d2015-09-14 18:38:1119class Profile;
[email protected]fb7da4132011-03-15 15:51:0020
dljamesa0499b62024-03-26 21:49:3021namespace base {
22class Uuid;
23}
24
blundell80c5b2a02015-09-17 18:22:1225namespace content {
26class WebContents;
27}
28
chrishab1ba090f2017-08-18 22:00:5029namespace gfx {
30class Rect;
31}
32
blundellbde024d2015-09-30 13:47:0733// Implementation of LiveTabContext which uses an instance of
[email protected]fb7da4132011-03-15 15:51:0034// Browser in order to fulfil its duties.
blundellbde024d2015-09-30 13:47:0735class BrowserLiveTabContext : public sessions::LiveTabContext {
[email protected]fb7da4132011-03-15 15:51:0036 public:
blundellbde024d2015-09-30 13:47:0737 explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {}
Peter Boström53c6c5952021-09-17 09:41:2638
39 BrowserLiveTabContext(const BrowserLiveTabContext&) = delete;
40 BrowserLiveTabContext& operator=(const BrowserLiveTabContext&) = delete;
41
blundellbde024d2015-09-30 13:47:0742 ~BrowserLiveTabContext() override {}
[email protected]fb7da4132011-03-15 15:51:0043
blundellbde024d2015-09-30 13:47:0744 // Overridden from LiveTabContext:
dcheng5dd5ff62014-10-21 12:42:3845 void ShowBrowserWindow() override;
Mikel Astize023c572018-03-28 07:56:5646 SessionID GetSessionID() const override;
Joel Hockey38c33892022-06-09 01:51:1947 sessions::SessionWindow::WindowType GetWindowType() const override;
dcheng5dd5ff62014-10-21 12:42:3848 int GetTabCount() const override;
49 int GetSelectedIndex() const override;
50 std::string GetAppName() const override;
Elly Fong-Jones8bdc12b2020-09-19 00:02:0051 std::string GetUserTitle() const override;
blundell80c5b2a02015-09-17 18:22:1252 sessions::LiveTab* GetLiveTabAt(int index) const override;
53 sessions::LiveTab* GetActiveLiveTab() const override;
Roman Arora6fa01832021-12-01 00:25:4154 std::map<std::string, std::string> GetExtraDataForTab(
Roman Arorafa794582021-11-12 00:42:3755 int index) const override;
Roman Arora6fa01832021-12-01 00:25:4156 std::map<std::string, std::string> GetExtraDataForWindow() const override;
Mohamed Mansourbc071892023-12-07 04:08:0357 std::optional<tab_groups::TabGroupId> GetTabGroupForTab(
Connie Wan866179b2019-12-18 21:39:3358 int index) const override;
Connie Wandfd8f832020-01-06 20:22:3059 const tab_groups::TabGroupVisualData* GetVisualDataForGroup(
60 const tab_groups::TabGroupId& group) const override;
dljamesa0499b62024-03-26 21:49:3061 const std::optional<base::Uuid> GetSavedTabGroupIdForGroup(
62 const tab_groups::TabGroupId& group) const override;
Roman Arorafa794582021-11-12 00:42:3763 bool IsTabPinned(int index) const override;
Connie Wan866179b2019-12-18 21:39:3364 void SetVisualDataForGroup(
Connie Wandfd8f832020-01-06 20:22:3065 const tab_groups::TabGroupId& group,
66 const tab_groups::TabGroupVisualData& visual_data) override;
chrishab1ba090f2017-08-18 22:00:5067 const gfx::Rect GetRestoredBounds() const override;
68 ui::WindowShowState GetRestoredState() const override;
69 std::string GetWorkspace() const override;
dljames988d7c52024-04-18 18:04:3170 sessions::LiveTab* AddRestoredTab(const sessions::tab_restore::Tab& tab,
71 int tab_index,
72 bool select) override;
blundell80c5b2a02015-09-17 18:22:1273 sessions::LiveTab* ReplaceRestoredTab(
dljames988d7c52024-04-18 18:04:3174 const sessions::tab_restore::Tab& tab) override;
dcheng5dd5ff62014-10-21 12:42:3875 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0076
blundell7bf49a3d2015-09-14 18:38:1177 // see Browser::Create
Roman Arorafa794582021-11-12 00:42:3778 static sessions::LiveTabContext* Create(
79 Profile* profile,
Joel Hockey38c33892022-06-09 01:51:1980 sessions::SessionWindow::WindowType type,
Roman Arorafa794582021-11-12 00:42:3781 const std::string& app_name,
82 const gfx::Rect& bounds,
83 ui::WindowShowState show_state,
84 const std::string& workspace,
85 const std::string& user_title,
Roman Arora6fa01832021-12-01 00:25:4186 const std::map<std::string, std::string>& extra_data);
blundell7bf49a3d2015-09-14 18:38:1187
88 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:0789 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:1190 const content::WebContents* contents);
91
92 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:0793 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:0194 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:2795 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:1196
Connie Wanb56d7e22020-08-01 00:54:4197 // see chrome::FindBrowserWithGroup
98 // Returns the LiveTabContext of the Browser containing the group with ID
99 // |group| if such a Browser exists within the given |profile|.
100 static sessions::LiveTabContext* FindContextWithGroup(
Connie Wane1deeafb2020-08-06 18:13:09101 tab_groups::TabGroupId group,
102 Profile* profile);
Connie Wanb56d7e22020-08-01 00:54:41103
[email protected]fb7da4132011-03-15 15:51:00104 private:
Keishi Hattori0e45c022021-11-27 09:25:52105 const raw_ptr<Browser> browser_;
[email protected]fb7da4132011-03-15 15:51:00106};
107
blundellbde024d2015-09-30 13:47:07108#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_