blob: 220eb1e9923d0760c05fd9bb8efe9dbe8fb2c641 [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) {}
34 ~BrowserLiveTabContext() override {}
[email protected]fb7da4132011-03-15 15:51:0035
blundellbde024d2015-09-30 13:47:0736 // Overridden from LiveTabContext:
dcheng5dd5ff62014-10-21 12:42:3837 void ShowBrowserWindow() override;
Mikel Astize023c572018-03-28 07:56:5638 SessionID GetSessionID() const override;
dcheng5dd5ff62014-10-21 12:42:3839 int GetTabCount() const override;
40 int GetSelectedIndex() const override;
41 std::string GetAppName() const override;
Elly Fong-Jones8bdc12b2020-09-19 00:02:0042 std::string GetUserTitle() const override;
blundell80c5b2a02015-09-17 18:22:1243 sessions::LiveTab* GetLiveTabAt(int index) const override;
44 sessions::LiveTab* GetActiveLiveTab() const override;
dcheng5dd5ff62014-10-21 12:42:3845 bool IsTabPinned(int index) const override;
Connie Wan866179b2019-12-18 21:39:3346 base::Optional<tab_groups::TabGroupId> GetTabGroupForTab(
47 int index) const override;
Connie Wandfd8f832020-01-06 20:22:3048 const tab_groups::TabGroupVisualData* GetVisualDataForGroup(
49 const tab_groups::TabGroupId& group) const override;
Connie Wan866179b2019-12-18 21:39:3350 void SetVisualDataForGroup(
Connie Wandfd8f832020-01-06 20:22:3051 const tab_groups::TabGroupId& group,
52 const tab_groups::TabGroupVisualData& visual_data) override;
chrishab1ba090f2017-08-18 22:00:5053 const gfx::Rect GetRestoredBounds() const override;
54 ui::WindowShowState GetRestoredState() const override;
55 std::string GetWorkspace() const override;
56
blundell80c5b2a02015-09-17 18:22:1257 sessions::LiveTab* AddRestoredTab(
[email protected]40a7e412013-04-29 18:13:0158 const std::vector<sessions::SerializedNavigationEntry>& navigations,
[email protected]fb7da4132011-03-15 15:51:0059 int tab_index,
60 int selected_navigation,
61 const std::string& extension_app_id,
Connie Wan866179b2019-12-18 21:39:3362 base::Optional<tab_groups::TabGroupId> group,
Connie Wandfd8f832020-01-06 20:22:3063 const tab_groups::TabGroupVisualData& group_visual_data,
[email protected]fb7da4132011-03-15 15:51:0064 bool select,
65 bool pin,
66 bool from_last_session,
blundell579e373e2015-09-22 07:04:4367 const sessions::PlatformSpecificTabData* storage_namespace,
Maks Orlovich303126962020-04-06 21:34:2568 const sessions::SerializedUserAgentOverride& user_agent_override)
69 override;
blundell80c5b2a02015-09-17 18:22:1270 sessions::LiveTab* ReplaceRestoredTab(
[email protected]40a7e412013-04-29 18:13:0171 const std::vector<sessions::SerializedNavigationEntry>& navigations,
Connie Wan866179b2019-12-18 21:39:3372 base::Optional<tab_groups::TabGroupId> group,
[email protected]fb7da4132011-03-15 15:51:0073 int selected_navigation,
74 bool from_last_session,
75 const std::string& extension_app_id,
blundell579e373e2015-09-22 07:04:4376 const sessions::PlatformSpecificTabData* tab_platform_data,
Maks Orlovich303126962020-04-06 21:34:2577 const sessions::SerializedUserAgentOverride& user_agent_override)
78 override;
dcheng5dd5ff62014-10-21 12:42:3879 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0080
blundell7bf49a3d2015-09-14 18:38:1181 // see Browser::Create
chrishab1ba090f2017-08-18 22:00:5082 static sessions::LiveTabContext* Create(Profile* profile,
83 const std::string& app_name,
84 const gfx::Rect& bounds,
85 ui::WindowShowState show_state,
Elly Fong-Jones8bdc12b2020-09-19 00:02:0086 const std::string& workspace,
87 const std::string& user_title);
blundell7bf49a3d2015-09-14 18:38:1188
89 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:0790 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:1191 const content::WebContents* contents);
92
93 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:0794 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:0195 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:2796 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:1197
Connie Wanb56d7e22020-08-01 00:54:4198 // see chrome::FindBrowserWithGroup
99 // Returns the LiveTabContext of the Browser containing the group with ID
100 // |group| if such a Browser exists within the given |profile|.
101 static sessions::LiveTabContext* FindContextWithGroup(
Connie Wane1deeafb2020-08-06 18:13:09102 tab_groups::TabGroupId group,
103 Profile* profile);
Connie Wanb56d7e22020-08-01 00:54:41104
[email protected]fb7da4132011-03-15 15:51:00105 private:
Lei Zhang8bd9882c2017-11-28 21:24:08106 Browser* const browser_;
[email protected]fb7da4132011-03-15 15:51:00107
blundellbde024d2015-09-30 13:47:07108 DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext);
[email protected]fb7da4132011-03-15 15:51:00109};
110
blundellbde024d2015-09-30 13:47:07111#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_