blob: 68322c8cdcf3a4715d2d4f9b12041a3b68453d3a [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,
mostynb205d6252014-10-04 00:49:2267 const std::string& user_agent_override) override;
blundell80c5b2a02015-09-17 18:22:1268 sessions::LiveTab* ReplaceRestoredTab(
[email protected]40a7e412013-04-29 18:13:0169 const std::vector<sessions::SerializedNavigationEntry>& navigations,
Connie Wan866179b2019-12-18 21:39:3370 base::Optional<tab_groups::TabGroupId> group,
[email protected]fb7da4132011-03-15 15:51:0071 int selected_navigation,
72 bool from_last_session,
73 const std::string& extension_app_id,
blundell579e373e2015-09-22 07:04:4374 const sessions::PlatformSpecificTabData* tab_platform_data,
mostynb205d6252014-10-04 00:49:2275 const std::string& user_agent_override) override;
dcheng5dd5ff62014-10-21 12:42:3876 void CloseTab() override;
[email protected]fb7da4132011-03-15 15:51:0077
blundell7bf49a3d2015-09-14 18:38:1178 // see Browser::Create
chrishab1ba090f2017-08-18 22:00:5079 static sessions::LiveTabContext* Create(Profile* profile,
80 const std::string& app_name,
81 const gfx::Rect& bounds,
82 ui::WindowShowState show_state,
83 const std::string& workspace);
blundell7bf49a3d2015-09-14 18:38:1184
85 // see browser::FindBrowserForWebContents
blundellbde024d2015-09-30 13:47:0786 static sessions::LiveTabContext* FindContextForWebContents(
blundell7bf49a3d2015-09-14 18:38:1187 const content::WebContents* contents);
88
89 // see chrome::FindBrowserWithID
blundellbde024d2015-09-30 13:47:0790 // Returns the LiveTabContext of the Browser with |desired_id| if
scottmgd161e6c2016-02-17 02:08:0191 // such a Browser exists.
Mikel Astiz2f127c422018-04-05 19:10:2792 static sessions::LiveTabContext* FindContextWithID(SessionID desired_id);
blundell7bf49a3d2015-09-14 18:38:1193
[email protected]fb7da4132011-03-15 15:51:0094 private:
Lei Zhang8bd9882c2017-11-28 21:24:0895 Browser* const browser_;
[email protected]fb7da4132011-03-15 15:51:0096
blundellbde024d2015-09-30 13:47:0797 DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext);
[email protected]fb7da4132011-03-15 15:51:0098};
99
blundellbde024d2015-09-30 13:47:07100#endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_