mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 11:45:37 +00:00
Bug 1454441 - 3. Move remote debugging setting to runtime; r=esawin,snorp
Move the remote debugging setting to GeckoRuntimeSettings and use it in geckoview_example. MozReview-Commit-ID: LW4f4qenUrx --HG-- extra : rebase_source : 3664b00d6b66a835063a8333e0151760f7aa8bcb
This commit is contained in:
parent
8f892bc71d
commit
51abedf496
@ -125,10 +125,6 @@ public class CustomTabsActivity extends AppCompatActivity
|
|||||||
|
|
||||||
final GeckoSessionSettings settings = new GeckoSessionSettings();
|
final GeckoSessionSettings settings = new GeckoSessionSettings();
|
||||||
settings.setBoolean(GeckoSessionSettings.USE_MULTIPROCESS, false);
|
settings.setBoolean(GeckoSessionSettings.USE_MULTIPROCESS, false);
|
||||||
settings.setBoolean(
|
|
||||||
GeckoSessionSettings.USE_REMOTE_DEBUGGER,
|
|
||||||
GeckoSharedPrefs.forApp(this).getBoolean(
|
|
||||||
GeckoPreferences.PREFS_DEVTOOLS_REMOTE_USB_ENABLED, false));
|
|
||||||
mGeckoSession = new GeckoSession(settings);
|
mGeckoSession = new GeckoSession(settings);
|
||||||
mGeckoSession.setNavigationDelegate(this);
|
mGeckoSession.setNavigationDelegate(this);
|
||||||
mGeckoSession.setProgressDelegate(this);
|
mGeckoSession.setProgressDelegate(this);
|
||||||
|
@ -93,10 +93,6 @@ public class WebAppActivity extends AppCompatActivity
|
|||||||
|
|
||||||
final GeckoSessionSettings settings = new GeckoSessionSettings();
|
final GeckoSessionSettings settings = new GeckoSessionSettings();
|
||||||
settings.setBoolean(GeckoSessionSettings.USE_MULTIPROCESS, false);
|
settings.setBoolean(GeckoSessionSettings.USE_MULTIPROCESS, false);
|
||||||
settings.setBoolean(
|
|
||||||
GeckoSessionSettings.USE_REMOTE_DEBUGGER,
|
|
||||||
GeckoSharedPrefs.forApp(this).getBoolean(
|
|
||||||
GeckoPreferences.PREFS_DEVTOOLS_REMOTE_USB_ENABLED, false));
|
|
||||||
mGeckoSession = new GeckoSession(settings);
|
mGeckoSession = new GeckoSession(settings);
|
||||||
mGeckoView.setSession(mGeckoSession, GeckoRuntime.getDefault(this));
|
mGeckoView.setSession(mGeckoSession, GeckoRuntime.getDefault(this));
|
||||||
|
|
||||||
|
@ -145,7 +145,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
|
|||||||
SCREEN_ID,
|
SCREEN_ID,
|
||||||
USE_MULTIPROCESS,
|
USE_MULTIPROCESS,
|
||||||
USE_PRIVATE_MODE,
|
USE_PRIVATE_MODE,
|
||||||
USE_REMOTE_DEBUGGER,
|
|
||||||
USE_TRACKING_PROTECTION;
|
USE_TRACKING_PROTECTION;
|
||||||
|
|
||||||
private final GeckoSessionSettings.Key<?> mKey;
|
private final GeckoSessionSettings.Key<?> mKey;
|
||||||
|
@ -82,6 +82,16 @@ public final class GeckoRuntimeSettings implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether remote debugging support should be enabled.
|
||||||
|
*
|
||||||
|
* @param enabled True if remote debugging should be enabled.
|
||||||
|
*/
|
||||||
|
public @NonNull Builder remoteDebuggingEnabled(final boolean enabled) {
|
||||||
|
mSettings.mRemoteDebugging.set(enabled);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether support for web fonts should be enabled.
|
* Set whether support for web fonts should be enabled.
|
||||||
*
|
*
|
||||||
@ -130,11 +140,13 @@ public final class GeckoRuntimeSettings implements Parcelable {
|
|||||||
|
|
||||||
/* package */ Pref<Boolean> mJavaScript = new Pref<Boolean>(
|
/* package */ Pref<Boolean> mJavaScript = new Pref<Boolean>(
|
||||||
"javascript.enabled", true);
|
"javascript.enabled", true);
|
||||||
|
/* package */ Pref<Boolean> mRemoteDebugging = new Pref<Boolean>(
|
||||||
|
"devtools.debugger.remote-enabled", false);
|
||||||
/* package */ Pref<Boolean> mWebFonts = new Pref<Boolean>(
|
/* package */ Pref<Boolean> mWebFonts = new Pref<Boolean>(
|
||||||
"browser.display.use_document_fonts", true);
|
"browser.display.use_document_fonts", true);
|
||||||
|
|
||||||
private final Pref<?>[] mPrefs = new Pref<?>[] {
|
private final Pref<?>[] mPrefs = new Pref<?>[] {
|
||||||
mJavaScript, mWebFonts
|
mJavaScript, mRemoteDebugging, mWebFonts
|
||||||
};
|
};
|
||||||
|
|
||||||
/* package */ GeckoRuntimeSettings() {
|
/* package */ GeckoRuntimeSettings() {
|
||||||
@ -149,12 +161,18 @@ public final class GeckoRuntimeSettings implements Parcelable {
|
|||||||
if (settings == null) {
|
if (settings == null) {
|
||||||
mArgs = new String[0];
|
mArgs = new String[0];
|
||||||
mExtras = new Bundle();
|
mExtras = new Bundle();
|
||||||
} else {
|
return;
|
||||||
mUseContentProcess = settings.getUseContentProcessHint();
|
}
|
||||||
mArgs = settings.getArguments().clone();
|
|
||||||
mExtras = new Bundle(settings.getExtras());
|
mUseContentProcess = settings.getUseContentProcessHint();
|
||||||
mJavaScript.set(settings.mJavaScript.get());
|
mArgs = settings.getArguments().clone();
|
||||||
mWebFonts.set(settings.mWebFonts.get());
|
mExtras = new Bundle(settings.getExtras());
|
||||||
|
|
||||||
|
for (int i = 0; i < mPrefs.length; i++) {
|
||||||
|
// We know this is safe.
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Pref<Object> uncheckedPref = (Pref<Object>) mPrefs[i];
|
||||||
|
uncheckedPref.set(settings.mPrefs[i].get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +228,25 @@ public final class GeckoRuntimeSettings implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether remote debugging support is enabled.
|
||||||
|
*
|
||||||
|
* @return True if remote debugging support is enabled.
|
||||||
|
*/
|
||||||
|
public boolean getRemoteDebuggingEnabled() {
|
||||||
|
return mRemoteDebugging.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether remote debugging support should be enabled.
|
||||||
|
*
|
||||||
|
* @param enabled True if remote debugging should be enabled.
|
||||||
|
*/
|
||||||
|
public @NonNull GeckoRuntimeSettings setRemoteDebuggingEnabled(final boolean enabled) {
|
||||||
|
mRemoteDebugging.set(enabled);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether web fonts support is enabled.
|
* Get whether web fonts support is enabled.
|
||||||
*
|
*
|
||||||
@ -239,8 +276,10 @@ public final class GeckoRuntimeSettings implements Parcelable {
|
|||||||
out.writeByte((byte) (mUseContentProcess ? 1 : 0));
|
out.writeByte((byte) (mUseContentProcess ? 1 : 0));
|
||||||
out.writeStringArray(mArgs);
|
out.writeStringArray(mArgs);
|
||||||
mExtras.writeToParcel(out, flags);
|
mExtras.writeToParcel(out, flags);
|
||||||
out.writeByte((byte) (mJavaScript.get() ? 1 : 0));
|
|
||||||
out.writeByte((byte) (mWebFonts.get() ? 1 : 0));
|
for (final Pref<?> pref : mPrefs) {
|
||||||
|
out.writeValue(pref.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AIDL code may call readFromParcel even though it's not part of Parcelable.
|
// AIDL code may call readFromParcel even though it's not part of Parcelable.
|
||||||
@ -248,8 +287,13 @@ public final class GeckoRuntimeSettings implements Parcelable {
|
|||||||
mUseContentProcess = source.readByte() == 1;
|
mUseContentProcess = source.readByte() == 1;
|
||||||
mArgs = source.createStringArray();
|
mArgs = source.createStringArray();
|
||||||
mExtras.readFromParcel(source);
|
mExtras.readFromParcel(source);
|
||||||
mJavaScript.set(source.readByte() == 1);
|
|
||||||
mWebFonts.set(source.readByte() == 1);
|
for (final Pref<?> pref : mPrefs) {
|
||||||
|
// We know this is safe.
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final Pref<Object> uncheckedPref = (Pref<Object>) pref;
|
||||||
|
uncheckedPref.set(source.readValue(getClass().getClassLoader()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<GeckoRuntimeSettings> CREATOR
|
public static final Parcelable.Creator<GeckoRuntimeSettings> CREATOR
|
||||||
|
@ -90,9 +90,6 @@ public final class GeckoSessionSettings implements Parcelable {
|
|||||||
Arrays.asList(DISPLAY_MODE_BROWSER, DISPLAY_MODE_MINIMAL_UI,
|
Arrays.asList(DISPLAY_MODE_BROWSER, DISPLAY_MODE_MINIMAL_UI,
|
||||||
DISPLAY_MODE_STANDALONE, DISPLAY_MODE_FULLSCREEN));
|
DISPLAY_MODE_STANDALONE, DISPLAY_MODE_FULLSCREEN));
|
||||||
|
|
||||||
public static final Key<Boolean> USE_REMOTE_DEBUGGER =
|
|
||||||
new Key<Boolean>("useRemoteDebugger");
|
|
||||||
|
|
||||||
private final GeckoSession mSession;
|
private final GeckoSession mSession;
|
||||||
private final GeckoBundle mBundle;
|
private final GeckoBundle mBundle;
|
||||||
|
|
||||||
@ -121,7 +118,6 @@ public final class GeckoSessionSettings implements Parcelable {
|
|||||||
mBundle.putBoolean(USE_MULTIPROCESS.name, true);
|
mBundle.putBoolean(USE_MULTIPROCESS.name, true);
|
||||||
mBundle.putBoolean(USE_DESKTOP_MODE.name, false);
|
mBundle.putBoolean(USE_DESKTOP_MODE.name, false);
|
||||||
mBundle.putInt(DISPLAY_MODE.name, DISPLAY_MODE_BROWSER);
|
mBundle.putInt(DISPLAY_MODE.name, DISPLAY_MODE_BROWSER);
|
||||||
mBundle.putBoolean(USE_REMOTE_DEBUGGER.name, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBoolean(final Key<Boolean> key, final boolean value) {
|
public void setBoolean(final Key<Boolean> key, final boolean value) {
|
||||||
|
@ -138,12 +138,8 @@ public class GeckoViewActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadSettings(final Intent intent) {
|
private void loadSettings(final Intent intent) {
|
||||||
final GeckoSessionSettings settings = mGeckoSession.getSettings();
|
sGeckoRuntime.getSettings().setRemoteDebuggingEnabled(
|
||||||
settings.setBoolean(
|
|
||||||
GeckoSessionSettings.USE_REMOTE_DEBUGGER,
|
|
||||||
intent.getBooleanExtra(USE_REMOTE_DEBUGGER_EXTRA, false));
|
intent.getBooleanExtra(USE_REMOTE_DEBUGGER_EXTRA, false));
|
||||||
|
|
||||||
Log.i(LOGTAG, "Load with settings " + settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user