mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 19:41:49 +00:00
Bug 1369815 - Add display mode to GeckoViewSettings r=esawin
This commit is contained in:
parent
f029ff1bf4
commit
957d44dd7a
@ -22,6 +22,24 @@ public final class GeckoViewSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public enum DisplayMode {
|
||||
// This needs to match nsIDocShell.idl
|
||||
BROWSER(0),
|
||||
MINIMAL_UI(1),
|
||||
STANDALONE(2),
|
||||
FULLSCREEN(3);
|
||||
|
||||
private final int mMode;
|
||||
|
||||
DisplayMode(int mode) {
|
||||
mMode = mode;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return mMode;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Key to enabled and disable tracking protection.
|
||||
*/
|
||||
@ -32,6 +50,7 @@ public final class GeckoViewSettings {
|
||||
*/
|
||||
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
|
||||
@ -40,6 +59,13 @@ public final class GeckoViewSettings {
|
||||
public static final Key<Boolean> USE_MULTIPROCESS =
|
||||
new Key<Boolean>("useMultiprocess");
|
||||
|
||||
/*
|
||||
* Key to specify which display-mode we should use
|
||||
*/
|
||||
public static final Key<Boolean> DISPLAY_MODE =
|
||||
new Key<Boolean>("displayMode");
|
||||
|
||||
|
||||
private final EventDispatcher mEventDispatcher;
|
||||
private final GeckoBundle mBundle;
|
||||
|
||||
@ -54,6 +80,7 @@ public final class GeckoViewSettings {
|
||||
setBoolean(USE_TRACKING_PROTECTION, false);
|
||||
setBoolean(USE_PRIVATE_MODE, false);
|
||||
setBoolean(USE_MULTIPROCESS, true);
|
||||
setInt(DISPLAY_MODE, DisplayMode.BROWSER.value());
|
||||
}
|
||||
|
||||
/* package */ GeckoViewSettings(GeckoViewSettings settings, EventDispatcher eventDispatcher) {
|
||||
@ -78,6 +105,23 @@ public final class GeckoViewSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public void setInt(final Key<Boolean> key, int value) {
|
||||
synchronized (mBundle) {
|
||||
final Object old = mBundle.get(key.text);
|
||||
if (old != null && old.equals(value)) {
|
||||
return;
|
||||
}
|
||||
mBundle.putInt(key.text, value);
|
||||
}
|
||||
dispatchUpdate();
|
||||
}
|
||||
|
||||
public int getInt(final Key<Boolean> key) {
|
||||
synchronized (mBundle) {
|
||||
return mBundle.getInt(key.text);
|
||||
}
|
||||
}
|
||||
|
||||
/* package */ GeckoBundle asBundle() {
|
||||
return mBundle;
|
||||
}
|
||||
|
@ -32,12 +32,14 @@ class GeckoViewSettings extends GeckoViewModule {
|
||||
// We only allow to set this setting during initialization, further updates
|
||||
// will be ignored.
|
||||
this.useMultiprocess = !!this.settings.useMultiprocess;
|
||||
this._displayMode = Ci.nsIDocShell.DISPLAY_MODE_BROWSER;
|
||||
}
|
||||
|
||||
onSettingsUpdate() {
|
||||
debug("onSettingsUpdate: " + JSON.stringify(this.settings));
|
||||
|
||||
this.useTrackingProtection = !!this.settings.useTrackingProtection;
|
||||
this.displayMode = this.settings.displayMode;
|
||||
}
|
||||
|
||||
get useTrackingProtection() {
|
||||
@ -51,7 +53,7 @@ class GeckoViewSettings extends GeckoViewModule {
|
||||
}
|
||||
if (aUse != this._useTrackingProtection) {
|
||||
this.messageManager.loadFrameScript("data:," +
|
||||
"docShell.useTrackingProtection = " + aUse,
|
||||
`docShell.useTrackingProtection = ${aUse}`,
|
||||
true
|
||||
);
|
||||
this._useTrackingProtection = aUse;
|
||||
@ -76,4 +78,22 @@ class GeckoViewSettings extends GeckoViewModule {
|
||||
}
|
||||
parentNode.appendChild(this.browser);
|
||||
}
|
||||
|
||||
get displayMode() {
|
||||
return this._displayMode;
|
||||
}
|
||||
|
||||
set displayMode(aMode) {
|
||||
if (!this.useMultiprocess) {
|
||||
this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDocShell)
|
||||
.displayMode = aMode;
|
||||
} else {
|
||||
this.messageManager.loadFrameScript("data:," +
|
||||
`docShell.displayMode = ${aMode}`,
|
||||
true
|
||||
);
|
||||
}
|
||||
this._displayMode = aMode;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user