| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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 "components/sessions/content/content_live_tab.h" |
| 6 |
| 7 namespace { |
| 8 const char kContentLiveTabWebContentsUserDataKey[] = "content_live_tab"; |
| 9 } |
| 10 |
| 11 namespace sessions { |
| 12 |
| 13 // static |
| 14 void ContentLiveTab::CreateForWebContents(content::WebContents* contents) { |
| 15 if (FromWebContents(contents)) |
| 16 return; |
| 17 |
| 18 contents->SetUserData( |
| 19 kContentLiveTabWebContentsUserDataKey, |
| 20 new ContentLiveTab(contents)); |
| 21 } |
| 22 |
| 23 // static |
| 24 ContentLiveTab* ContentLiveTab::FromWebContents( |
| 25 content::WebContents* contents) { |
| 26 return static_cast<ContentLiveTab*>(contents->GetUserData( |
| 27 kContentLiveTabWebContentsUserDataKey)); |
| 28 } |
| 29 |
| 30 ContentLiveTab::ContentLiveTab(content::WebContents* contents) |
| 31 : web_contents_(contents) {} |
| 32 |
| 33 ContentLiveTab::~ContentLiveTab() {} |
| 34 |
| 35 int ContentLiveTab::GetCurrentEntryIndex() { |
| 36 return navigation_controller().GetCurrentEntryIndex(); |
| 37 } |
| 38 |
| 39 int ContentLiveTab::GetPendingEntryIndex() { |
| 40 return navigation_controller().GetPendingEntryIndex(); |
| 41 } |
| 42 |
| 43 sessions::SerializedNavigationEntry ContentLiveTab::GetEntryAtIndex(int index) { |
| 44 return sessions::ContentSerializedNavigationBuilder::FromNavigationEntry( |
| 45 index, *navigation_controller().GetEntryAtIndex(index)); |
| 46 } |
| 47 |
| 48 sessions::SerializedNavigationEntry ContentLiveTab::GetPendingEntry() { |
| 49 return sessions::ContentSerializedNavigationBuilder::FromNavigationEntry( |
| 50 GetPendingEntryIndex(), *navigation_controller().GetPendingEntry()); |
| 51 } |
| 52 |
| 53 int ContentLiveTab::GetEntryCount() { |
| 54 return navigation_controller().GetEntryCount(); |
| 55 } |
| 56 |
| 57 void ContentLiveTab::LoadIfNecessary() { |
| 58 navigation_controller().LoadIfNecessary(); |
| 59 } |
| 60 |
| 61 const std::string& ContentLiveTab::GetUserAgentOverride() const { |
| 62 return web_contents()->GetUserAgentOverride(); |
| 63 } |
| 64 |
| 65 } // namespace sessions |
| OLD | NEW |