diff options
author | hush <hush@chromium.org> | 2015-10-28 16:07:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-28 23:08:38 +0000 |
commit | 46d95445d14c5702d1600ea2f5eb879ef4c66ac7 (patch) | |
tree | 6727c8e214a2da3e30677d6f81fefe586b04d10e /android_webview/glue | |
parent | 66d0d86e335fba38cc6652f179796467d485e29a (diff) | |
download | chromium_src-46d95445d14c5702d1600ea2f5eb879ef4c66ac7.zip chromium_src-46d95445d14c5702d1600ea2f5eb879ef4c66ac7.tar.gz chromium_src-46d95445d14c5702d1600ea2f5eb879ef4c66ac7.tar.bz2 |
Set FLAG_ACTIVITY_NEW_TASK when context is not an activity
Context#startActivity requires that the intent has
FLAG_ACTIVITY_NEW_TASK set if the context is not an Activity.
BUG=548807
Review URL: https://codereview.chromium.org/1413513008
Cr-Commit-Position: refs/heads/master@{#356682}
Diffstat (limited to 'android_webview/glue')
2 files changed, 15 insertions, 4 deletions
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java b/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java index a802246..e8b36a8 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/ResourcesContextWrapperFactory.java @@ -7,8 +7,10 @@ package com.android.webview.chromium; import android.content.ComponentCallbacks; import android.content.Context; import android.content.ContextWrapper; +import android.content.Intent; import android.view.LayoutInflater; +import org.chromium.android_webview.AwContents; import org.chromium.base.annotations.SuppressFBWarnings; /** @@ -89,5 +91,16 @@ public class ResourcesContextWrapperFactory { public void unregisterComponentCallbacks(ComponentCallbacks callback) { getBaseContext().unregisterComponentCallbacks(callback); } + + @Override + public void startActivity(Intent intent) { + if (AwContents.activityFromContext(this) == null) { + // FLAG_ACTIVITY_NEW_TASK is needed to start activities from a non-activity + // context. + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + } + + super.startActivity(intent); + } } } diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java index d521003..55c29c8 100644 --- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java +++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java @@ -39,6 +39,7 @@ import android.webkit.WebViewClient; import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; +import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContentsClient; import org.chromium.android_webview.AwContentsClientBridge; import org.chromium.android_webview.AwHttpAuthHandler; @@ -49,9 +50,6 @@ import org.chromium.android_webview.permission.AwPermissionRequest; import org.chromium.android_webview.permission.Resource; import org.chromium.base.ThreadUtils; import org.chromium.base.TraceEvent; -import org.chromium.content.browser.ContentView; -import org.chromium.content.browser.ContentViewClient; -import org.chromium.content.browser.ContentViewCore; import java.lang.ref.WeakReference; import java.security.Principal; @@ -873,7 +871,7 @@ public class WebViewContentsClientAdapter extends AwContentsClient { */ private boolean showDefaultJsDialog(JsPromptResult res, int jsDialogType, String defaultValue, String message, String url) { - Context activityContext = ContentViewCore.activityFromContext(mContext); + Context activityContext = AwContents.activityFromContext(mContext); if (activityContext == null) { return false; } |