Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / components / sessions / content / content_live_tab.cc
blobf7fdad23b74f32fafbba437f730a6ae6d11e3f63
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.
5 #include "components/sessions/content/content_live_tab.h"
7 namespace {
8 const char kContentLiveTabWebContentsUserDataKey[] = "content_live_tab";
11 namespace sessions {
13 // static
14 void ContentLiveTab::CreateForWebContents(content::WebContents* contents) {
15 if (FromWebContents(contents))
16 return;
18 contents->SetUserData(
19 kContentLiveTabWebContentsUserDataKey,
20 new ContentLiveTab(contents));
23 // static
24 ContentLiveTab* ContentLiveTab::FromWebContents(
25 content::WebContents* contents) {
26 return static_cast<ContentLiveTab*>(contents->GetUserData(
27 kContentLiveTabWebContentsUserDataKey));
30 ContentLiveTab::ContentLiveTab(content::WebContents* contents)
31 : web_contents_(contents) {}
33 ContentLiveTab::~ContentLiveTab() {}
35 int ContentLiveTab::GetCurrentEntryIndex() {
36 return navigation_controller().GetCurrentEntryIndex();
39 int ContentLiveTab::GetPendingEntryIndex() {
40 return navigation_controller().GetPendingEntryIndex();
43 sessions::SerializedNavigationEntry ContentLiveTab::GetEntryAtIndex(int index) {
44 return sessions::ContentSerializedNavigationBuilder::FromNavigationEntry(
45 index, *navigation_controller().GetEntryAtIndex(index));
48 sessions::SerializedNavigationEntry ContentLiveTab::GetPendingEntry() {
49 return sessions::ContentSerializedNavigationBuilder::FromNavigationEntry(
50 GetPendingEntryIndex(), *navigation_controller().GetPendingEntry());
53 int ContentLiveTab::GetEntryCount() {
54 return navigation_controller().GetEntryCount();
57 void ContentLiveTab::LoadIfNecessary() {
58 navigation_controller().LoadIfNecessary();
61 const std::string& ContentLiveTab::GetUserAgentOverride() const {
62 return web_contents()->GetUserAgentOverride();
65 } // namespace sessions