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:
Jim Chen 2018-04-20 15:51:30 -04:00
Родитель 8f892bc71d
Коммит 51abedf496
6 изменённых файлов: 56 добавлений и 29 удалений

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

@ -125,10 +125,6 @@ public class CustomTabsActivity extends AppCompatActivity
final GeckoSessionSettings settings = new GeckoSessionSettings();
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.setNavigationDelegate(this);
mGeckoSession.setProgressDelegate(this);

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

@ -93,10 +93,6 @@ public class WebAppActivity extends AppCompatActivity
final GeckoSessionSettings settings = new GeckoSessionSettings();
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);
mGeckoView.setSession(mGeckoSession, GeckoRuntime.getDefault(this));

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

@ -145,7 +145,6 @@ public class GeckoSessionTestRule extends UiThreadTestRule {
SCREEN_ID,
USE_MULTIPROCESS,
USE_PRIVATE_MODE,
USE_REMOTE_DEBUGGER,
USE_TRACKING_PROTECTION;
private final GeckoSessionSettings.Key<?> mKey;

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

@ -82,6 +82,16 @@ public final class GeckoRuntimeSettings implements Parcelable {
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.
*
@ -130,11 +140,13 @@ public final class GeckoRuntimeSettings implements Parcelable {
/* package */ Pref<Boolean> mJavaScript = new Pref<Boolean>(
"javascript.enabled", true);
/* package */ Pref<Boolean> mRemoteDebugging = new Pref<Boolean>(
"devtools.debugger.remote-enabled", false);
/* package */ Pref<Boolean> mWebFonts = new Pref<Boolean>(
"browser.display.use_document_fonts", true);
private final Pref<?>[] mPrefs = new Pref<?>[] {
mJavaScript, mWebFonts
mJavaScript, mRemoteDebugging, mWebFonts
};
/* package */ GeckoRuntimeSettings() {
@ -149,12 +161,18 @@ public final class GeckoRuntimeSettings implements Parcelable {
if (settings == null) {
mArgs = new String[0];
mExtras = new Bundle();
} else {
mUseContentProcess = settings.getUseContentProcessHint();
mArgs = settings.getArguments().clone();
mExtras = new Bundle(settings.getExtras());
mJavaScript.set(settings.mJavaScript.get());
mWebFonts.set(settings.mWebFonts.get());
return;
}
mUseContentProcess = settings.getUseContentProcessHint();
mArgs = settings.getArguments().clone();
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;
}
/**
* 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.
*
@ -239,8 +276,10 @@ public final class GeckoRuntimeSettings implements Parcelable {
out.writeByte((byte) (mUseContentProcess ? 1 : 0));
out.writeStringArray(mArgs);
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.
@ -248,8 +287,13 @@ public final class GeckoRuntimeSettings implements Parcelable {
mUseContentProcess = source.readByte() == 1;
mArgs = source.createStringArray();
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

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

@ -90,9 +90,6 @@ public final class GeckoSessionSettings implements Parcelable {
Arrays.asList(DISPLAY_MODE_BROWSER, DISPLAY_MODE_MINIMAL_UI,
DISPLAY_MODE_STANDALONE, DISPLAY_MODE_FULLSCREEN));
public static final Key<Boolean> USE_REMOTE_DEBUGGER =
new Key<Boolean>("useRemoteDebugger");
private final GeckoSession mSession;
private final GeckoBundle mBundle;
@ -121,7 +118,6 @@ public final class GeckoSessionSettings implements Parcelable {
mBundle.putBoolean(USE_MULTIPROCESS.name, true);
mBundle.putBoolean(USE_DESKTOP_MODE.name, false);
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) {

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

@ -138,12 +138,8 @@ public class GeckoViewActivity extends Activity {
}
private void loadSettings(final Intent intent) {
final GeckoSessionSettings settings = mGeckoSession.getSettings();
settings.setBoolean(
GeckoSessionSettings.USE_REMOTE_DEBUGGER,
sGeckoRuntime.getSettings().setRemoteDebuggingEnabled(
intent.getBooleanExtra(USE_REMOTE_DEBUGGER_EXTRA, false));
Log.i(LOGTAG, "Load with settings " + settings);
}
@Override