mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1219016 - Store application context in GeckoAppShell; r=snorp
This patch adds separate setter and getter for the application context in GeckoAppShell. The existing getContext method is misused for both application and activity context, so new methods are added to improve consistency.
This commit is contained in:
parent
9d879a0145
commit
776204544b
@ -1280,6 +1280,7 @@ public abstract class GeckoApp
|
||||
// When that's fixed, `this` can change to
|
||||
// `(GeckoApplication) getApplication()` here.
|
||||
GeckoAppShell.setContextGetter(this);
|
||||
GeckoAppShell.setApplicationContext(getApplicationContext());
|
||||
GeckoAppShell.setGeckoInterface(this);
|
||||
|
||||
Tabs.getInstance().attachToContext(this);
|
||||
|
@ -2045,6 +2045,7 @@ public class GeckoAppShell
|
||||
}
|
||||
}
|
||||
|
||||
private static Context sApplicationContext;
|
||||
private static ContextGetter sContextGetter;
|
||||
|
||||
@WrapForJNI(allowMultithread = true)
|
||||
@ -2056,6 +2057,14 @@ public class GeckoAppShell
|
||||
sContextGetter = cg;
|
||||
}
|
||||
|
||||
public static Context getApplicationContext() {
|
||||
return sApplicationContext;
|
||||
}
|
||||
|
||||
public static void setApplicationContext(final Context context) {
|
||||
sApplicationContext = context;
|
||||
}
|
||||
|
||||
public static SharedPreferences getSharedPreferences() {
|
||||
if (sContextGetter == null) {
|
||||
throw new IllegalStateException("No ContextGetter; cannot fetch prefs.");
|
||||
|
@ -139,6 +139,10 @@ public class GeckoView extends LayerView
|
||||
|
||||
private void init(Context context, String url, boolean doInit) {
|
||||
|
||||
if (GeckoAppShell.getApplicationContext() == null) {
|
||||
GeckoAppShell.setApplicationContext(context.getApplicationContext());
|
||||
}
|
||||
|
||||
// Set the GeckoInterface if the context is an activity and the GeckoInterface
|
||||
// has not already been set
|
||||
if (context instanceof Activity && getGeckoInterface() == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user