Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/tab_android.h" | |
| 6 #include "chrome/browser/ui/android/tab_model/android_live_tab_context.h" | |
| 7 #include "chrome/browser/ui/android/tab_model/tab_model.h" | |
| 8 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | |
| 9 #include "components/sessions/content/content_live_tab.h" | |
| 10 | |
| 11 AndroidLiveTabContext::AndroidLiveTabContext(TabModel* tab_model) | |
| 12 : tab_model_(tab_model) {} | |
| 13 | |
| 14 // Not supported by android. | |
| 15 void AndroidLiveTabContext::ShowBrowserWindow() { | |
| 16 } | |
| 17 | |
| 18 const SessionID& AndroidLiveTabContext::GetSessionID() const { | |
| 19 return tab_model_->SessionId(); | |
| 20 } | |
| 21 | |
| 22 int AndroidLiveTabContext::GetTabCount() const { | |
| 23 return tab_model_->GetTabCount(); | |
| 24 } | |
| 25 | |
| 26 int AndroidLiveTabContext::GetSelectedIndex() const { | |
| 27 return tab_model_->GetActiveIndex(); | |
| 28 } | |
| 29 | |
| 30 // Not supported by android. | |
| 31 std::string AndroidLiveTabContext::GetAppName() const { | |
| 32 return std::string(); | |
| 33 } | |
| 34 | |
| 35 sessions::LiveTab* AndroidLiveTabContext::GetLiveTabAt(int index) const { | |
| 36 TabAndroid* tab_android = tab_model_->GetTabAt(index); | |
| 37 if (!tab_android || !tab_android->web_contents()) | |
| 38 return nullptr; | |
| 39 | |
| 40 return sessions::ContentLiveTab::GetForWebContents( | |
| 41 tab_android->web_contents()); | |
| 42 } | |
| 43 | |
| 44 sessions::LiveTab* AndroidLiveTabContext::GetActiveLiveTab() const { | |
| 45 content::WebContents* web_contents = tab_model_->GetActiveWebContents(); | |
| 46 if (!web_contents) | |
| 47 return nullptr; | |
| 48 | |
| 49 return sessions::ContentLiveTab::GetForWebContents(web_contents); | |
| 50 } | |
| 51 | |
| 52 // Not supported by android. | |
| 53 bool AndroidLiveTabContext::IsTabPinned(int index) const { | |
| 54 return false; | |
| 55 } | |
| 56 | |
| 57 // Currently do nothing. | |
| 58 sessions::LiveTab* AndroidLiveTabContext::AddRestoredTab( | |
| 59 const std::vector<sessions::SerializedNavigationEntry>& navigations, | |
| 60 int tab_index, | |
| 61 int selected_navigation, | |
| 62 const std::string& extension_app_id, | |
| 63 bool select, | |
| 64 bool pin, | |
| 65 bool from_last_session, | |
| 66 const sessions::PlatformSpecificTabData* tab_platform_data, | |
| 67 const std::string& user_agent_override) { | |
| 68 NOTIMPLEMENTED(); | |
| 69 return nullptr; | |
|
Theresa
2016/07/02 01:00:37
This would also need to be implemented. It would b
| |
| 70 } | |
| 71 | |
| 72 // Currently do nothing. | |
| 73 sessions::LiveTab* AndroidLiveTabContext::ReplaceRestoredTab( | |
| 74 const std::vector<sessions::SerializedNavigationEntry>& navigations, | |
| 75 int selected_navigation, | |
| 76 bool from_last_session, | |
| 77 const std::string& extension_app_id, | |
| 78 const sessions::PlatformSpecificTabData* tab_platform_data, | |
| 79 const std::string& user_agent_override) { | |
| 80 NOTIMPLEMENTED(); | |
| 81 return nullptr; | |
| 82 } | |
| 83 | |
| 84 // Currently do nothing. | |
| 85 void AndroidLiveTabContext::CloseTab() { | |
| 86 NOTIMPLEMENTED(); | |
| 87 } | |
| 88 | |
| 89 // static. | |
| 90 sessions::LiveTabContext* AndroidLiveTabContext::FindContextForWebContents( | |
| 91 const content::WebContents* contents) { | |
| 92 TabAndroid* tab_android = TabAndroid::FromWebContents(contents); | |
| 93 TabModel* model = TabModelList::FindTabModelWithId( | |
| 94 tab_android->window_id().id()); | |
| 95 | |
| 96 return model ? model->GetLiveTabContext() : nullptr; | |
| 97 } | |
| 98 | |
|
Theresa
2016/07/02 01:00:37
We would need a new method here,
sessions::LiveTab
xingliu
2016/07/05 19:46:38
Updated the CL, refactor the code to use RestoreMo
| |
| OLD | NEW |