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

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

Issue 2975883003: Revert of Fixes redirects to external apps when navigating from PWA. (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 package org.chromium.chrome.browser.webapps; 4 package org.chromium.chrome.browser.webapps;
5 5
6 import android.content.Intent;
7 import android.net.Uri; 6 import android.net.Uri;
8 import android.support.customtabs.CustomTabsIntent; 7 import android.support.customtabs.CustomTabsIntent;
9 8
10 import org.chromium.chrome.browser.IntentHandler;
11 import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider;
12 import org.chromium.chrome.browser.tab.Tab; 9 import org.chromium.chrome.browser.tab.Tab;
13 import org.chromium.chrome.browser.tab.TabIdManager; 10 import org.chromium.chrome.browser.tab.TabIdManager;
14 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; 11 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
15 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; 12 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
16 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; 13 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
17 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; 14 import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
18 15
19 /** 16 /**
20 * Asynchronously creates Tabs for navigation originating from an installed PWA. 17 * Asynchronously creates Tabs for navigation originating from an installed PWA.
21 * 18 *
22 * This is the same as the parent class with exception of opening a Custom Tab f or 19 * This is the same as the parent class with exception of opening a Custom Tab f or
23 * {@code _blank} links and {@code window.open(url)} calls instead of creating a new tab in Chrome. 20 * {@code _blank} links and {@code window.open(url)} calls instead of creating a new tab in Chrome.
24 */ 21 */
25 public class WebappTabDelegate extends TabDelegate { 22 public class WebappTabDelegate extends TabDelegate {
26 public WebappTabDelegate(boolean incognito) { 23 private final WebappActivity mActivity;
24
25 public WebappTabDelegate(WebappActivity activity, boolean incognito) {
27 super(incognito); 26 super(incognito);
27 this.mActivity = activity;
28 } 28 }
29 29
30 @Override 30 @Override
31 public void createNewTab(AsyncTabCreationParams asyncParams, TabLaunchType t ype, int parentId) { 31 public void createNewTab(AsyncTabCreationParams asyncParams, TabLaunchType t ype, int parentId) {
32 int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVAL ID_TAB_ID); 32 int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVAL ID_TAB_ID);
33 AsyncTabParamsManager.add(assignedTabId, asyncParams); 33 AsyncTabParamsManager.add(assignedTabId, asyncParams);
34 34
35 Intent intent = new CustomTabsIntent.Builder().setShowTitle(true).build( ).intent; 35 CustomTabsIntent customTabIntent =
36 intent.setData(Uri.parse(asyncParams.getLoadUrlParams().getUrl())); 36 new CustomTabsIntent.Builder().setShowTitle(true).build();
37 intent.putExtra(CustomTabIntentDataProvider.EXTRA_SEND_TO_EXTERNAL_DEFAU LT_HANDLER, true);
38 intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, t rue);
39 addAsyncTabExtras(asyncParams, parentId, false /* isChromeUI */, assigne dTabId, intent);
40 37
41 IntentHandler.startActivityForTrustedIntent(intent); 38 customTabIntent.intent.setPackage(mActivity.getPackageName());
39 addAsyncTabExtras(asyncParams, parentId, true, assignedTabId, customTabI ntent.intent);
40 customTabIntent.launchUrl(mActivity, Uri.parse(asyncParams.getLoadUrlPar ams().getUrl()));
42 } 41 }
43 } 42 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappActivity.java ('k') | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698