[email protected] | a636d8e5 | 2012-02-28 15:40:41 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |
| 6 | #define CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/compiler_specific.h" |
avi | 655876a | 2015-12-25 07:18:15 | [diff] [blame] | 12 | #include "base/macros.h" |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 13 | #include "components/sessions/core/live_tab_context.h" |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame^] | 14 | #include "ui/base/ui_base_types.h" |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 15 | |
| 16 | class Browser; |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 17 | class Profile; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 18 | |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 19 | namespace content { |
| 20 | class WebContents; |
| 21 | } |
| 22 | |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame^] | 23 | namespace gfx { |
| 24 | class Rect; |
| 25 | } |
| 26 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 27 | // Implementation of LiveTabContext which uses an instance of |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 28 | // Browser in order to fulfil its duties. |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 29 | class BrowserLiveTabContext : public sessions::LiveTabContext { |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 30 | public: |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 31 | explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {} |
| 32 | ~BrowserLiveTabContext() override {} |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 33 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 34 | // Overridden from LiveTabContext: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 35 | void ShowBrowserWindow() override; |
| 36 | const SessionID& GetSessionID() const override; |
| 37 | int GetTabCount() const override; |
| 38 | int GetSelectedIndex() const override; |
| 39 | std::string GetAppName() const override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 40 | sessions::LiveTab* GetLiveTabAt(int index) const override; |
| 41 | sessions::LiveTab* GetActiveLiveTab() const override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 42 | bool IsTabPinned(int index) const override; |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame^] | 43 | const gfx::Rect GetRestoredBounds() const override; |
| 44 | ui::WindowShowState GetRestoredState() const override; |
| 45 | std::string GetWorkspace() const override; |
| 46 | |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 47 | sessions::LiveTab* AddRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 48 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 49 | int tab_index, |
| 50 | int selected_navigation, |
| 51 | const std::string& extension_app_id, |
| 52 | bool select, |
| 53 | bool pin, |
| 54 | bool from_last_session, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 55 | const sessions::PlatformSpecificTabData* storage_namespace, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 56 | const std::string& user_agent_override) override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 57 | sessions::LiveTab* ReplaceRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 58 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 59 | int selected_navigation, |
| 60 | bool from_last_session, |
| 61 | const std::string& extension_app_id, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 62 | const sessions::PlatformSpecificTabData* tab_platform_data, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 63 | const std::string& user_agent_override) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 64 | void CloseTab() override; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 65 | |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 66 | // see Browser::Create |
chrisha | b1ba090f | 2017-08-18 22:00:50 | [diff] [blame^] | 67 | static sessions::LiveTabContext* Create(Profile* profile, |
| 68 | const std::string& app_name, |
| 69 | const gfx::Rect& bounds, |
| 70 | ui::WindowShowState show_state, |
| 71 | const std::string& workspace); |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 72 | |
| 73 | // see browser::FindBrowserForWebContents |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 74 | static sessions::LiveTabContext* FindContextForWebContents( |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 75 | const content::WebContents* contents); |
| 76 | |
| 77 | // see chrome::FindBrowserWithID |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 78 | // Returns the LiveTabContext of the Browser with |desired_id| if |
scottmg | d161e6c | 2016-02-17 02:08:01 | [diff] [blame] | 79 | // such a Browser exists. |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 80 | static sessions::LiveTabContext* FindContextWithID( |
scottmg | d161e6c | 2016-02-17 02:08:01 | [diff] [blame] | 81 | SessionID::id_type desired_id); |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 82 | |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 83 | private: |
| 84 | Browser* browser_; |
| 85 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 86 | DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext); |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 87 | }; |
| 88 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame] | 89 | #endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |