Backout 977ee9208065, a405768bd32a, 69a1fb2ddca3, 58d5f1d1443e for Moth orange.

This commit is contained in:
Ms2ger 2012-07-14 11:38:56 +02:00
parent 0aa26e90d2
commit 219c32d8fb
17 changed files with 37 additions and 260 deletions

View File

@ -357,7 +357,6 @@ webapps.install = Install
webapps.install.accesskey = I
#LOCALIZATION NOTE (webapps.requestInstall) %1$S is the web app name, %2$S is the site from which the web app is installed
webapps.requestInstall = Do you want to install "%1$S" from this site (%2$S)?
webapps.install.success = Application Installed
# Telemetry opt-out prompt for Aurora and Nightly
# LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by

View File

@ -29,12 +29,10 @@ let webappsUI = {
switch(aTopic) {
case "webapps-ask-install":
let win = this._getWindowForId(data.oid);
if (win && win.location.href == data.from) {
this.doInstall(data, win);
}
let [chromeWin, browser] = this._getBrowserForId(data.oid);
if (chromeWin)
this.doInstall(data, browser, chromeWin);
break;
case "webapps-launch":
DOMApplicationRegistry.getManifestFor(data.origin, (function(aManifest) {
if (!aManifest)
@ -85,14 +83,27 @@ let webappsUI = {
}
},
doInstall: function(aData, aWindow) {
let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
_getBrowserForId: function(aId) {
let someWindow = Services.wm.getMostRecentWindow(null);
let chromeWin = browser.ownerDocument.defaultView;
let bundle = chromeWin.gNavigatorBundle;
if (someWindow) {
let windowUtils = someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let content = windowUtils.getOuterWindowWithId(aId);
if (content) {
let browser = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell).chromeEventHandler;
let win = browser.ownerDocument.defaultView;
return [win, browser];
}
}
return [null, null];
},
doInstall: function(aData, aBrowser, aWindow) {
let bundle = aWindow.gNavigatorBundle;
let mainAction = {
label: bundle.getString("webapps.install"),
@ -106,14 +117,13 @@ let webappsUI = {
}
DOMApplicationRegistry.confirmInstall(aData, false, localDir);
installationSuccessNotification(app, chromeWin);
} else {
DOMApplicationRegistry.denyInstall(aData);
}
}
};
let requestingURI = chromeWin.makeURI(aData.from);
let requestingURI = aWindow.makeURI(aData.from);
let manifest = new DOMApplicationManifest(aData.app.manifest, aData.app.origin);
let host;
@ -124,35 +134,10 @@ let webappsUI = {
}
let message = bundle.getFormattedString("webapps.requestInstall",
[manifest.name, host]);
[manifest.name, host], 2);
chromeWin.PopupNotifications.show(browser, "webapps-install", message,
"webapps-notification-icon", mainAction);
},
aWindow.PopupNotifications.show(aBrowser, "webapps-install", message,
"webapps-notification-icon", mainAction);
_getWindowForId: function(aId) {
let someWindow = Services.wm.getMostRecentWindow(null);
return someWindow &&
someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.getOuterWindowWithId(aId);
}
}
function installationSuccessNotification(app, aWindow) {
let bundle = aWindow.gNavigatorBundle;
if (("@mozilla.org/alerts-service;1" in Cc)) {
let notifier;
try {
notifier = Cc["@mozilla.org/alerts-service;1"].
getService(Ci.nsIAlertsService);
notifier.showAlertNotification(app.iconURI.spec,
bundle.getString("webapps.install.success"),
app.appNameAsFilename,
false, null, null);
} catch (ex) {}
}
}

View File

