Skip to content

Commit 017527d

Browse files
committed
Prepare to get the multiprocess setting from WebViewDelegate.
In future OS versions, we should fetch the multiprocess-enabled setting from WebViewDelegate instead of querying the setting directly. Add the skeleton code to get this from the delegate under a build version condition. BUG=684489 Review-Url: https://codereview.chromium.org/2645413002 Cr-Commit-Position: refs/heads/master@{#445705} (cherry picked from commit acc84fb) Review-Url: https://codereview.chromium.org/2649273004 . Cr-Commit-Position: refs/branch-heads/2987@{#56} Cr-Branched-From: ad51088-refs/heads/master@{#444943}
1 parent 0dd4403 commit 017527d

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.chromium.android_webview.PlatformServiceBridge;
5151
import org.chromium.android_webview.ResourcesContextWrapperFactory;
5252
import org.chromium.base.BuildConfig;
53+
import org.chromium.base.BuildInfo;
5354
import org.chromium.base.CommandLine;
5455
import org.chromium.base.ContextUtils;
5556
import org.chromium.base.MemoryPressureListener;
@@ -198,6 +199,13 @@ public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegate) {
198199
initialize(WebViewDelegateFactory.createProxyDelegate(delegate));
199200
}
200201

202+
/**
203+
* Constructor for internal use when a proxy delegate has already been created.
204+
*/
205+
WebViewChromiumFactoryProvider(WebViewDelegate delegate) {
206+
initialize(delegate);
207+
}
208+
201209
@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
202210
private void initialize(WebViewDelegate webViewDelegate) {
203211
mWebViewDelegate = webViewDelegate;
@@ -225,9 +233,17 @@ private void initialize(WebViewDelegate webViewDelegate) {
225233
CommandLine.init(null);
226234
}
227235

228-
if (Settings.Global.getInt(ContextUtils.getApplicationContext().getContentResolver(),
229-
Settings.Global.WEBVIEW_MULTIPROCESS, 0)
230-
== 1) {
236+
boolean multiProcess = false;
237+
if (BuildInfo.isAtLeastO()) {
238+
// Ask the system if multiprocess should be enabled on O+.
239+
multiProcess = mWebViewDelegate.isMultiProcessEnabled();
240+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
241+
// Check the multiprocess developer setting directly on N.
242+
multiProcess = Settings.Global.getInt(
243+
ContextUtils.getApplicationContext().getContentResolver(),
244+
Settings.Global.WEBVIEW_MULTIPROCESS, 0) == 1;
245+
}
246+
if (multiProcess) {
231247
CommandLine cl = CommandLine.getInstance();
232248
cl.appendSwitch("webview-sandboxed-renderer");
233249
}

android_webview/glue/java/src/com/android/webview/chromium/WebViewDelegateFactory.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ void invokeDrawGlFunctor(
8282

8383
/** @see android.webkit.WebViewDelegate#addWebViewAssetPath */
8484
void addWebViewAssetPath(Context context);
85+
86+
/** @see android.webkit.WebViewDelegate#isMultiProcessEnabled */
87+
boolean isMultiProcessEnabled();
8588
}
8689

8790
/**
@@ -110,7 +113,7 @@ static WebViewDelegate createApi21CompatibilityDelegate() {
110113
* A {@link WebViewDelegate com.android.webview.chromium.WebViewDelegate} that proxies requests
111114
* to a {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate}.
112115
*/
113-
private static class ProxyDelegate implements WebViewDelegate {
116+
static class ProxyDelegate implements WebViewDelegate {
114117
android.webkit.WebViewDelegate mDelegate;
115118

116119
ProxyDelegate(android.webkit.WebViewDelegate delegate) {
@@ -198,6 +201,11 @@ public AssetManager getAssets() {
198201
}
199202
});
200203
}
204+
205+
@Override
206+
public boolean isMultiProcessEnabled() {
207+
throw new UnsupportedOperationException();
208+
}
201209
}
202210

203211
/**
@@ -383,5 +391,10 @@ public void addWebViewAssetPath(Context context) {
383391
throw new RuntimeException("Invalid reflection", e);
384392
}
385393
}
394+
395+
@Override
396+
public boolean isMultiProcessEnabled() {
397+
throw new UnsupportedOperationException();
398+
}
386399
}
387400
}

0 commit comments

Comments
 (0)