Skip to content

Commit

Permalink
Prepare to get the multiprocess setting from WebViewDelegate.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
tornewuff committed Jan 24, 2017
1 parent 0dd4403 commit 017527d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.chromium.android_webview.PlatformServiceBridge;
import org.chromium.android_webview.ResourcesContextWrapperFactory;
import org.chromium.base.BuildConfig;
import org.chromium.base.BuildInfo;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.MemoryPressureListener;
Expand Down Expand Up @@ -198,6 +199,13 @@ public WebViewChromiumFactoryProvider(android.webkit.WebViewDelegate delegate) {
initialize(WebViewDelegateFactory.createProxyDelegate(delegate));
}

/**
* Constructor for internal use when a proxy delegate has already been created.
*/
WebViewChromiumFactoryProvider(WebViewDelegate delegate) {
initialize(delegate);
}

@SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
private void initialize(WebViewDelegate webViewDelegate) {
mWebViewDelegate = webViewDelegate;
Expand Down Expand Up @@ -225,9 +233,17 @@ private void initialize(WebViewDelegate webViewDelegate) {
CommandLine.init(null);
}

if (Settings.Global.getInt(ContextUtils.getApplicationContext().getContentResolver(),
Settings.Global.WEBVIEW_MULTIPROCESS, 0)
== 1) {
boolean multiProcess = false;
if (BuildInfo.isAtLeastO()) {
// Ask the system if multiprocess should be enabled on O+.
multiProcess = mWebViewDelegate.isMultiProcessEnabled();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// Check the multiprocess developer setting directly on N.
multiProcess = Settings.Global.getInt(
ContextUtils.getApplicationContext().getContentResolver(),
Settings.Global.WEBVIEW_MULTIPROCESS, 0) == 1;
}
if (multiProcess) {
CommandLine cl = CommandLine.getInstance();
cl.appendSwitch("webview-sandboxed-renderer");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void invokeDrawGlFunctor(

/** @see android.webkit.WebViewDelegate#addWebViewAssetPath */
void addWebViewAssetPath(Context context);

/** @see android.webkit.WebViewDelegate#isMultiProcessEnabled */
boolean isMultiProcessEnabled();
}

/**
Expand Down Expand Up @@ -110,7 +113,7 @@ static WebViewDelegate createApi21CompatibilityDelegate() {
* A {@link WebViewDelegate com.android.webview.chromium.WebViewDelegate} that proxies requests
* to a {@link android.webkit.WebViewDelegate android.webkit.WebViewDelegate}.
*/
private static class ProxyDelegate implements WebViewDelegate {
static class ProxyDelegate implements WebViewDelegate {
android.webkit.WebViewDelegate mDelegate;

ProxyDelegate(android.webkit.WebViewDelegate delegate) {
Expand Down Expand Up @@ -198,6 +201,11 @@ public AssetManager getAssets() {
}
});
}

@Override
public boolean isMultiProcessEnabled() {
throw new UnsupportedOperationException();
}
}

/**
Expand Down Expand Up @@ -383,5 +391,10 @@ public void addWebViewAssetPath(Context context) {
throw new RuntimeException("Invalid reflection", e);
}
}

@Override
public boolean isMultiProcessEnabled() {
throw new UnsupportedOperationException();
}
}
}

0 comments on commit 017527d

Please sign in to comment.