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

Side by Side Diff: webapk/libs/client/src/org/chromium/webapk/lib/client/NavigationClient.java

Issue 1965583002: Move //webapk to //chrome/android/webapk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
1 // Copyright 2016 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
5 package org.chromium.webapk.lib.client;
6
7 import android.content.ComponentName;
8 import android.content.Context;
9 import android.content.Intent;
10 import android.net.Uri;
11
12 import org.chromium.webapk.lib.common.WebApkConstants;
13 import org.chromium.webapk.lib.common.WebApkUtils;
14
15 /**
16 * NavigationClient provides APIs that A WebAPK host can delegate a WebAPK to lo ad URL.
17 */
18 public class NavigationClient {
19 /**
20 * Create an Intent to launch a WebAPK and return the Intent to the host.
21 * @param webAPKPackageName the package name of the WebAPK to launch.
22 * @param callerPackageName the package name of the host.
23 * @param urlToNavigate the URL of the WebAPK to navigate.
24 */
25 public static Intent createIntentToLaunchWebAPK(String webAPKPackageName,
26 String callerPackageName, String urlToNavigate) {
27 Intent intent;
28 try {
29 intent = Intent.parseUri(urlToNavigate, Intent.URI_INTENT_SCHEME);
30 } catch (Exception ex) {
31 return null;
32 }
33 intent.setComponent(new ComponentName(webAPKPackageName,
34 WebApkConstants.WEBAPK_MAIN_ACTIVITY));
35 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
36 return intent;
37 }
38
39 /**
40 * When navigation is out of the scope of a WebAPK, the Activity hosted in t he WebAPK can call
41 * this function to create an Intent to ask its host to complete the navigat ion.
42 * @param context a context instance.
43 * @param urlToNavigate the URL for the navigation.
44 * @param hostLauchActivity the Activity of the host that this Intent is sen t to.
45 */
46 public static Intent createIntentToNavigateBackToHost(Context context,
47 String urlToNavigate, String hostLauchActivity) {
48 String hostPackageName = WebApkUtils.getHostBrowserPackageName(context);
49 Intent intent = new Intent(Intent.ACTION_VIEW);
50 intent.setComponent(new ComponentName(hostPackageName, hostLauchActivity ));
51 intent.setData(Uri.parse(urlToNavigate));
52 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
53 return intent;
54 }
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698