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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sessions/ios/ios_live_tab.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sessions/ios/ios_live_tab.cc
diff --git a/components/sessions/ios/ios_live_tab.cc b/components/sessions/ios/ios_live_tab.cc
new file mode 100644
index 0000000000000000000000000000000000000000..30d49f79ab049d2625ce70e47a8ced931185d645
--- /dev/null
+++ b/components/sessions/ios/ios_live_tab.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/sessions/ios/ios_live_tab.h"
+#include "ios/web/public/navigation_manager.h"
+
+namespace {
+const char kIOSLiveTabWebStateUserDataKey[] = "ios_live_tab";
+}
+
+namespace sessions {
+
+std::string IOSLiveTab::user_agent_override_;
+
+// static
+IOSLiveTab* IOSLiveTab::GetForWebState(web::WebState* web_state) {
+ if (!web_state->GetUserData(kIOSLiveTabWebStateUserDataKey)) {
+ web_state->SetUserData(kIOSLiveTabWebStateUserDataKey,
+ new IOSLiveTab(web_state));
+ }
+
+ return static_cast<IOSLiveTab*>(
+ web_state->GetUserData(kIOSLiveTabWebStateUserDataKey));
+}
+
+IOSLiveTab::IOSLiveTab(web::WebState* web_state) : web_state_(web_state) {}
+
+IOSLiveTab::~IOSLiveTab() {}
+
+int IOSLiveTab::GetCurrentEntryIndex() {
+ return navigation_manager()->GetCurrentEntryIndex();
+}
+
+int IOSLiveTab::GetPendingEntryIndex() {
+ return navigation_manager()->GetPendingItemIndex();
+}
+
+sessions::SerializedNavigationEntry IOSLiveTab::GetEntryAtIndex(int index) {
+ return sessions::IOSSerializedNavigationBuilder::FromNavigationItem(
+ index, *navigation_manager()->GetItemAtIndex(index));
+}
+
+sessions::SerializedNavigationEntry IOSLiveTab::GetPendingEntry() {
+ return sessions::IOSSerializedNavigationBuilder::FromNavigationItem(
+ GetPendingEntryIndex(), *navigation_manager()->GetPendingItem());
+}
+
+int IOSLiveTab::GetEntryCount() {
+ return navigation_manager()->GetEntryCount();
+}
+
+void IOSLiveTab::LoadIfNecessary() {
+ navigation_manager()->LoadIfNecessary();
+}
+
+const std::string& IOSLiveTab::GetUserAgentOverride() const {
+ // Dynamic user agent overrides are not supported on iOS.
+ return user_agent_override_;
+}
+
+} // namespace sessions
« 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