mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1146325 - Convert loaded tab queue data to the required format and send to gecko to open (r=margaret)
This commit is contained in:
parent
3418adedea
commit
ec686db052
@ -6,6 +6,8 @@
|
||||
package org.mozilla.gecko.tabqueue;
|
||||
|
||||
import org.mozilla.gecko.BrowserApp;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.GeckoProfile;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.R;
|
||||
@ -21,6 +23,8 @@ import android.content.res.Resources;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class TabQueueHelper {
|
||||
private static final String LOGTAG = "Gecko" + TabQueueHelper.class.getSimpleName();
|
||||
@ -121,7 +125,16 @@ public class TabQueueHelper {
|
||||
|
||||
JSONArray jsonArray = profile.readJSONArrayFromFile(filename);
|
||||
|
||||
// TODO: Convert data to required format for gecko to process and send to Gecko - Bug 1146325
|
||||
if (jsonArray.length() > 0) {
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("urls", jsonArray);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Tabs:OpenMultiple", data.toString()));
|
||||
} catch (JSONException e) {
|
||||
// Don't exit early as we perform cleanup at the end of this function.
|
||||
Log.e(LOGTAG, "Error sending tab queue data", e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
profile.deleteFileFromProfileDir(filename);
|
||||
|
@ -88,6 +88,7 @@ SessionStore.prototype = {
|
||||
observerService.addObserver(this, "ClosedTabs:StopNotifications", true);
|
||||
observerService.addObserver(this, "last-pb-context-exited", true);
|
||||
observerService.addObserver(this, "Session:RestoreRecentTabs", true);
|
||||
observerService.addObserver(this, "Tabs:OpenMultiple", true);
|
||||
break;
|
||||
case "final-ui-startup":
|
||||
observerService.removeObserver(this, "final-ui-startup");
|
||||
@ -157,6 +158,11 @@ SessionStore.prototype = {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "Tabs:OpenMultiple": {
|
||||
let data = JSON.parse(aData);
|
||||
this._openTabs(data);
|
||||
break;
|
||||
}
|
||||
case "application-background":
|
||||
// We receive this notification when Android's onPause callback is
|
||||
// executed. After onPause, the application may be terminated at any
|
||||
@ -910,6 +916,21 @@ SessionStore.prototype = {
|
||||
return shEntry;
|
||||
},
|
||||
|
||||
// This function iterates through a list of urls opening a new tab for each.
|
||||
_openTabs: function ss_openTabs(aData) {
|
||||
let window = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
for (let i = 0; i < aData.urls.length; i++) {
|
||||
let url = aData.urls[i];
|
||||
let params = {
|
||||
selected: (i == aData.urls.length - 1),
|
||||
isPrivate: false,
|
||||
desktopMode: false,
|
||||
};
|
||||
|
||||
let tab = window.BrowserApp.addTab(url, params);
|
||||
}
|
||||
},
|
||||
|
||||
// This function iterates through a list of tab data restoring session for each of them.
|
||||
_restoreTabs: function ss_restoreTabs(aData) {
|
||||
let window = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
|
Loading…
Reference in New Issue
Block a user