From fd1ea10abb9c8fecad8d883f0c40af856c4f8752 Mon Sep 17 00:00:00 2001 From: Dylan Roeh Date: Tue, 6 Jun 2017 11:45:43 -0500 Subject: [PATCH] Bug 1365636 - Use args-provided profile in GeckoView example app. r=snorp --- .../main/java/org/mozilla/gecko/GeckoView.java | 4 ++-- .../geckoview_example/GeckoViewActivity.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java index 28c838730f62..f458f27f81fb 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java @@ -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(); diff --git a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java index 0e68303a3a8b..281c915e8cdd 100644 --- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java +++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java @@ -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);