| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_UI_ANDROID_TAB_MODEL_ANDROID_LIVE_TAB_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ | 6 #define CHROME_BROWSER_UI_ANDROID_TAB_MODEL_ANDROID_LIVE_TAB_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/sessions/core/live_tab_context.h" | 13 #include "components/sessions/core/live_tab_context.h" |
| 14 | 14 |
| 15 class Browser; | |
| 16 class Profile; | |
| 17 | |
| 18 namespace content { | 15 namespace content { |
| 19 class WebContents; | 16 class WebContents; |
| 20 } | 17 } |
| 21 | 18 |
| 22 // Implementation of LiveTabContext which uses an instance of | 19 class TabModel; |
| 23 // Browser in order to fulfil its duties. | 20 |
| 24 class BrowserLiveTabContext : public sessions::LiveTabContext { | 21 // Implementation of LiveTabContext which is used by android. |
| 22 class AndroidLiveTabContext : public sessions::LiveTabContext { |
| 25 public: | 23 public: |
| 26 explicit BrowserLiveTabContext(Browser* browser) : browser_(browser) {} | 24 explicit AndroidLiveTabContext(TabModel* tab_model); |
| 27 ~BrowserLiveTabContext() override {} | 25 ~AndroidLiveTabContext() override {} |
| 28 | 26 |
| 29 // Overridden from LiveTabContext: | 27 // Overridden from LiveTabContext: |
| 30 void ShowBrowserWindow() override; | 28 void ShowBrowserWindow() override; |
| 31 const SessionID& GetSessionID() const override; | 29 const SessionID& GetSessionID() const override; |
| 32 int GetTabCount() const override; | 30 int GetTabCount() const override; |
| 33 int GetSelectedIndex() const override; | 31 int GetSelectedIndex() const override; |
| 34 std::string GetAppName() const override; | 32 std::string GetAppName() const override; |
| 35 sessions::LiveTab* GetLiveTabAt(int index) const override; | 33 sessions::LiveTab* GetLiveTabAt(int index) const override; |
| 36 sessions::LiveTab* GetActiveLiveTab() const override; | 34 sessions::LiveTab* GetActiveLiveTab() const override; |
| 37 bool IsTabPinned(int index) const override; | 35 bool IsTabPinned(int index) const override; |
| 38 sessions::LiveTab* AddRestoredTab( | 36 sessions::LiveTab* AddRestoredTab( |
| 39 const std::vector<sessions::SerializedNavigationEntry>& navigations, | 37 const std::vector<sessions::SerializedNavigationEntry>& navigations, |
| 40 int tab_index, | 38 int tab_index, |
| 41 int selected_navigation, | 39 int selected_navigation, |
| 42 const std::string& extension_app_id, | 40 const std::string& extension_app_id, |
| 43 bool select, | 41 bool select, |
| 44 bool pin, | 42 bool pin, |
| 45 bool from_last_session, | 43 bool from_last_session, |
| 46 const sessions::PlatformSpecificTabData* storage_namespace, | 44 const sessions::PlatformSpecificTabData* storage_namespace, |
| 47 const std::string& user_agent_override) override; | 45 const std::string& user_agent_override) override; |
| 48 sessions::LiveTab* ReplaceRestoredTab( | 46 sessions::LiveTab* ReplaceRestoredTab( |
| 49 const std::vector<sessions::SerializedNavigationEntry>& navigations, | 47 const std::vector<sessions::SerializedNavigationEntry>& navigations, |
| 50 int selected_navigation, | 48 int selected_navigation, |
| 51 bool from_last_session, | 49 bool from_last_session, |
| 52 const std::string& extension_app_id, | 50 const std::string& extension_app_id, |
| 53 const sessions::PlatformSpecificTabData* tab_platform_data, | 51 const sessions::PlatformSpecificTabData* tab_platform_data, |
| 54 const std::string& user_agent_override) override; | 52 const std::string& user_agent_override) override; |
| 55 void CloseTab() override; | 53 void CloseTab() override; |
| 56 | 54 |
| 57 // see Browser::Create | 55 static LiveTabContext* FindContextForWebContents( |
| 58 static sessions::LiveTabContext* Create( | |
| 59 Profile* profile, | |
| 60 const std::string& app_name); | |
| 61 | |
| 62 // see browser::FindBrowserForWebContents | |
| 63 static sessions::LiveTabContext* FindContextForWebContents( | |
| 64 const content::WebContents* contents); | 56 const content::WebContents* contents); |
| 65 | |
| 66 // see chrome::FindBrowserWithID | |
| 67 // Returns the LiveTabContext of the Browser with |desired_id| if | |
| 68 // such a Browser exists. | |
| 69 static sessions::LiveTabContext* FindContextWithID( | 57 static sessions::LiveTabContext* FindContextWithID( |
| 70 SessionID::id_type desired_id); | 58 SessionID::id_type desired_id); |
| 71 | 59 |
| 72 private: | 60 private: |
| 73 Browser* browser_; | 61 TabModel* tab_model_; |
| 74 | 62 DISALLOW_COPY_AND_ASSIGN(AndroidLiveTabContext); |
| 75 DISALLOW_COPY_AND_ASSIGN(BrowserLiveTabContext); | |
| 76 }; | 63 }; |
| 77 | 64 |
| 78 #endif // CHROME_BROWSER_UI_BROWSER_LIVE_TAB_CONTEXT_H_ | 65 |
| 66 #endif // CHROME_BROWSER_UI_ANDROID_TAB_MODEL_ANDROID_LIVE_TAB_CONTEXT_H_ |
| OLD | NEW |