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

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

Issue 2969143002: 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;
6 import android.net.Uri; 7 import android.net.Uri;
7 import android.support.customtabs.CustomTabsIntent; 8 import android.support.customtabs.CustomTabsIntent;
8 9
10 import org.chromium.chrome.browser.IntentHandler;
11 import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider;
9 import org.chromium.chrome.browser.tab.Tab; 12 import org.chromium.chrome.browser.tab.Tab;
10 import org.chromium.chrome.browser.tab.TabIdManager; 13 import org.chromium.chrome.browser.tab.TabIdManager;
11 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; 14 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
12 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; 15 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
13 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; 16 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams;
14 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; 17 import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
15 18
16 /** 19 /**
17 * Asynchronously creates Tabs for navigation originating from an installed PWA. 20 * Asynchronously creates Tabs for navigation originating from an installed PWA.
18 * 21 *
19 * This is the same as the parent class with exception of opening a Custom Tab f or 22 * This is the same as the parent class with exception of opening a Custom Tab f or
20 * {@code _blank} links and {@code window.open(url)} calls instead of creating a new tab in Chrome. 23 * {@code _blank} links and {@code window.open(url)} calls instead of creating a new tab in Chrome.
21 */ 24 */
22 public class WebappTabDelegate extends TabDelegate { 25 public class WebappTabDelegate extends TabDelegate {
23 private final WebappActivity mActivity; 26 public WebappTabDelegate(boolean incognito) {
24
25 public WebappTabDelegate(WebappActivity activity, boolean incognito) {
26 super(incognito); 27 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 CustomTabsIntent customTabIntent = 35 Intent intent = new CustomTabsIntent.Builder().setShowTitle(true).build( ).intent;
36 new CustomTabsIntent.Builder().setShowTitle(true).build(); 36 intent.setData(Uri.parse(asyncParams.getLoadUrlParams().getUrl()));
37 intent.putExtra(CustomTabIntentDataProvider.EXTRA_SEND_TO_EXTERNAL_DEFAU LT_HANDLER, true);
Yusuf 2017/07/07 20:50:02 Good investigation finding out about this! I am s
piotrs 2017/07/09 23:43:38 My patch description wasn't clear enough, I update
38 intent.putExtra(CustomTabIntentDataProvider.EXTRA_IS_OPENED_BY_CHROME, t rue);
39 addAsyncTabExtras(asyncParams, parentId, false /* isChromeUI */, assigne dTabId, intent);
37 40
38 customTabIntent.intent.setPackage(mActivity.getPackageName()); 41 IntentHandler.startActivityForTrustedIntent(intent);
39 addAsyncTabExtras(asyncParams, parentId, true, assignedTabId, customTabI ntent.intent);
40 customTabIntent.launchUrl(mActivity, Uri.parse(asyncParams.getLoadUrlPar ams().getUrl()));
41 } 42 }
42 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698