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

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/document/TabDelegateImpl.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/document/TabDelegateImpl.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/document/TabDelegateImpl.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/document/TabDelegateImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..a22b3133e614fda25efe25e139750358a731f824
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/document/TabDelegateImpl.java
@@ -0,0 +1,67 @@
+// 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.
+
+package org.chromium.chrome.browser.document;
+
+import android.app.Activity;
+
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.browser.TabState;
+import org.chromium.chrome.browser.tab.ChromeTab;
+import org.chromium.chrome.browser.tabmodel.document.ActivityDelegate;
+import org.chromium.chrome.browser.tabmodel.document.DocumentTabModel.Entry;
+import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
+import org.chromium.content_public.browser.LoadUrlParams;
+import org.chromium.content_public.browser.WebContents;
+import org.chromium.ui.base.PageTransition;
+
+/**
+ * Provides Tabs to a DocumentTabModel.
+ * TODO(dfalcantara): delete or refactor this after upstreaming.
+ */
+public class TabDelegateImpl implements TabDelegate {
+ @Override
+ public Tab getActivityTab(
+ boolean incognito, ActivityDelegate activityDelegate, Activity activity) {
+ if (!(activity instanceof DocumentActivity)
+ || !activityDelegate.isValidActivity(incognito, activity.getIntent())) return null;
+ return ((DocumentActivity) activity).getActivityTab();
+ }
+
+ @Override
+ public void createTabInForeground(Activity parentActivity, boolean incognito,
+ LoadUrlParams loadUrlParams, PendingDocumentData documentParams) {
+ ChromeLauncherActivity.launchDocumentInstance(parentActivity, incognito,
+ ChromeLauncherActivity.LAUNCH_MODE_FOREGROUND, loadUrlParams.getUrl(),
+ DocumentMetricIds.STARTED_BY_WINDOW_OPEN,
+ loadUrlParams.getTransitionType(), false, documentParams);
+ }
+
+ @Override
+ public Tab createFrozenTab(Entry entry) {
+ TabState state = entry.getTabState();
+ assert state != null;
+ return ChromeTab.createFrozenTabFromState(entry.tabId, null, state.isIncognito(), null,
+ Tab.INVALID_TAB_ID, state);
+ }
+
+ @Override
+ public void createTabWithWebContents(
+ boolean isIncognito, WebContents webContents, int parentTabId) {
+ PendingDocumentData data = new PendingDocumentData();
+ data.webContents = webContents;
+ ChromeLauncherActivity.launchDocumentInstance(
+ null, isIncognito, ChromeLauncherActivity.LAUNCH_MODE_FOREGROUND, null,
+ DocumentMetricIds.STARTED_BY_CHROME_HOME_RECENT_TABS,
+ PageTransition.RELOAD, false, data);
+ }
+
+ @Override
+ public void createTabForDevTools(String url) {
+ ChromeLauncherActivity.launchDocumentInstance(
+ null, false, ChromeLauncherActivity.LAUNCH_MODE_FOREGROUND, url,
+ DocumentMetricIds.STARTED_BY_CHROME_HOME_RECENT_TABS,
+ PageTransition.RELOAD, false, null);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698