Bug 697309 - Add support for the Open Web Apps API - part 1 : UI glue r=fabrice

This commit is contained in:
Mark Finkle 2012-03-27 17:44:25 -04:00
parent 49f76cfb3b
commit 86100c2891
8 changed files with 76 additions and 12 deletions

View File

@ -236,6 +236,7 @@ var BrowserApp = {
CharacterEncoding.init();
SearchEngines.init();
ActivityObserver.init();
WebappsUI.init();
// Init LoginManager
Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
@ -415,6 +416,7 @@ var BrowserApp = {
ConsoleAPI.uninit();
CharacterEncoding.uninit();
SearchEngines.uninit();
WebappsUI.uninit();
},
// This function returns false during periods where the browser displayed document is

View File

@ -9,6 +9,7 @@
<script type="application/javascript" src="chrome://browser/content/downloads.js"/>
<script type="application/javascript" src="chrome://browser/content/exceptions.js"/>
<script type="application/javascript" src="chrome://browser/content/sanitize.js"/>
<script type="application/javascript" src="chrome://browser/content/webapps.js"/>
<deck id="browsers" flex="1"/>

View File

@ -0,0 +1,65 @@
/* ***** BEGIN LICENSE BLOCK *****
*
* 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/.
*
* ***** END LICENSE BLOCK ***** */
Cu.import("resource://gre/modules/Webapps.jsm");
let WebappsUI = {
init: function() {
Services.obs.addObserver(this, "webapps-ask-install", false);
Services.obs.addObserver(this, "webapps-launch", false);
},
uninit: function() {
Services.obs.removeObserver(this, "webapps-ask-install");
Services.obs.removeObserver(this, "webapps-launch");
},
observe: function(aSubject, aTopic, aData) {
let data = JSON.parse(aData);
switch (aTopic) {
case "webapps-ask-install":
this.doInstall(data);
break;
case "webapps-launch":
DOMApplicationRegistry.getManifestFor(data.origin, (function(aManifest) {
if (!aManifest)
return;
let manifest = new DOMApplicationManifest(aManifest, data.origin);
this.openURL(manifest.fullLaunchPath(), data.origin);
}).bind(this));
break;
}
},
doInstall: function(aData) {
let manifest = new DOMApplicationManifest(aData.app.manifest, aData.app.origin);
let checkbox = { value: false };
let name = manifest.name ? manifest.name : manifest.fullLaunchPath();
if (Services.prompt.confirm(null, Strings.browser.GetStringFromName("webapps.installTitle"), name))
DOMApplicationRegistry.confirmInstall(aData);
},
openURL: function(aURI, aOrigin) {
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
let tabs = BrowserApp.tabs;
let tab = null;
for (let i = 0; i < tabs.length; i++) {
let appOrigin = ss.getTabValue(tabs[i], "appOrigin");
if (appOrigin == aOrigin)
tab = tabs[i];
}
if (tab) {
BrowserApp.selectTab(tab);
} else {
tab = BrowserApp.addTab(aURI);
ss.setTabValue(tab, "appOrigin", aOrigin);
}
}
}

View File

@ -26,7 +26,8 @@ chrome.jar:
* content/downloads.js (content/downloads.js)
content/netError.xhtml (content/netError.xhtml)
content/SelectHelper.js (content/SelectHelper.js)
content/webapps.js (content/webapps.js)
% override chrome://global/content/config.xul chrome://browser/content/config.xhtml
% override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
% override chrome://mozapps/content/extensions/extensions.xul chrome://browser/content/aboutAddons.xhtml

View File

@ -150,6 +150,7 @@
@BINPATH@/components/directory.xpt
@BINPATH@/components/docshell.xpt
@BINPATH@/components/dom.xpt
@BINPATH@/components/dom_apps.xpt
@BINPATH@/components/dom_base.xpt
@BINPATH@/components/dom_battery.xpt
@BINPATH@/components/dom_canvas.xpt
@ -284,7 +285,6 @@
@BINPATH@/components/xuldoc.xpt
@BINPATH@/components/xultmpl.xpt
@BINPATH@/components/zipwriter.xpt
@BINPATH@/components/openwebapps.xpt
; JavaScript components
@BINPATH@/components/ConsoleAPI.manifest
@ -338,7 +338,6 @@
@BINPATH@/components/amContentHandler.js
@BINPATH@/components/amWebInstallListener.js
@BINPATH@/components/nsBlocklistService.js
@BINPATH@/components/OpenWebapps.manifest
#ifdef MOZ_UPDATER
@BINPATH@/components/nsUpdateService.manifest
@ -411,6 +410,8 @@
#endif
@BINPATH@/components/TelemetryPing.js
@BINPATH@/components/TelemetryPing.manifest
@BINPATH@/components/Webapps.js
@BINPATH@/components/Webapps.manifest
; Modules
@BINPATH@/modules/*
@ -613,7 +614,6 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
@BINPATH@/components/PromptService.js
@BINPATH@/components/SessionStore.js
@BINPATH@/components/Sidebar.js
@BINPATH@/components/OpenWebapps.js
#ifdef MOZ_SAFE_BROWSING
@BINPATH@/components/SafeBrowsing.js
#endif

View File

@ -225,6 +225,9 @@ timer.start=%S: timer started
# %1$S=name of timer, %2$S=number of milliseconds
timer.end=%1$S: %2$Sms
#Webapps
webapps.installTitle=Install Application
# Click to play plugins
clickToPlayPlugins.message1=%S contains plugin content. Would you like to play it?
clickToPlayPlugins.yes=Yes

View File

@ -1,7 +0,0 @@
<!ENTITY webapps.title.placeholder "Enter a title">
<!ENTITY webapps.permissions "Allow access:">
<!ENTITY webapps.perm.geolocation "Location-aware browsing">
<!ENTITY webapps.perm.offline "Offline data storage">
<!ENTITY webapps.perm.notifications "Desktop notifications">
<!ENTITY webapps.perm.requestedHint "(requested)">
<!ENTITY webapps.add-homescreen "Add to home screen">

View File

@ -16,6 +16,5 @@
locale/@AB_CD@/browser/sync.dtd (%chrome/sync.dtd)
locale/@AB_CD@/browser/sync.properties (%chrome/sync.properties)
locale/@AB_CD@/browser/prompt.dtd (%chrome/prompt.dtd)
locale/@AB_CD@/browser/webapps.dtd (%chrome/webapps.dtd)
locale/@AB_CD@/browser/feedback.dtd (%chrome/feedback.dtd)
locale/@AB_CD@/browser/phishing.dtd (%chrome/phishing.dtd)