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

Side by Side Diff: components/sessions/ios/ios_live_tab.cc

Issue 1372103002: [sessions] Introduce iOS implementation of LiveTab interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 5 years, 2 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/ios/ios_live_tab.h ('k') | no next file » | 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/ios/ios_live_tab.h"
6 #include "ios/web/public/navigation_manager.h"
7
8 namespace {
9 const char kIOSLiveTabWebStateUserDataKey[] = "ios_live_tab";
10 }
11
12 namespace sessions {
13
14 std::string IOSLiveTab::user_agent_override_;
15
16 // static
17 IOSLiveTab* IOSLiveTab::GetForWebState(web::WebState* web_state) {
18 if (!web_state->GetUserData(kIOSLiveTabWebStateUserDataKey)) {
19 web_state->SetUserData(kIOSLiveTabWebStateUserDataKey,
20 new IOSLiveTab(web_state));
21 }
22
23 return static_cast<IOSLiveTab*>(
24 web_state->GetUserData(kIOSLiveTabWebStateUserDataKey));
25 }
26
27 IOSLiveTab::IOSLiveTab(web::WebState* web_state) : web_state_(web_state) {}
28
29 IOSLiveTab::~IOSLiveTab() {}
30
31 int IOSLiveTab::GetCurrentEntryIndex() {
32 return navigation_manager()->GetCurrentEntryIndex();
33 }
34
35 int IOSLiveTab::GetPendingEntryIndex() {
36 return navigation_manager()->GetPendingItemIndex();
37 }
38
39 sessions::SerializedNavigationEntry IOSLiveTab::GetEntryAtIndex(int index) {
40 return sessions::IOSSerializedNavigationBuilder::FromNavigationItem(
41 index, *navigation_manager()->GetItemAtIndex(index));
42 }
43
44 sessions::SerializedNavigationEntry IOSLiveTab::GetPendingEntry() {
45 return sessions::IOSSerializedNavigationBuilder::FromNavigationItem(
46 GetPendingEntryIndex(), *navigation_manager()->GetPendingItem());
47 }
48
49 int IOSLiveTab::GetEntryCount() {
50 return navigation_manager()->GetEntryCount();
51 }
52
53 void IOSLiveTab::LoadIfNecessary() {
54 navigation_manager()->LoadIfNecessary();
55 }
56
57 const std::string& IOSLiveTab::GetUserAgentOverride() const {
58 // Dynamic user agent overrides are not supported on iOS.
59 return user_agent_override_;
60 }
61
62 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/ios/ios_live_tab.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698