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

Unified Diff: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java

Issue 2858563004: Add support for webapk without runtimeHost (Closed)
Patch Set: Fix test failure. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
diff --git a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
index e30875d3a331c1bbdfff0a3290f591ff735ed751..1f37399a6b5895d6592382070029a0be23d04333 100644
--- a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
+++ b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/MainActivity.java
@@ -17,8 +17,6 @@ import android.util.Log;
import org.chromium.webapk.lib.common.WebApkConstants;
import org.chromium.webapk.lib.common.WebApkMetaDataKeys;
-import java.net.URISyntaxException;
-
/**
* WebAPK's main Activity.
*/
@@ -76,9 +74,7 @@ public class MainActivity extends Activity {
if (launchHostBrowserInWebApkMode(startUrl, overrideUrl)) {
return;
}
- if (launchBrowser(startUrl)) {
- return;
- }
+
installBrowser();
}
@@ -92,6 +88,8 @@ public class MainActivity extends Activity {
Log.v(TAG, "Package name of the WebAPK:" + packageName);
String runtimeHost = WebApkUtils.getHostBrowserPackageName(this);
+ if (runtimeHost == null) return false;
+
boolean isFromExternalIntent = (overrideUrl != null);
int source = getIntent().getIntExtra(WebApkConstants.EXTRA_SOURCE, 0);
if (isFromExternalIntent && source == WebApkConstants.SHORTCUT_SOURCE_UNKNOWN) {
@@ -118,46 +116,11 @@ public class MainActivity extends Activity {
}
}
- /**
- * Launches browser (not necessarily the host browser).
- * @param startUrl URL to navigate browser to.
- * @return True if successful.
- */
- private boolean launchBrowser(String startUrl) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(startUrl));
- intent.addCategory(Intent.CATEGORY_BROWSABLE);
-
- // The WebAPK can handle {@link startUrl}. Set a selector to prevent the WebAPK from
- // launching itself.
- try {
- Intent selectorIntent = Intent.parseUri("https://", Intent.URI_INTENT_SCHEME);
- intent.setSelector(selectorIntent);
- } catch (URISyntaxException e) {
- return false;
- }
-
- // Add extras in case that the URL is launched in Chrome.
- int source =
- getIntent().getIntExtra(WebApkConstants.EXTRA_SOURCE, Intent.URI_INTENT_SCHEME);
- intent.putExtra(REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true)
- .putExtra(WebApkConstants.EXTRA_SOURCE, source);
-
- try {
- startActivity(intent);
- } catch (ActivityNotFoundException e) {
- return false;
- }
- return true;
- }
-
/**
* Launches the Play Store with the host browser's page.
*/
private void installBrowser() {
- String hostBrowserPackageName = WebApkUtils.getHostBrowserPackageName(this);
- if (hostBrowserPackageName == null) {
- return;
- }
+ String hostBrowserPackageName = WebApkConstants.DEFAULT_HOST_BROWSER;
try {
startActivity(createInstallIntent(hostBrowserPackageName));

Powered by Google App Engine
This is Rietveld 408576698