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.IntentHandler; | |
10 import org.chromium.chrome.browser.tab.Tab; | |
11 import org.chromium.chrome.browser.tab.TabIdManager; | |
12 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; | |
13 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | |
14 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; | |
15 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; | |
16 | |
17 /** | |
18 * Asynchronously creates Tabs for navigation originating from an installed PWA. | |
19 * | |
20 * This is the same as the parent class with exception of opening a Custom Tab f or | |
21 * {@code _blank} links and {@code window.open(url)} calls instead of creating a new tab in Chrome. | |
22 */ | |
23 public class WebappTabDelegate extends TabDelegate { | |
24 private final WebappActivity mActivity; | |
25 | |
26 public WebappTabDelegate(WebappActivity activity, boolean incognito) { | |
27 super(incognito); | |
28 this.mActivity = activity; | |
29 } | |
30 | |
31 @Override | |
32 public void createNewTab(AsyncTabCreationParams asyncParams, TabLaunchType t ype, int parentId) { | |
33 int assignedTabId = TabIdManager.getInstance().generateValidId(Tab.INVAL ID_TAB_ID); | |
34 AsyncTabParamsManager.add(assignedTabId, asyncParams); | |
35 | |
36 CustomTabsIntent customTabIntent = | |
37 new CustomTabsIntent.Builder().setShowTitle(true).build(); | |
38 | |
39 customTabIntent.intent.setPackage(mActivity.getPackageName()); | |
40 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
| |
41 addAsyncTabExtras(asyncParams, parentId, true, assignedTabId, customTabI ntent.intent); | |
42 customTabIntent.launchUrl(mActivity, Uri.parse(asyncParams.getLoadUrlPar ams().getUrl())); | |
43 } | |
44 } | |
OLD | NEW |