Commit 6a66c00f authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: move getSafeBrowsingPrivacyPolicyUrl to UI thread

This is a follow-up to http://crrev/c/958229.

This moves the implementation of getSafeBrowsingPrivacyPolicyUrl() to
the UI thread, and adds a DCHECK to assert this. This was done under
boliu@'s recommendation, since AwBrowserContext seems like it should be
used mainly on the UI thread only (based on how content::BrowserContext
is used).

We still permit apps to call WebView#getSafeBrowsingPrivacyPolicyUrl()
on any thread, since it is a static method. We accommodate this by
blocking and running on the UI thread.

Test: run_webview_instrumentation_test_apk -f SafeBrowsingTest#testGetSafeBrowsingPrivacyPolicyUrl
Change-Id: I275825d6a49e08247e2839ec4a93272ce4204c98
Reviewed-on: https://chromium-review.googlesource.com/958040Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542901}
parent 58b49ba3
......@@ -58,7 +58,7 @@ ScopedJavaLocalRef<jstring>
JNI_AwContentsStatics_GetSafeBrowsingPrivacyPolicyUrl(
JNIEnv* env,
const JavaParamRef<jclass>&) {
// TODO(ntfschr): limit this to only the UI thread.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GURL privacy_policy_url(
security_interstitials::kSafeBrowsingPrivacyPolicyUrl);
std::string locale =
......
......@@ -110,6 +110,7 @@ public class SharedStatics {
* to users.
*/
public Uri getSafeBrowsingPrivacyPolicyUrl() {
return AwContentsStatics.getSafeBrowsingPrivacyPolicyUrl();
return ThreadUtils.runOnUiThreadBlockingNoException(
() -> AwContentsStatics.getSafeBrowsingPrivacyPolicyUrl());
}
}
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