Commit 5566a0f4 authored by Benoit Lize's avatar Benoit Lize Committed by Commit Bot

android: Don't crash when a bad ACTION_VIEW intent is received.

ACTION_VIEW intents should contain a Uri as data, but in some cases they
might not (explicit intent incorrectly set, for instance). Don't crash
in this case.

For instance,
adb shell am start -a android.intent.action.VIEW -n org.chromium.chrome/com.google.android.apps.chrome.Main
would crash, this fixes it.

BUG=742294

Change-Id: Ic44d7cb656d193449363ef63506e0d9852a6e782
Reviewed-on: https://chromium-review.googlesource.com/569964
Commit-Queue: Benoit L <lizeb@chromium.org>
Reviewed-by: default avatarNicolas Dossou-Gbété <dgn@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487438}
parent eee5116e
...@@ -231,9 +231,11 @@ public final class WarmupManager { ...@@ -231,9 +231,11 @@ public final class WarmupManager {
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
if (uri == null) return; if (uri == null) return;
String scheme = uri.normalizeScheme().getScheme();
boolean isHttp = UrlConstants.HTTP_SCHEME.equals(scheme);
if (!isHttp && !UrlConstants.HTTPS_SCHEME.equals(scheme)) return;
// HTTP connections will not be used when the data reduction proxy is enabled. // HTTP connections will not be used when the data reduction proxy is enabled.
if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled() if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled() && isHttp) {
&& UrlConstants.HTTP_SCHEME.equals(uri.normalizeScheme().getScheme())) {
return; return;
} }
......
...@@ -35,6 +35,7 @@ import org.chromium.base.library_loader.LoaderErrors; ...@@ -35,6 +35,7 @@ import org.chromium.base.library_loader.LoaderErrors;
import org.chromium.base.library_loader.ProcessInitException; import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeApplication; import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.WarmupManager; import org.chromium.chrome.browser.WarmupManager;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
import org.chromium.chrome.browser.metrics.MemoryUma; import org.chromium.chrome.browser.metrics.MemoryUma;
...@@ -185,14 +186,17 @@ public abstract class AsyncInitializationActivity extends AppCompatActivity impl ...@@ -185,14 +186,17 @@ public abstract class AsyncInitializationActivity extends AppCompatActivity impl
@Override @Override
public void maybePreconnect() { public void maybePreconnect() {
TraceEvent.begin("maybePreconnect"); try {
Intent intent = getIntent(); TraceEvent.begin("maybePreconnect");
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { Intent intent = getIntent();
final String url = intent.getDataString(); if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction())) return;
WarmupManager.getInstance() String url = IntentHandler.getUrlFromIntent(intent);
.maybePreconnectUrlAndSubResources(Profile.getLastUsedProfile(), url); if (url == null) return;
WarmupManager.getInstance().maybePreconnectUrlAndSubResources(
Profile.getLastUsedProfile(), url);
} finally {
TraceEvent.end("maybePreconnect");
} }
TraceEvent.end("maybePreconnect");
} }
@Override @Override
......
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