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 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 #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.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 # Telemetry opt-out prompt for Aurora and Nightly
# LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by # LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by

View File

@ -29,12 +29,10 @@ let webappsUI = {
switch(aTopic) { switch(aTopic) {
case "webapps-ask-install": case "webapps-ask-install":
let win = this._getWindowForId(data.oid); let [chromeWin, browser] = this._getBrowserForId(data.oid);
if (win && win.location.href == data.from) { if (chromeWin)
this.doInstall(data, win); this.doInstall(data, browser, chromeWin);
}
break; break;
case "webapps-launch": case "webapps-launch":
DOMApplicationRegistry.getManifestFor(data.origin, (function(aManifest) { DOMApplicationRegistry.getManifestFor(data.origin, (function(aManifest) {
if (!aManifest) if (!aManifest)
@ -85,14 +83,27 @@ let webappsUI = {
} }
}, },
doInstall: function(aData, aWindow) { _getBrowserForId: function(aId) {
let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) let someWindow = Services.wm.getMostRecentWindow(null);
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
let chromeWin = browser.ownerDocument.defaultView; if (someWindow) {
let bundle = chromeWin.gNavigatorBundle; 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 = { let mainAction = {
label: bundle.getString("webapps.install"), label: bundle.getString("webapps.install"),
@ -106,14 +117,13 @@ let webappsUI = {
} }
DOMApplicationRegistry.confirmInstall(aData, false, localDir); DOMApplicationRegistry.confirmInstall(aData, false, localDir);
installationSuccessNotification(app, chromeWin);
} else { } else {
DOMApplicationRegistry.denyInstall(aData); 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 manifest = new DOMApplicationManifest(aData.app.manifest, aData.app.origin);
let host; let host;
@ -124,35 +134,10 @@ let webappsUI = {
} }
let message = bundle.getFormattedString("webapps.requestInstall", let message = bundle.getFormattedString("webapps.requestInstall",
[manifest.name, host]); [manifest.name, host], 2);
chromeWin.PopupNotifications.show(browser, "webapps-install", message, aWindow.PopupNotifications.show(aBrowser, "webapps-install", message,
"webapps-notification-icon", mainAction); "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/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/WebappOSUtils.jsm");
const WEBAPP_RUNTIME = Services.appinfo.ID == "webapprt@mozilla.org"; const WEBAPP_RUNTIME = Services.appinfo.ID == "webapprt@mozilla.org";
@ -172,7 +171,7 @@ let DOMApplicationRegistry = {
this.uninstall(msg); this.uninstall(msg);
break; break;
case "Webapps:Launch": case "Webapps:Launch":
WebappOSUtils.launch(msg); Services.obs.notifyObservers(this, "webapps-launch", JSON.stringify(msg));
break; break;
case "Webapps:GetInstalled": case "Webapps:GetInstalled":
this.getInstalled(msg); this.getInstalled(msg);

View File

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

View File

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

View File

@ -6,6 +6,6 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script> <script>
navigator.mozApps.install("http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp", null); 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> </script>
</window> </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> <script>
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var mmListener = { // Observe app installation and confirm that the install origin didn't change.
receiveMessage: function(aMessage) { var observer = {
ppmm.removeMessageListener("Webapps:Install", mmListener); observe: function observe(subject, topic, data) {
Services.obs.removeObserver(observer, "webapps-sync-install");
var msg = aMessage.json; ok(JSON.parse(data).installOrigin == "http://www.example.com",
is(msg.from.indexOf("modified-url"), -1, "the install origin didn't change"); "the install origin didn't change");
tearDown(); tearDown();
SimpleTest.finish(); SimpleTest.finish();
} }
}; };
var ppmm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"] Components.utils.import("resource://gre/modules/Services.jsm");
.getService(Components.interfaces.nsIFrameMessageManager); Services.obs.addObserver(observer, "webapps-sync-install", false);
ppmm.addMessageListener("Webapps:Install", mmListener);
</script> </script>
<!-- Load a page that initiates an app installation and then immediately <!-- 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 \ obsolete \
profile \ profile \
themes \ themes \
webapps \
$(NULL) $(NULL)
DIRS += \ DIRS += \

View File

@ -241,9 +241,6 @@ PopupNotifications.prototype = {
let notifications = this._getNotificationsForBrowser(browser); let notifications = this._getNotificationsForBrowser(browser);
notifications.push(notification); 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); let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (browser == this.tabbrowser.selectedBrowser && fm.activeWindow == this.window) { if (browser == this.tabbrowser.selectedBrowser && fm.activeWindow == this.window) {
// show panel now // show panel now

View File

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

View File

@ -32,11 +32,6 @@
font-weight: bold; font-weight: bold;
} }
#alertImage {
max-width: 48px;
max-height: 48px;
}
.alertText { .alertText {
-moz-margin-end: 6px; -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_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); AString pathForAppWithIdentifier(in AString bundleIdentifier);
/**
* Launch the app with the given identifier, if it exists.
*/
void launchAppWithIdentifier(in AString bundleIdentifier);
}; };