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

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

Issue 2800833003: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Created 3 years, 8 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 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;
7 import android.content.Intent; 8 import android.content.Intent;
8 import android.os.AsyncTask; 9 import android.os.AsyncTask;
9 10
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
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 * @param requestId Id of the request for launching this tab. 42 *
43 * @param context The context using which the URL is being loaded.
44 * @param requestId Id of the request for launching this tab.
43 * @param incognito Whether the tab should be launched in incognito mode. 45 * @param incognito Whether the tab should be launched in incognito mode.
44 * @param url The URL which should be launched in a tab. 46 * @param url The URL which should be launched in a tab.
45 * @param disposition The disposition requested by the navigation source. 47 * @param disposition The disposition requested by the navigation source.
46 * @param referrerUrl URL of the referrer which is opening the page. 48 * @param referrerUrl URL of the referrer which is opening the page.
47 * @param referrerPolicy The referrer policy to consider when applying the r eferrer. 49 * @param referrerPolicy The referrer policy to consider when applying the r eferrer.
48 * @param extraHeaders Extra headers to apply when requesting the tab's URL. 50 * @param extraHeaders Extra headers to apply when requesting the tab's URL.
49 * @param postData Post-data to include in the tab URL's request body. 51 * @param postData Post-data to include in the tab URL's request body.
50 */ 52 */
51 @CalledByNative 53 @CalledByNative
52 public static void launchTab(final int requestId, final boolean incognito, f inal String url, 54 public static void launchTab(final Context context, final int requestId,
53 final int disposition, final String referrerUrl, final int referrerP olicy, 55 final boolean incognito, final String url, final int disposition,
54 final String extraHeaders, final ResourceRequestBody postData) { 56 final String referrerUrl, final int referrerPolicy, final String ext raHeaders,
57 final ResourceRequestBody postData) {
55 final TabDelegate tabDelegate = new TabDelegate(incognito); 58 final TabDelegate tabDelegate = new TabDelegate(incognito);
56 59
57 // 1. Launch WebAPK if one matches the target URL. 60 // 1. Launch WebAPK if one matches the target URL.
58 if (ChromeWebApkHost.isEnabled()) { 61 if (ChromeWebApkHost.isEnabled()) {
59 String webApkPackageName = 62 String webApkPackageName = WebApkValidator.queryWebApkPackage(contex t, url);
60 WebApkValidator.queryWebApkPackage(ContextUtils.getApplicati onContext(), url);
61 if (webApkPackageName != null) { 63 if (webApkPackageName != null) {
62 Intent intent = 64 Intent intent =
63 WebApkNavigationClient.createLaunchWebApkIntent(webApkPa ckageName, url); 65 WebApkNavigationClient.createLaunchWebApkIntent(webApkPa ckageName, url);
64 if (intent != null) { 66 if (intent != null) {
65 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource. NOTIFICATION); 67 intent.putExtra(ShortcutHelper.EXTRA_SOURCE, ShortcutSource. NOTIFICATION);
66 ContextUtils.getApplicationContext().startActivity(intent); 68 context.startActivity(intent);
67 return; 69 return;
68 } 70 }
69 } 71 }
70 } 72 }
71 73
72 // 2. Launch WebappActivity if one matches the target URL and was opened recently. 74 // 2. Launch WebappActivity if one matches the target URL and was opened recently.
73 // Otherwise, open the URL in a tab. 75 // Otherwise, open the URL in a tab.
74 final WebappDataStorage storage = 76 final WebappDataStorage storage =
75 WebappRegistry.getInstance().getWebappDataStorageForUrl(url); 77 WebappRegistry.getInstance().getWebappDataStorageForUrl(url);
76 78
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * @param requestId Id of the tab launching request which has been fulfilled . 128 * @param requestId Id of the tab launching request which has been fulfilled .
127 * @param webContents The WebContents instance associated with this request. 129 * @param webContents The WebContents instance associated with this request.
128 */ 130 */
129 public static void onWebContentsForRequestAvailable(int requestId, WebConten ts webContents) { 131 public static void onWebContentsForRequestAvailable(int requestId, WebConten ts webContents) {
130 nativeOnWebContentsForRequestAvailable(requestId, webContents); 132 nativeOnWebContentsForRequestAvailable(requestId, webContents);
131 } 133 }
132 134
133 private static native void nativeOnWebContentsForRequestAvailable( 135 private static native void nativeOnWebContentsForRequestAvailable(
134 int requestId, WebContents webContents); 136 int requestId, WebContents webContents);
135 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698