Commit 649c62d4 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: changes to WebLayerShellActivity url parsing

This tries to use WEB_URL first. This way 'https' urls are matched.

This also special cases http://localhost: as WEB_URL doesn't handle
ports.

Lastly, this makes loadUrl disable intent processing. To do otherwise
means you can't navigate to sites such as http://youtube.com/.

BUG=none
TEST=none

Change-Id: I96af6c37f35fa8fae4d1bbf64fc974c3b071fbd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438340Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812116}
parent 4b38de28
...@@ -54,6 +54,7 @@ import org.chromium.weblayer.FaviconCallback; ...@@ -54,6 +54,7 @@ import org.chromium.weblayer.FaviconCallback;
import org.chromium.weblayer.FaviconFetcher; import org.chromium.weblayer.FaviconFetcher;
import org.chromium.weblayer.FindInPageCallback; import org.chromium.weblayer.FindInPageCallback;
import org.chromium.weblayer.FullscreenCallback; import org.chromium.weblayer.FullscreenCallback;
import org.chromium.weblayer.NavigateParams;
import org.chromium.weblayer.NavigationCallback; import org.chromium.weblayer.NavigationCallback;
import org.chromium.weblayer.NavigationController; import org.chromium.weblayer.NavigationController;
import org.chromium.weblayer.NewTabCallback; import org.chromium.weblayer.NewTabCallback;
...@@ -627,7 +628,13 @@ public class WebLayerShellActivity extends AppCompatActivity { ...@@ -627,7 +628,13 @@ public class WebLayerShellActivity extends AppCompatActivity {
} }
public void loadUrl(String input) { public void loadUrl(String input) {
mBrowser.getActiveTab().getNavigationController().navigate(getUriFromInput(input)); // Disable intent processing for urls typed in. This way the user can navigate to urls that
// match apps (this is similar to what Chrome does).
NavigateParams.Builder navigateParamsBuilder =
new NavigateParams.Builder().disableIntentProcessing();
mBrowser.getActiveTab().getNavigationController().navigate(
getUriFromInput(input), navigateParamsBuilder.build());
} }
private static String getUrlFromIntent(Intent intent) { private static String getUrlFromIntent(Intent intent) {
...@@ -645,6 +652,13 @@ public class WebLayerShellActivity extends AppCompatActivity { ...@@ -645,6 +652,13 @@ public class WebLayerShellActivity extends AppCompatActivity {
return Uri.parse("https://google.com"); return Uri.parse("https://google.com");
} }
// WEB_URL doesn't match port numbers. Special case "localhost:" to aid
// testing where a port is remapped.
// Use WEB_URL first to ensure this matches urls such as 'https.'
if (WEB_URL.matcher(input).matches() || input.startsWith("http://localhost:")) {
return Uri.parse(input);
}
if (input.startsWith("www.") || input.indexOf(":") == -1) { if (input.startsWith("www.") || input.indexOf(":") == -1) {
String url = "http://" + input; String url = "http://" + input;
if (WEB_URL.matcher(url).matches()) { if (WEB_URL.matcher(url).matches()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment