OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 4 |
5 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.content.Context; | |
8 import android.content.Intent; | 7 import android.content.Intent; |
9 import android.os.AsyncTask; | 8 import android.os.AsyncTask; |
10 | 9 |
| 10 import org.chromium.base.ContextUtils; |
11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
12 import org.chromium.chrome.browser.tab.Tab; | 12 import org.chromium.chrome.browser.tab.Tab; |
13 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 13 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
14 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; | 14 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; |
15 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; | 15 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
16 import org.chromium.chrome.browser.webapps.ChromeWebApkHost; | 16 import org.chromium.chrome.browser.webapps.ChromeWebApkHost; |
17 import org.chromium.chrome.browser.webapps.WebappDataStorage; | 17 import org.chromium.chrome.browser.webapps.WebappDataStorage; |
18 import org.chromium.chrome.browser.webapps.WebappRegistry; | 18 import org.chromium.chrome.browser.webapps.WebappRegistry; |
19 import org.chromium.content_public.browser.LoadUrlParams; | 19 import org.chromium.content_public.browser.LoadUrlParams; |
20 import org.chromium.content_public.browser.WebContents; | 20 import org.chromium.content_public.browser.WebContents; |
(...skipping 11 matching lines...) Expand all Loading... |
32 * URLs within the scope of a recently launched standalone-capable web app on th
e Android home | 32 * URLs within the scope of a recently launched standalone-capable web app on th
e Android home |
33 * screen are launched in the standalone web app frame. | 33 * screen are launched in the standalone web app frame. |
34 */ | 34 */ |
35 public class ServiceTabLauncher { | 35 public class ServiceTabLauncher { |
36 // Name of the extra containing the Id of a tab launch request id. | 36 // Name of the extra containing the Id of a tab launch request id. |
37 public static final String LAUNCH_REQUEST_ID_EXTRA = | 37 public static final String LAUNCH_REQUEST_ID_EXTRA = |
38 "org.chromium.chrome.browser.ServiceTabLauncher.LAUNCH_REQUEST_ID"; | 38 "org.chromium.chrome.browser.ServiceTabLauncher.LAUNCH_REQUEST_ID"; |
39 | 39 |
40 /** | 40 /** |
41 * Launches the browser activity and launches a tab for |url|. | 41 * Launches the browser activity and launches a tab for |url|. |
42 * | 42 * @param requestId Id of the request for launching this tab. |
43 * @param context The context using which the URL is being loaded. | |
44 * @param requestId Id of the request for launching this tab. | |
45 * @param incognito Whether the tab should be launched in incognito mode. | 43 * @param incognito Whether the tab should be launched in incognito mode. |
46 * @param url The URL which should be launched in a tab. | 44 * @param url The URL which should be launched in a tab. |
47 * @param disposition The disposition requested by the navigation source. | 45 * @param disposition The disposition requested by the navigation source. |
48 * @param referrerUrl URL of the referrer which is opening the page. | 46 * @param referrerUrl URL of the referrer which is opening the page. |
49 * @param referrerPolicy The referrer policy to consider when applying the r
eferrer. | 47 * @param referrerPolicy The referrer policy to consider when applying the r
eferrer. |
50 * @param extraHeaders Extra headers to apply when requesting the tab's URL. | 48 * @param extraHeaders Extra headers to apply when requesting the tab's URL. |
51 * @param postData Post-data to include in the tab URL's request body. | 49 * @param postData Post-data to include in the tab URL's request body. |
52 */ | 50 */ |
53 @CalledByNative | 51 @CalledByNative |
54 public static void launchTab(final Context context, final int requestId, | 52 public static void launchTab(final int requestId, final boolean incognito, f
inal String url, |
55 final boolean incognito, final String url, final int disposition, | 53 final int disposition, final String referrerUrl, final int referrerP
olicy, |
56 final String referrerUrl, final int referrerPolicy, final String ext
raHeaders, | 54 final String extraHeaders, final ResourceRequestBody postData) { |
57 final ResourceRequestBody postData) { | |
58 final TabDelegate tabDelegate = new TabDelegate(incognito); | 55 final TabDelegate tabDelegate = new TabDelegate(incognito); |
59 | 56 |
60 // 1. Launch WebAPK if one matches the target URL. | 57 // 1. Launch WebAPK if one matches the target URL. |
61 if (ChromeWebApkHost.isEnabled()) { | 58 if (ChromeWebApkHost.isEnabled()) { |
62 String webApkPackageName = WebApkValidator.queryWebApkPackage(contex
t, url); | 59 String webApkPackageName = |
| 60 WebApkValidator.queryWebApkPackage(ContextUtils.getApplicati
onContext(), url); |
63 if (webApkPackageName != null) { | 61 if (webApkPackageName != null) { |
64 Intent intent = | 62 Intent intent = |
65 WebApkNavigationClient.createLaunchWebApkIntent(webApkPa
ckageName, url); | 63 WebApkNavigationClient.createLaunchWebApkIntent(webApkPa
ckageName, url); |
66 if (intent != null) { | 64 if (intent != null) { |
67 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource.
NOTIFICATION); | 65 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource.
NOTIFICATION); |
68 context.startActivity(intent); | 66 ContextUtils.getApplicationContext().startActivity(intent); |
69 return; | 67 return; |
70 } | 68 } |
71 } | 69 } |
72 } | 70 } |
73 | 71 |
74 // 2. Launch WebappActivity if one matches the target URL and was opened
recently. | 72 // 2. Launch WebappActivity if one matches the target URL and was opened
recently. |
75 // Otherwise, open the URL in a tab. | 73 // Otherwise, open the URL in a tab. |
76 final WebappDataStorage storage = | 74 final WebappDataStorage storage = |
77 WebappRegistry.getInstance().getWebappDataStorageForUrl(url); | 75 WebappRegistry.getInstance().getWebappDataStorageForUrl(url); |
78 | 76 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 * @param requestId Id of the tab launching request which has been fulfilled
. | 126 * @param requestId Id of the tab launching request which has been fulfilled
. |
129 * @param webContents The WebContents instance associated with this request. | 127 * @param webContents The WebContents instance associated with this request. |
130 */ | 128 */ |
131 public static void onWebContentsForRequestAvailable(int requestId, WebConten
ts webContents) { | 129 public static void onWebContentsForRequestAvailable(int requestId, WebConten
ts webContents) { |
132 nativeOnWebContentsForRequestAvailable(requestId, webContents); | 130 nativeOnWebContentsForRequestAvailable(requestId, webContents); |
133 } | 131 } |
134 | 132 |
135 private static native void nativeOnWebContentsForRequestAvailable( | 133 private static native void nativeOnWebContentsForRequestAvailable( |
136 int requestId, WebContents webContents); | 134 int requestId, WebContents webContents); |
137 } | 135 } |
OLD | NEW |