Bug 1332331 - [1.1] Add multiprocess GeckoView setting. r=snorp DONTBUILD

This commit is contained in:
Eugen Sawin 2017-04-19 22:32:32 +02:00
Родитель d6ef64ba74
Коммит a439cf46a2
3 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -10,7 +10,7 @@
windowtype="navigator:browser"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<browser id="content" type="content" primary="true" src="about:blank" flex="1" remote="true"/>
<browser id="content" type="content" primary="true" src="about:blank" flex="1"/>
<script type="application/javascript" src="chrome://geckoview/content/geckoview.js"/>
</window>

Просмотреть файл

@ -22,10 +22,23 @@ public final class GeckoViewSettings {
}
}
/*
* Key to enabled and disable tracking protection.
*/
public static final Key<Boolean> USE_TRACKING_PROTECTION =
new Key<Boolean>("useTrackingProtection");
/*
* Key to enabled and disable private mode browsing.
*/
public static final Key<Boolean> USE_PRIVATE_MODE =
new Key<Boolean>("usePrivateMode");
/*
* Key to enabled and disable multiprocess browsing (e10s).
* Note: can only be set during GeckoView initialization, changes during an
* active GeckoView session will be ignored.
*/
public static final Key<Boolean> USE_MULTIPROCESS =
new Key<Boolean>("useMultiprocess");
private final EventDispatcher mEventDispatcher;
private final GeckoBundle mBundle;
@ -40,6 +53,7 @@ public final class GeckoViewSettings {
setBoolean(USE_TRACKING_PROTECTION, false);
setBoolean(USE_PRIVATE_MODE, false);
setBoolean(USE_MULTIPROCESS, true);
}
/* package */ GeckoViewSettings(GeckoViewSettings settings, EventDispatcher eventDispatcher) {

Просмотреть файл

@ -23,10 +23,15 @@ function debug(aMsg) {
// Handles GeckoView settings including:
// * tracking protection
// * multiprocess
class GeckoViewSettings extends GeckoViewModule {
init() {
this._isSafeBrowsingInit = false;
this._useTrackingProtection = false;
// We only allow to set this setting during initialization, further updates
// will be ignored.
this.useMultiprocess = !!this.settings.useMultiprocess;
}
onSettingsUpdate() {
@ -52,4 +57,23 @@ class GeckoViewSettings extends GeckoViewModule {
this._useTrackingProtection = aUse;
}
}
get useMultiprocess() {
return this.browser.getAttribute("remote") == "true";
}
set useMultiprocess(aUse) {
if (aUse == this.useMultiprocess) {
return;
}
let parentNode = this.browser.parentNode;
parentNode.removeChild(this.browser);
if (aUse) {
this.browser.setAttribute("remote", "true");
} else {
this.browser.removeAttribute("remote");
}
parentNode.appendChild(this.browser);
}
}