Backed out 2 changesets (bug 1052276) for causing various Android failures

Backed out changeset fb6d69690255 (bug 1052276)
Backed out changeset 14a934f9c207 (bug 1052276)
This commit is contained in:
Wes Kocher 2014-08-14 16:36:59 -07:00
parent 43f46a56f1
commit 76e9302a18
9 changed files with 87 additions and 122 deletions

View File

@ -610,7 +610,8 @@ public abstract class GeckoApp
if (button != null) {
final String label = button.optString("label", "");
final String icon = button.optString("icon", "");
showButtonToast(msg, duration, label, icon, callback);
final String id = button.optString("id", "");
showButtonToast(msg, duration, label, icon, id);
} else {
showNormalToast(msg, duration);
}
@ -789,21 +790,21 @@ public abstract class GeckoApp
void showButtonToast(final String message, final String duration,
final String buttonText, final String buttonIcon,
final EventCallback callback) {
final String buttonId) {
BitmapUtils.getDrawable(GeckoApp.this, buttonIcon, new BitmapUtils.BitmapLoader() {
@Override
public void onBitmapFound(final Drawable d) {
final int toastDuration = duration.equals("long") ? ButtonToast.LENGTH_LONG : ButtonToast.LENGTH_SHORT;
getButtonToast().show(false, message, toastDuration, buttonText, d, new ButtonToast.ToastListener() {
getButtonToast().show(false, message, toastDuration ,buttonText, d, new ButtonToast.ToastListener() {
@Override
public void onButtonClicked() {
callback.sendSuccess(null);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Toast:Click", buttonId));
}
@Override
public void onToastHidden(ButtonToast.ReasonHidden reason) {
if (reason == ButtonToast.ReasonHidden.TIMEOUT) {
callback.sendCancel();
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Toast:Hidden", buttonId));
}
}
});

View File

@ -3,9 +3,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
XPCOMUtils.defineLazyModuleGetter(this, "Toast",
"resource://gre/modules/Toast.jsm");
var MasterPassword = {
pref: "privacy.masterpassword.enabled",
_tokenName: "",
@ -64,7 +61,7 @@ var MasterPassword = {
} catch(e) {
dump("MasterPassword.removePassword: " + e + "\n");
}
Toast.show(Strings.browser.GetStringFromName("masterPassword.incorrect"), Toast.SHORT);
NativeWindow.toast.show(Strings.browser.GetStringFromName("masterPassword.incorrect"), "short");
return false;
}
};

View File

@ -4,9 +4,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
XPCOMUtils.defineLazyModuleGetter(this, "Toast",
"resource://gre/modules/Toast.jsm");
// Define elements that bound phone number containers.
const PHONE_NUMBER_CONTAINERS = "td,div";
@ -924,7 +921,7 @@ var SelectionHandler = {
if (selectedText.length) {
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
clipboard.copyString(selectedText, this._contentWindow.document);
Toast.show(Strings.browser.GetStringFromName("selectionHelper.textCopied"), Toast.SHORT);
NativeWindow.toast.show(Strings.browser.GetStringFromName("selectionHelper.textCopied"), "short");
}
this._closeSelection();
},

View File

@ -10,9 +10,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry",
"resource://gre/modules/UITelemetry.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Toast",
"resource://gre/modules/Toast.jsm");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", function ()
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
@ -514,7 +511,7 @@ AboutReader.prototype = {
if (!visible && !this._hasUsedToolbar) {
this._hasUsedToolbar = Services.prefs.getBoolPref("reader.has_used_toolbar");
if (!this._hasUsedToolbar) {
Toast.show(gStrings.GetStringFromName("aboutReader.toolbarTip"), Toast.SHORT);
gChromeWin.NativeWindow.toast.show(gStrings.GetStringFromName("aboutReader.toolbarTip"), "short");
Services.prefs.setBoolPref("reader.has_used_toolbar", true);
this._hasUsedToolbar = true;

View File

@ -89,12 +89,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
XPCOMUtils.defineLazyModuleGetter(this, "NetErrorHelper",
"resource://gre/modules/NetErrorHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Toast",
"resource://gre/modules/Toast.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PageActions",
"resource://gre/modules/PageActions.jsm");
// Lazily-loaded browser scripts:
[
["SelectHelper", "chrome://browser/content/SelectHelper.js"],
@ -367,7 +361,7 @@ var BrowserApp = {
Services.obs.addObserver(this, "sessionstore-state-purge-complete", false);
function showFullScreenWarning() {
Toast.show(Strings.browser.GetStringFromName("alertFullScreenToast"), Toast.SHORT);
NativeWindow.toast.show(Strings.browser.GetStringFromName("alertFullScreenToast"), "short");
}
window.addEventListener("fullscreen", function() {
@ -517,7 +511,7 @@ var BrowserApp = {
let newtabStrings = Strings.browser.GetStringFromName("newtabpopup.opened");
let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
Toast.show(label, Toast.LONG, {
NativeWindow.toast.show(label, "long", {
button: {
icon: "drawable://switch_button_icon",
label: buttonLabel,
@ -539,7 +533,7 @@ var BrowserApp = {
let newtabStrings = Strings.browser.GetStringFromName("newprivatetabpopup.opened");
let label = PluralForm.get(1, newtabStrings).replace("#1", 1);
let buttonLabel = Strings.browser.GetStringFromName("newtabpopup.switch");
Toast.show(label, Toast.LONG, {
NativeWindow.toast.show(label, "long", {
button: {
icon: "drawable://switch_button_icon",
label: buttonLabel,
@ -1052,7 +1046,7 @@ var BrowserApp = {
message = Strings.browser.GetStringFromName("undoCloseToast.messageDefault");
}
Toast.show(message, Toast.SHORT, {
NativeWindow.toast.show(message, "short", {
button: {
icon: "drawable://undo_button_icon",
label: Strings.browser.GetStringFromName("undoCloseToast.action2"),
@ -1850,12 +1844,16 @@ var NativeWindow = {
init: function() {
Services.obs.addObserver(this, "Menu:Clicked", false);
Services.obs.addObserver(this, "Doorhanger:Reply", false);
Services.obs.addObserver(this, "Toast:Click", false);
Services.obs.addObserver(this, "Toast:Hidden", false);
this.contextmenus.init();
},
uninit: function() {
Services.obs.removeObserver(this, "Menu:Clicked");
Services.obs.removeObserver(this, "Doorhanger:Reply");
Services.obs.removeObserver(this, "Toast:Click", false);
Services.obs.removeObserver(this, "Toast:Hidden", false);
this.contextmenus.uninit();
},
@ -1874,6 +1872,38 @@ var NativeWindow = {
});
},
toast: {
_callbacks: {},
show: function(aMessage, aDuration, aOptions) {
let msg = {
type: "Toast:Show",
message: aMessage,
duration: aDuration
};
if (aOptions && aOptions.button) {
msg.button = {
id: uuidgen.generateUUID().toString(),
};
// null is badly handled by the receiver, so try to avoid including nulls.
if (aOptions.button.label) {
msg.button.label = aOptions.button.label;
}
if (aOptions.button.icon) {
// If the caller specified a button, make sure we convert any chrome urls
// to jar:jar urls so that the frontend can show them
msg.button.icon = resolveGeckoURI(aOptions.button.icon);
};
this._callbacks[msg.button.id] = aOptions.button.callback;
}
sendMessageToJava(msg);
}
},
menu: {
_callbacks: [],
_menuId: 1,
@ -1975,6 +2005,14 @@ var NativeWindow = {
if (aTopic == "Menu:Clicked") {
if (this.menu._callbacks[aData])
this.menu._callbacks[aData]();
} else if (aTopic == "Toast:Click") {
if (this.toast._callbacks[aData]) {
this.toast._callbacks[aData]();
delete this.toast._callbacks[aData];
}
} else if (aTopic == "Toast:Hidden") {
if (this.toast._callbacks[aData])
delete this.toast._callbacks[aData];
} else if (aTopic == "Doorhanger:Reply") {
let data = JSON.parse(aData);
let reply_id = data["callback"];
@ -2674,10 +2712,12 @@ var NativeWindow = {
}
};
XPCOMUtils.defineLazyModuleGetter(this, "PageActions",
"resource://gre/modules/PageActions.jsm");
// These alias to the old, deprecated NativeWindow interfaces
[
["pageactions", "resource://gre/modules/PageActions.jsm", "PageActions"],
["toast", "resource://gre/modules/Toast.jsm", "Toast"],
["pageactions", "resource://gre/modules/PageActions.jsm", "PageActions"]
].forEach(item => {
let [name, script, exprt] = item;
@ -5993,7 +6033,7 @@ var XPInstallObserver = {
observe: function xpi_observer(aSubject, aTopic, aData) {
switch (aTopic) {
case "addon-install-started":
Toast.show(Strings.browser.GetStringFromName("alertAddonsDownloading"), Toast.SHORT);
NativeWindow.toast.show(Strings.browser.GetStringFromName("alertAddonsDownloading"), "short");
break;
case "addon-install-blocked":
let installInfo = aSubject.QueryInterface(Ci.amIWebInstallInfo);
@ -6078,13 +6118,13 @@ var XPInstallObserver = {
// Display completion message for new installs or updates not done Automatically
if (!aInstall.existingAddon || !AddonManager.shouldAutoUpdate(aInstall.existingAddon)) {
let message = Strings.browser.GetStringFromName("alertAddonsInstalledNoRestart");
Toast.show(message, Toast.SHORT);
NativeWindow.toast.show(message, "short");
}
}
},
onInstallFailed: function(aInstall) {
Toast.show(Strings.browser.GetStringFromName("alertAddonsFail"), Toast.SHORT);
NativeWindow.toast.show(Strings.browser.GetStringFromName("alertAddonsFail"), "short");
},
onDownloadProgress: function xpidm_onDownloadProgress(aInstall) {},
@ -6116,7 +6156,7 @@ var XPInstallObserver = {
msg = msg.replace("#3", Strings.brand.GetStringFromName("brandShortName"));
msg = msg.replace("#4", Services.appinfo.version);
Toast.show(msg, Toast.SHORT);
NativeWindow.toast.show(msg, "short");
},
showRestartPrompt: function() {
@ -7046,7 +7086,7 @@ var SearchEngines = {
Services.search.addEngine(engine.url, Ci.nsISearchEngine.DATA_XML, engine.iconURL, false, {
onSuccess: function() {
// Display a toast confirming addition of new search engine.
Toast.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [engine.title], 1), Toast.LONG);
NativeWindow.toast.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [engine.title], 1), "long");
},
onError: function(aCode) {
@ -7060,7 +7100,7 @@ var SearchEngines = {
errorMessage = "alertSearchEngineErrorToast";
}
Toast.show(Strings.browser.formatStringFromName(errorMessage, [engine.title], 1), Toast.LONG);
NativeWindow.toast.show(Strings.browser.formatStringFromName(errorMessage, [engine.title], 1), "long");
}
});
},
@ -7141,7 +7181,7 @@ var SearchEngines = {
name = title.value + " " + i;
Services.search.addEngineWithDetails(name, favicon, null, null, method, formURL);
Toast.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name], 1), Toast.LONG);
NativeWindow.toast.show(Strings.browser.formatStringFromName("alertSearchEngineAddedToast", [name], 1), "long");
let engine = Services.search.getEngineByName(name);
engine.wrappedJSObject._queryCharset = charset;
for (let i = 0; i < formData.length; ++i) {

View File

@ -8,9 +8,6 @@
let Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Toast",
"resource://gre/modules/Toast.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Notifications",
"resource://gre/modules/Notifications.jsm");
@ -261,11 +258,10 @@ AlertDownloadProgressListener.prototype = {
case Ci.nsIDownloadManager.DOWNLOAD_QUEUED: {
if (BrowserApp.isGuest) {
aDownload.cancel();
Toast.show(Strings.browser.GetStringFromName("downloads.disabledInGuest"), Toast.LONG);
NativeWindow.toast.show(Strings.browser.GetStringFromName("downloads.disabledInGuest"), "long");
return;
}
Toast.show(Strings.browser.GetStringFromName("alertDownloadsToast"), Toast.LONG);
NativeWindow.toast.show(Strings.browser.GetStringFromName("alertDownloadsToast"), "long");
Downloads.createNotification(aDownload, new DownloadNotifOptions(aDownload,
Strings.browser.GetStringFromName("alertDownloadsStart2"),
aDownload.displayName));

View File

@ -10,9 +10,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Messaging.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Toast",
"resource://gre/modules/Toast.jsm");
function ContentDispatchChooser() {}
ContentDispatchChooser.prototype =
@ -52,23 +49,26 @@ ContentDispatchChooser.prototype =
if (aHandler.possibleApplicationHandlers.length > 1) {
aHandler.launchWithURI(aURI, aWindowContext);
} else {
let bundle = Services.strings.createBundle("chrome://browser/locale/handling.properties");
let failedText = bundle.GetStringFromName("protocol.failed");
let searchText = bundle.GetStringFromName("protocol.toast.search");
let win = this._getChromeWin();
if (win && win.NativeWindow) {
let bundle = Services.strings.createBundle("chrome://browser/locale/handling.properties");
let failedText = bundle.GetStringFromName("protocol.failed");
let searchText = bundle.GetStringFromName("protocol.toast.search");
Toast.show(failedText, Toast.LONG, {
button: {
label: searchText,
callback: function() {
let message = {
type: "Intent:Open",
url: "market://search?q=" + aURI.scheme,
};
win.NativeWindow.toast.show(failedText, "long", {
button: {
label: searchText,
callback: function() {
let message = {
type: "Intent:Open",
url: "market://search?q=" + aURI.scheme,
};
sendMessageToJava(message);
sendMessageToJava(message);
}
}
}
});
});
}
}
},
};

View File

@ -1,62 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Messaging.jsm");
this.EXPORTED_SYMBOLS = ["Toast"];
// Copied from browser.js
// TODO: We should move this method to a common importable location
function resolveGeckoURI(uri) {
if (!uri)
throw "Can't resolve an empty uri";
if (uri.startsWith("chrome://")) {
let registry = Cc['@mozilla.org/chrome/chrome-registry;1'].getService(Ci["nsIChromeRegistry"]);
return registry.convertChromeURL(Services.io.newURI(uri, null, null)).spec;
} else if (uri.startsWith("resource://")) {
let handler = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
return handler.resolveURI(Services.io.newURI(uri, null, null));
}
return uri;
}
var Toast = {
LONG: "long",
SHORT: "short",
show: function(message, duration, options) {
let msg = {
type: "Toast:Show",
message: message,
duration: duration
};
let callback;
if (options && options.button) {
msg.button = { };
// null is badly handled by the receiver, so try to avoid including nulls.
if (options.button.label) {
msg.button.label = options.button.label;
}
if (options.button.icon) {
// If the caller specified a button, make sure we convert any chrome urls
// to jar:jar urls so that the frontend can show them
msg.button.icon = resolveGeckoURI(options.button.icon);
};
callback = options.button.callback;
}
sendMessageToJava(msg, callback);
}
}

View File

@ -27,7 +27,6 @@ EXTRA_JS_MODULES += [
'SimpleServiceDiscovery.jsm',
'SSLExceptions.jsm',
'TabMirror.jsm',
'Toast.jsm',
'WebappManagerWorker.js',
]