blob: ad221e6bb0a1c3aa21b988def39763a711068ba7 [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"
avi655876a2015-12-25 07:18:1512#include "base/macros.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
blundell80c5b2a02015-09-17 18:22:1221namespace content {
22class WebContents;
23}
24
chrishab1ba090f2017-08-18 22:00:5025namespace gfx {
26class Rect;
27}
28
blundellbde024d2015-09-30 13:47:0729// Implementation of LiveTabContext which uses an instance of
[email protected]fb7da4132011-03-15 15:51:0030// Browser in order to fulfil its duties.
blundellbde024d2015-09-30 13:47:0731class BrowserLiveTabContext : public sessions::LiveTabContext {
[email protected]fb7da4132011-03-15 15:51:0032 public:
blundellbde024d2015-09-30 13:47:0733 explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {}
Peter Boström53c6c5952021-09-17 09:41:2634
35 BrowserLiveTabContext(const BrowserLiveTabContext&) = delete;
36 BrowserLiveTabContext& operator=(const BrowserLiveTabContext&) = delete;
37
blundellbde024d2015-09-30 13:47:0738 ~BrowserLiveTabContext() override {}
[email protected]fb7da4132011-03-15 15:51:0039
blundellbde024d2015-09-30 13:47:0740 // Overridden from LiveTabContext:
dcheng5dd5ff62014-10-21 12:42:3841 void ShowBrowserWindow() override;
Mikel Astize023c572018-03-28 07:56:5642 SessionID GetSessionID() const override;
dcheng5dd5ff62014-10-21 12:42:3843 int GetTabCount() const override;
44 int GetSelectedIndex() const override;
45 std::string GetAppName() const override;
Elly Fong-Jones8bdc12b2020-09-19 00:02:0046 std::string GetUserTitle() const override;
blundell80c5b2a02015-09-17 18:22:1247 sessions::LiveTab* GetLiveTabAt(int index) const override;
48 sessions::LiveTab* GetActiveLiveTab() const override;
dcheng5dd5ff62014-10-21 12:42:3849 bool IsTabPinned(int index) const override;
Anton Bikineev46bbb972021-05-15 17:53:5350 absl::optional<tab_groups::TabGroupId> GetTabGroupForTab(
Connie Wan866179b2019-12-18 21:39:3351 int index) const override;
Connie Wandfd8f832020-01-06 20:22:3052 const tab_groups::TabGroupVisualData* GetVisualDataForGroup(
53 const tab_groups::TabGroupId& group) const override;
Connie Wan866179b2019-12-18 21:39:3354 void SetVisualDataForGroup(
Connie Wandfd8f832020-01-06 20:22:3055 const tab_groups::TabGroupId& group,
56 const tab_groups::TabGroupVisualData& visual_data) override;
chrishab1ba090f2017-08-18 22:00:5057 const gfx::Rect GetRestoredBounds() const override;
58 ui::WindowShowState GetRestoredState() const override;
59 std::string GetWorkspace() const override;
60
blundell80c5b2a02015-09-17 18:22:1261 sessions::LiveTab* AddRestoredTab(
[email protected]40a7e412013-04-29 18:13:0162 const std::vector<sessions::SerializedNavigationEntry>& navigations,
[email protected]fb7da4132011-03-15 15:51:0063 int tab_index,
64 int selected_navigation,
65 const std::string& extension_app_id,
Anton Bikineev46bbb972021-05-15 17:53:5366 absl::optional<tab_groups::TabGroupId> group,
Connie Wandfd8f832020-01-06 20:22:3067 const tab_groups::TabGroupVisualData& group_visual_data,
[email protected]fb7da4132011-03-15 15:51:0068 bool select,
69 bool pin,
blundell579e373e2015-09-22 07:04:4370 const sessions::PlatformSpecificTabData* storage_namespace,
Sreeja Kamishetty673efca2020-12-02 08:08:0671 const sessions::SerializedUserAgentOverride& user_agent_override,
72 const SessionID* tab_id) override;
blundell80c5b2a02015-09-17 18:22:1273 sessions::LiveTab* ReplaceRestoredTab(
[email protected]40a7e412013-04-29 18:13:0174 const std::vector<sessions::SerializedNavigationEntry>& navigations,
Anton Bikineev46bbb972021-05-15 17:53:5375 absl::optional<tab_groups::TabGroupId> group,
[email protected]fb7da4132011-03-15 15:51:0076 int selected_navigation,
[email protected]fb7da4132011-03-15 15:51:0077 const std::string& extension_app_id,
blundell579e373e2015-09-22 07:04:4378 const sessions::PlatformSpecificTabData* tab_platform_data,
Maks Orlovich303126962020-04-06 21:34:2579 const sessions::SerializedUserAgentOverride& user_agent_override)
80 override;
dcheng5dd5ff62014-10-21 12:42:3881 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0082
blundell7bf49a3d2015-09-14 18:38:1183 // see Browser::Create
chrishab1ba090f2017-08-18 22:00:5084 static sessions::LiveTabContext* Create(Profile* profile,
85 const std::string& app_name,
86 const gfx::Rect& bounds,
87 ui::WindowShowState show_state,
Elly Fong-Jones8bdc12b2020-09-19 00:02:0088 const std::string& workspace,
89 const std::string& user_title);
blundell7bf49a3d2015-09-14 18:38:1190
91 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:0792 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:1193 const content::WebContents* contents);
94
95 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:0796 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:0197 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:2798 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:1199
Connie Wanb56d7e22020-08-01 00:54:41100 // see chrome::FindBrowserWithGroup
101 // Returns the LiveTabContext of the Browser containing the group with ID
102 // |group| if such a Browser exists within the given |profile|.
103 static sessions::LiveTabContext* FindContextWithGroup(
Connie Wane1deeafb2020-08-06 18:13:09104 tab_groups::TabGroupId group,
105 Profile* profile);
Connie Wanb56d7e22020-08-01 00:54:41106
[email protected]fb7da4132011-03-15 15:51:00107 private:
Lei Zhang8bd9882c2017-11-28 21:24:08108 Browser* const browser_;
[email protected]fb7da4132011-03-15 15:51:00109};
110
blundellbde024d2015-09-30 13:47:07111#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_