[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" |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 12 | #include "chrome/browser/ui/host_desktop.h" |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 13 | #include "components/sessions/core/live_tab_context.h" |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 14 | |
| 15 | class Browser; |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 16 | class Profile; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 17 | |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 18 | namespace content { |
| 19 | class WebContents; |
| 20 | } |
| 21 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 22 | // Implementation of LiveTabContext which uses an instance of |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 23 | // Browser in order to fulfil its duties. |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 24 | class BrowserLiveTabContext : public sessions::LiveTabContext { |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 25 | public: |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 26 | explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {} |
| 27 | ~BrowserLiveTabContext() override {} |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 28 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 29 | // Overridden from LiveTabContext: |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 30 | void ShowBrowserWindow() override; |
| 31 | const SessionID& GetSessionID() const override; |
| 32 | int GetTabCount() const override; |
| 33 | int GetSelectedIndex() const override; |
| 34 | std::string GetAppName() const override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 35 | sessions::LiveTab* GetLiveTabAt(int index) const override; |
| 36 | sessions::LiveTab* GetActiveLiveTab() const override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 37 | bool IsTabPinned(int index) const override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 38 | sessions::LiveTab* AddRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 39 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 40 | int tab_index, |
| 41 | int selected_navigation, |
| 42 | const std::string& extension_app_id, |
| 43 | bool select, |
| 44 | bool pin, |
| 45 | bool from_last_session, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 46 | const sessions::PlatformSpecificTabData* storage_namespace, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 47 | const std::string& user_agent_override) override; |
blundell | 80c5b2a0 | 2015-09-17 18:22:12 | [diff] [blame] | 48 | sessions::LiveTab* ReplaceRestoredTab( |
[email protected] | 40a7e41 | 2013-04-29 18:13:01 | [diff] [blame] | 49 | const std::vector<sessions::SerializedNavigationEntry>& navigations, |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 50 | int selected_navigation, |
| 51 | bool from_last_session, |
| 52 | const std::string& extension_app_id, |
blundell | 579e373e | 2015-09-22 07:04:43 | [diff] [blame] | 53 | const sessions::PlatformSpecificTabData* tab_platform_data, |
mostynb | 205d625 | 2014-10-04 00:49:22 | [diff] [blame] | 54 | const std::string& user_agent_override) override; |
dcheng | 5dd5ff6 | 2014-10-21 12:42:38 | [diff] [blame] | 55 | void CloseTab() override; |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 56 | |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 57 | // see Browser::Create |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 58 | static sessions::LiveTabContext* Create( |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 59 | Profile* profile, |
| 60 | chrome::HostDesktopType host_desktop_type, |
| 61 | const std::string& app_name); |
| 62 | |
| 63 | // see browser::FindBrowserForWebContents |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 64 | static sessions::LiveTabContext* FindContextForWebContents( |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 65 | const content::WebContents* contents); |
| 66 | |
| 67 | // see chrome::FindBrowserWithID |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 68 | // Returns the LiveTabContext of the Browser with |desired_id| if |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 69 | // such a Browser exists and is on the desktop defined by |host_desktop_type|. |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 70 | static sessions::LiveTabContext* FindContextWithID( |
blundell | 7bf49a3d | 2015-09-14 18:38:11 | [diff] [blame] | 71 | SessionID::id_type desired_id, |
| 72 | chrome::HostDesktopType host_desktop_type); |
| 73 | |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 74 | private: |
| 75 | Browser* browser_; |
| 76 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 77 | DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext); |
[email protected] | fb7da413 | 2011-03-15 15:51:00 | [diff] [blame] | 78 | }; |
| 79 | |
blundell | bde024d | 2015-09-30 13:47:07 | [diff] [blame^] | 80 | #endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ |