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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappTabDelegate.java

Issue 2898373002: Redirects _blank and window.open() off-origin navigation from PWA to CCT. (Closed)
Patch Set: Addressed comments Created 3 years, 6 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/src/org/chromium/chrome/browser/webapps/WebappTabDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappTabDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappTabDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..2f68c7c78a8458c6002d5d115f85d0459cb2fe33
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappTabDelegate.java
@@ -0,0 +1,44 @@
+// Copyright 2017 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.webapps;
+
+import android.net.Uri;
+import android.support.customtabs.CustomTabsIntent;
+
+import org.chromium.chrome.browser.IntentHandler;
+import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tab.TabIdManager;
+import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
+import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
+import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
+import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
+
+/**
+ * Asynchronously creates Tabs for navigation originating from an installed PWA.
+ *
+ * This is the same as the parent class with exception of opening a Custom Tab for
+ * {@code _blank} links and {@code window.open(url)} calls instead of creating a new tab in Chrome.
+ */
+public class WebappTabDelegate extends TabDelegate {
+ private final WebappActivity mActivity;
+
+ public WebappTabDelegate(WebappActivity activity, boolean incognito) {
+ super(incognito);
+ this.mActivity = activity;
+ }
+
+ @Override
+ public void createNewTab(AsyncTabCreationParams asyncParams, TabLaunchType type, int parentId) {
+ int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVALID_TAB_ID);
+ AsyncTabParamsManager.add(assignedTabId, asyncParams);
+
+ CustomTabsIntent customTabIntent =
+ new CustomTabsIntent.Builder().setShowTitle(true).build();
+
+ customTabIntent.intent.setPackage(mActivity.getPackageName());
+ IntentHandler.addTrustedIntentExtras(customTabIntent.intent);
Yusuf 2017/06/15 16:15:56 this is conditioned on ExternalNavigationDelegateI
piotrs 2017/06/15 23:28:21 It doesn't resolve to a single Chrome instance, as
+ addAsyncTabExtras(asyncParams, parentId, true, assignedTabId, customTabIntent.intent);
+ customTabIntent.launchUrl(mActivity, Uri.parse(asyncParams.getLoadUrlParams().getUrl()));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698