@ -14,7 +14,6 @@ let EXPORTED_SYMBOLS = ["DOMApplicationRegistry", "DOMApplicationManifest"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/WebappOSUtils.jsm");
const WEBAPP_RUNTIME = Services.appinfo.ID == "webapprt@mozilla.org";
@ -172,7 +171,7 @@ let DOMApplicationRegistry = {
this.uninstall(msg);
break;
case "Webapps:Launch":
WebappOSUtils.launch(msg);
Services.obs.notifyObservers(this, "webapps-launch", JSON.stringify(msg));
break;
case "Webapps:GetInstalled":
this.getInstalled(msg);

View File

@ -16,7 +16,6 @@ DIRS = \
MOCHITEST_CHROME_FILES = \
test_bug_765063.xul \
test_bug_771294.xul \
test_install_app.xul \
test_list_api.xul \
test_install_errors.xul \

View File

@ -12,7 +12,6 @@ include $(DEPTH)/config/autoconf.mk
MOCHITEST_CHROME_FILES = \
bug_765063.xul \
bug_771294.xul \
include.html \
wild_crazy.webapp \
wild_crazy.webapp^headers^ \

View File

@ -6,6 +6,6 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
navigator.mozApps.install("http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp", null);
history.pushState({}, "", "modified-url");
document.location = "about:blank";
</script>
</window>

View File

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
navigator.mozApps.install("http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp", null);
window.location = "about:blank";
</script>
</window>

View File

@ -18,22 +18,19 @@
<script>
SimpleTest.waitForExplicitFinish();
var mmListener = {
receiveMessage: function(aMessage) {
ppmm.removeMessageListener("Webapps:Install", mmListener);
var msg = aMessage.json;
is(msg.from.indexOf("modified-url"), -1, "the install origin didn't change");
// Observe app installation and confirm that the install origin didn't change.
var observer = {
observe: function observe(subject, topic, data) {
Services.obs.removeObserver(observer, "webapps-sync-install");
ok(JSON.parse(data).installOrigin == "http://www.example.com",
"the install origin didn't change");
tearDown();
SimpleTest.finish();
}
};
var ppmm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Components.interfaces.nsIFrameMessageManager);
ppmm.addMessageListener("Webapps:Install", mmListener);
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(observer, "webapps-sync-install", false);
</script>
<!-- Load a page that initiates an app installation and then immediately

View File

@ -1,53 +0,0 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Bug 771294">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="apphelper.js"/>
<script type="application/javascript" src="jshelper.js"/>
<script>
SimpleTest.waitForExplicitFinish();
Components.utils.import('resource://gre/modules/Services.jsm');
var blocked = true;
Services.obs.addObserver(
function observeShowing() {
Services.obs.removeObserver(observeShowing, "PopupNotifications-showing");
blocked = false;
},
"PopupNotifications-showing",
false
);
Services.obs.addObserver(
function observeInstalling() {
Services.obs.removeObserver(observeInstalling, "webapps-ask-install");
// Spin the event loop before running the test to give the registry time
// to process the install request and (hopefully not) show the doorhanger.
setTimeout(function verify() {
ok(blocked, "Install panel was blocked after immediate redirect");
tearDown();
SimpleTest.finish();
}, 0);
},
"webapps-ask-install",
false
);
</script>
<!-- Load a page that initiates an app installation and then immediately
- redirects to a page at a different origin. We can't do this directly
- inside this test page, because that would cause the test to hang. -->
<iframe src="http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/bug_771294.xul"/>
</window>

View File

@ -24,7 +24,6 @@ PARALLEL_DIRS = \
obsolete \
profile \
themes \
webapps \
$(NULL)
DIRS += \

View File

@ -241,9 +241,6 @@ PopupNotifications.prototype = {
let notifications = this._getNotificationsForBrowser(browser);
notifications.push(notification);
// Notify observers that we're showing the popup (useful for testing)
this._notify("showing");
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (browser == this.tabbrowser.selectedBrowser && fm.activeWindow == this.window) {
// show panel now

View File

@ -27,11 +27,6 @@
min-width: 46px;
}
#alertImage {
max-width: 48px;
max-height: 48px;
}
.alertTitle {
font-weight: bold;
}

View File

@ -32,11 +32,6 @@
font-weight: bold;
}
#alertImage {
max-width: 48px;
max-height: 48px;
}
.alertText {
-moz-margin-end: 6px;
}

View File

@ -1,18 +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/.
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
EXTRA_PP_JS_MODULES = \
WebappOSUtils.jsm \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,81 +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/. */
const Cc = Components.classes;
const Ci = Components.interfaces;
const CC = Components.Constructor;
let EXPORTED_SYMBOLS = ["WebappOSUtils"];
let WebappOSUtils = {
launch: function(aData) {
#ifdef XP_WIN
let appRegKey;
try {
let open = CC("@mozilla.org/windows-registry-key;1",
"nsIWindowsRegKey", "open");
let initWithPath = CC("@mozilla.org/file/local;1",
"nsILocalFile", "initWithPath");
let initProcess = CC("@mozilla.org/process/util;1",
"nsIProcess", "init");
appRegKey = open(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\",
aData.origin, Ci.nsIWindowsRegKey.ACCESS_READ);
let launchTarget = initWithPath(appRegKey.readStringValue("InstallLocation"));
launchTarget.append(appRegKey.readStringValue("AppFilename") + ".exe");
let process = initProcess(launchTarget);
process.runwAsync([], 0);
} catch (e) {
return false;
} finally {
if (appRegKey) {
appRegKey.close();
}
}
return true;
#elifdef XP_MACOSX
let mwaUtils = Cc["@mozilla.org/widget/mac-web-app-utils;1"]
.createInstance(Ci.nsIMacWebAppUtils);
let appPath;
try {
appPath = mwaUtils.pathForAppWithIdentifier(aData.origin);
} catch (e) {}
if (appPath) {
mwaUtils.launchAppWithIdentifier(aData.origin);
return true;
}
return false;
#elifdef XP_UNIX
let origin = Services.io.newURI(aData.origin, null, null);
let installDir = "." + origin.scheme + ";" + origin.host;
if (origin.port != -1)
installDir += ";" + origin.port;
let exeFile = Services.dirsvc.get("Home", Ci.nsIFile);
exeFile.append(installDir);
exeFile.append("webapprt-stub");
try {
if (exeFile.exists()) {
let process = Cc["@mozilla.org/process/util;1"]
.createInstance(Ci.nsIProcess);
process.init(exeFile);
process.runAsync([], 0);
return true;
}
} catch (e) {}
return false;
#else
Services.obs.notifyObservers(this, "webapps-launch", JSON.stringify(aData));
return true;
#endif
}
}

View File

@ -37,22 +37,3 @@ NS_IMETHODIMP nsMacWebAppUtils::PathForAppWithIdentifier(const nsAString& bundle
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP nsMacWebAppUtils::LaunchAppWithIdentifier(const nsAString& bundleIdentifier) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
// Note this might return false, meaning the app wasnt launched for some reason.
BOOL success = [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:
[NSString stringWithCharacters:((nsString)bundleIdentifier).get() length:((nsString)bundleIdentifier).Length()]
options: nil
additionalEventParamDescriptor: nil
launchIdentifier: NULL];
[ap release];
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}

View File

@ -17,9 +17,4 @@ interface nsIMacWebAppUtils : nsISupports {
*/
AString pathForAppWithIdentifier(in AString bundleIdentifier);
/**
* Launch the app with the given identifier, if it exists.
*/
void launchAppWithIdentifier(in AString bundleIdentifier);
};