blob: af211d93e9379f8c9d3e2591832d64da0beaf39b [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
Roman Arorafa794582021-11-12 00:42:378#include <map>
[email protected]fb7da4132011-03-15 15:51:009#include <string>
10#include <vector>
11
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
Roman Arorafa794582021-11-12 00:42:3720namespace base {
21class Value;
22}
23
blundell80c5b2a02015-09-17 18:22:1224namespace content {
25class WebContents;
26}
27
chrishab1ba090f2017-08-18 22:00:5028namespace gfx {
29class Rect;
30}
31
blundellbde024d2015-09-30 13:47:0732// Implementation of LiveTabContext which uses an instance of
[email protected]fb7da4132011-03-15 15:51:0033// Browser in order to fulfil its duties.
blundellbde024d2015-09-30 13:47:0734class BrowserLiveTabContext : public sessions::LiveTabContext {
[email protected]fb7da4132011-03-15 15:51:0035 public:
blundellbde024d2015-09-30 13:47:0736 explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {}
Peter Boström53c6c5952021-09-17 09:41:2637
38 BrowserLiveTabContext(const BrowserLiveTabContext&) = delete;
39 BrowserLiveTabContext& operator=(const BrowserLiveTabContext&) = delete;
40
blundellbde024d2015-09-30 13:47:0741 ~BrowserLiveTabContext() override {}
[email protected]fb7da4132011-03-15 15:51:0042
blundellbde024d2015-09-30 13:47:0743 // Overridden from LiveTabContext:
dcheng5dd5ff62014-10-21 12:42:3844 void ShowBrowserWindow() override;
Mikel Astize023c572018-03-28 07:56:5645 SessionID GetSessionID() const override;
dcheng5dd5ff62014-10-21 12:42:3846 int GetTabCount() const override;
47 int GetSelectedIndex() const override;
48 std::string GetAppName() const override;
Elly Fong-Jones8bdc12b2020-09-19 00:02:0049 std::string GetUserTitle() const override;
blundell80c5b2a02015-09-17 18:22:1250 sessions::LiveTab* GetLiveTabAt(int index) const override;
51 sessions::LiveTab* GetActiveLiveTab() const override;
Roman Arorafa794582021-11-12 00:42:3752 std::map<std::string, base::Value> GetExtraDataForTab(
53 int index) const override;
54 std::map<std::string, base::Value> GetExtraDataForWindow() const override;
Anton Bikineev46bbb972021-05-15 17:53:5355 absl::optional<tab_groups::TabGroupId> GetTabGroupForTab(
Connie Wan866179b2019-12-18 21:39:3356 int index) const override;
Connie Wandfd8f832020-01-06 20:22:3057 const tab_groups::TabGroupVisualData* GetVisualDataForGroup(
58 const tab_groups::TabGroupId& group) const override;
Roman Arorafa794582021-11-12 00:42:3759 bool IsTabPinned(int index) const override;
Connie Wan866179b2019-12-18 21:39:3360 void SetVisualDataForGroup(
Connie Wandfd8f832020-01-06 20:22:3061 const tab_groups::TabGroupId& group,
62 const tab_groups::TabGroupVisualData& visual_data) override;
chrishab1ba090f2017-08-18 22:00:5063 const gfx::Rect GetRestoredBounds() const override;
64 ui::WindowShowState GetRestoredState() const override;
65 std::string GetWorkspace() const override;
blundell80c5b2a02015-09-17 18:22:1266 sessions::LiveTab* AddRestoredTab(
[email protected]40a7e412013-04-29 18:13:0167 const std::vector<sessions::SerializedNavigationEntry>& navigations,
[email protected]fb7da4132011-03-15 15:51:0068 int tab_index,
69 int selected_navigation,
70 const std::string& extension_app_id,
Anton Bikineev46bbb972021-05-15 17:53:5371 absl::optional<tab_groups::TabGroupId> group,
Connie Wandfd8f832020-01-06 20:22:3072 const tab_groups::TabGroupVisualData& group_visual_data,
[email protected]fb7da4132011-03-15 15:51:0073 bool select,
74 bool pin,
blundell579e373e2015-09-22 07:04:4375 const sessions::PlatformSpecificTabData* storage_namespace,
Sreeja Kamishetty673efca2020-12-02 08:08:0676 const sessions::SerializedUserAgentOverride& user_agent_override,
Roman Arorafa794582021-11-12 00:42:3777 const std::map<std::string, base::Value>& extra_data,
Sreeja Kamishetty673efca2020-12-02 08:08:0678 const SessionID* tab_id) override;
blundell80c5b2a02015-09-17 18:22:1279 sessions::LiveTab* ReplaceRestoredTab(
[email protected]40a7e412013-04-29 18:13:0180 const std::vector<sessions::SerializedNavigationEntry>& navigations,
Anton Bikineev46bbb972021-05-15 17:53:5381 absl::optional<tab_groups::TabGroupId> group,
[email protected]fb7da4132011-03-15 15:51:0082 int selected_navigation,
[email protected]fb7da4132011-03-15 15:51:0083 const std::string& extension_app_id,
blundell579e373e2015-09-22 07:04:4384 const sessions::PlatformSpecificTabData* tab_platform_data,
Roman Arorafa794582021-11-12 00:42:3785 const sessions::SerializedUserAgentOverride& user_agent_override,
86 const std::map<std::string, base::Value>& extra_data) override;
dcheng5dd5ff62014-10-21 12:42:3887 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0088
blundell7bf49a3d2015-09-14 18:38:1189 // see Browser::Create
Roman Arorafa794582021-11-12 00:42:3790 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);
blundell7bf49a3d2015-09-14 18:38:1198
99 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:07100 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:11101 const content::WebContents* contents);
102
103 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:07104 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:01105 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:27106 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:11107
Connie Wanb56d7e22020-08-01 00:54:41108 // 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 Wane1deeafb2020-08-06 18:13:09112 tab_groups::TabGroupId group,
113 Profile* profile);
Connie Wanb56d7e22020-08-01 00:54:41114
[email protected]fb7da4132011-03-15 15:51:00115 private:
Lei Zhang8bd9882c2017-11-28 21:24:08116 Browser* const browser_;
[email protected]fb7da4132011-03-15 15:51:00117};
118
blundellbde024d2015-09-30 13:47:07119#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_