blob: 6f02b1467a6c38fc24e8b5fa9f2b21ec6065aa85 [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;
blundell80c5b2a02015-09-17 18:22:1242 sessions::LiveTab* GetLiveTabAt(int index) const override;
43 sessions::LiveTab* GetActiveLiveTab() const override;
dcheng5dd5ff62014-10-21 12:42:3844 bool IsTabPinned(int index) const override;
Connie Wan866179b2019-12-18 21:39:3345 base::Optional<tab_groups::TabGroupId> GetTabGroupForTab(
46 int index) const override;
Connie Wandfd8f832020-01-06 20:22:3047 const tab_groups::TabGroupVisualData* GetVisualDataForGroup(
48 const tab_groups::TabGroupId& group) const override;
Connie Wan866179b2019-12-18 21:39:3349 void SetVisualDataForGroup(
Connie Wandfd8f832020-01-06 20:22:3050 const tab_groups::TabGroupId& group,
51 const tab_groups::TabGroupVisualData& visual_data) override;
chrishab1ba090f2017-08-18 22:00:5052 const gfx::Rect GetRestoredBounds() const override;
53 ui::WindowShowState GetRestoredState() const override;
54 std::string GetWorkspace() const override;
55
blundell80c5b2a02015-09-17 18:22:1256 sessions::LiveTab* AddRestoredTab(
[email protected]40a7e412013-04-29 18:13:0157 const std::vector<sessions::SerializedNavigationEntry>& navigations,
[email protected]fb7da4132011-03-15 15:51:0058 int tab_index,
59 int selected_navigation,
60 const std::string& extension_app_id,
Connie Wan866179b2019-12-18 21:39:3361 base::Optional<tab_groups::TabGroupId> group,
Connie Wandfd8f832020-01-06 20:22:3062 const tab_groups::TabGroupVisualData& group_visual_data,
[email protected]fb7da4132011-03-15 15:51:0063 bool select,
64 bool pin,
65 bool from_last_session,
blundell579e373e2015-09-22 07:04:4366 const sessions::PlatformSpecificTabData* storage_namespace,
Maks Orlovich303126962020-04-06 21:34:2567 const sessions::SerializedUserAgentOverride& user_agent_override)
68 override;
blundell80c5b2a02015-09-17 18:22:1269 sessions::LiveTab* ReplaceRestoredTab(
[email protected]40a7e412013-04-29 18:13:0170 const std::vector<sessions::SerializedNavigationEntry>& navigations,
Connie Wan866179b2019-12-18 21:39:3371 base::Optional<tab_groups::TabGroupId> group,
[email protected]fb7da4132011-03-15 15:51:0072 int selected_navigation,
73 bool from_last_session,
74 const std::string& extension_app_id,
blundell579e373e2015-09-22 07:04:4375 const sessions::PlatformSpecificTabData* tab_platform_data,
Maks Orlovich303126962020-04-06 21:34:2576 const sessions::SerializedUserAgentOverride& user_agent_override)
77 override;
dcheng5dd5ff62014-10-21 12:42:3878 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0079
blundell7bf49a3d2015-09-14 18:38:1180 // see Browser::Create
chrishab1ba090f2017-08-18 22:00:5081 static sessions::LiveTabContext* Create(Profile* profile,
82 const std::string& app_name,
83 const gfx::Rect& bounds,
84 ui::WindowShowState show_state,
85 const std::string& workspace);
blundell7bf49a3d2015-09-14 18:38:1186
87 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:0788 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:1189 const content::WebContents* contents);
90
91 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:0792 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:0193 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:2794 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:1195
[email protected]fb7da4132011-03-15 15:51:0096 private:
Lei Zhang8bd9882c2017-11-28 21:24:0897 Browser* const browser_;
[email protected]fb7da4132011-03-15 15:51:0098
blundellbde024d2015-09-30 13:47:0799 DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext);
[email protected]fb7da4132011-03-15 15:51:00100};
101
blundellbde024d2015-09-30 13:47:07102#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_