Bug 1365636 - Use args-provided profile in GeckoView example app. r=snorp

This commit is contained in:
Dylan Roeh 2017-06-06 11:45:43 -05:00
Родитель 14713f207c
Коммит fd1ea10abb
2 изменённых файлов: 17 добавлений и 3 удалений

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

@ -306,7 +306,7 @@ public class GeckoView extends LayerView {
/**
* Preload GeckoView by starting Gecko with the specified arguments in the background,
* if Geckois not already running.
* if Gecko is not already running.
*
* @param context Activity or Application Context for starting GeckoView.
* @param geckoArgs Arguments to be passed to Gecko, if Gecko is not already running
@ -317,7 +317,7 @@ public class GeckoView extends LayerView {
GeckoAppShell.setApplicationContext(appContext);
}
if (GeckoThread.initMainProcess(GeckoProfile.get(appContext),
if (GeckoThread.initMainProcess(GeckoProfile.initFromArgs(appContext, geckoArgs),
geckoArgs,
/* debugging */ false)) {
GeckoThread.launch();

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

@ -10,6 +10,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
@ -31,11 +32,24 @@ public class GeckoViewActivity extends Activity {
Log.i(LOGTAG, "zerdatime " + SystemClock.elapsedRealtime() +
" - application start");
String geckoArgs = null;
final String intentArgs = getIntent().getStringExtra("args");
if (BuildConfig.DEBUG) {
// In debug builds, we want to load JavaScript resources fresh with each build.
GeckoView.preload(this, "-purgecaches");
geckoArgs = "-purgecaches";
}
if (!TextUtils.isEmpty(intentArgs)) {
if (geckoArgs == null) {
geckoArgs = intentArgs;
} else {
geckoArgs += " " + intentArgs;
}
}
GeckoView.preload(this, geckoArgs);
setContentView(R.layout.geckoview_activity);
mGeckoView = (GeckoView) findViewById(R.id.gecko_view);