Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: components/sessions/content/content_live_tab.cc

Issue 1321713005: Abstract WebContents/NavigationController from core TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sessions/content/content_live_tab.h ('k') | components/sessions/core/live_tab.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « components/sessions/content/content_live_tab.h ('k') | components/sessions/core/live_tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698