OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 package org.chromium.chrome.browser.webapps; |
| 5 |
| 6 import android.net.Uri; |
| 7 import android.support.customtabs.CustomTabsIntent; |
| 8 |
| 9 import org.chromium.chrome.browser.tab.Tab; |
| 10 import org.chromium.chrome.browser.tab.TabIdManager; |
| 11 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; |
| 12 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 13 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; |
| 14 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
| 15 |
| 16 /** |
| 17 * Asynchronously creates Tabs for navigation originating from an installed PWA. |
| 18 * |
| 19 * 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. |
| 21 */ |
| 22 public class WebappTabDelegate extends TabDelegate { |
| 23 private final WebappActivity mActivity; |
| 24 |
| 25 public WebappTabDelegate(WebappActivity activity, boolean incognito) { |
| 26 super(incognito); |
| 27 this.mActivity = activity; |
| 28 } |
| 29 |
| 30 @Override |
| 31 public void createNewTab(AsyncTabCreationParams asyncParams, TabLaunchType t
ype, int parentId) { |
| 32 int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVAL
ID_TAB_ID); |
| 33 AsyncTabParamsManager.add(assignedTabId, asyncParams); |
| 34 |
| 35 CustomTabsIntent customTabIntent = |
| 36 new CustomTabsIntent.Builder().setShowTitle(true).build(); |
| 37 |
| 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())); |
| 41 } |
| 42 } |
OLD | NEW |