forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 819037 - Set appId on browsers in webapps. r=mfinkle
- Loading branch information
Wes Johnston
committed
Jan 22, 2013
1 parent
032b66d
commit 6acda0f
Showing
4 changed files
with
84 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ let Cu = Components.utils; | |
Cu.import("resource://gre/modules/Services.jsm"); | ||
Cu.import("resource://gre/modules/FileUtils.jsm"); | ||
Cu.import("resource://gre/modules/NetUtil.jsm"); | ||
Cu.import("resource://gre/modules/commonjs/promise/core.js"); | ||
|
||
function pref(name, value) { | ||
return { | ||
|
@@ -16,7 +17,7 @@ function pref(name, value) { | |
} | ||
} | ||
|
||
var WebAppRT = { | ||
let WebAppRT = { | ||
DEFAULT_PREFS_FILENAME: "default-prefs.js", | ||
|
||
prefs: [ | ||
|
@@ -52,6 +53,56 @@ var WebAppRT = { | |
blocklist = blocklist.replace(/%APP_ID%/g, "[email protected]"); | ||
Services.prefs.setCharPref("extensions.blocklist.url", blocklist); | ||
} | ||
|
||
return this.findManifestUrlFor(url); | ||
}, | ||
|
||
findManifestUrlFor: function(aUrl) { | ||
let deferred = Promise.defer(); | ||
let request = navigator.mozApps.mgmt.getAll(); | ||
request.onsuccess = function() { | ||
let apps = request.result; | ||
for (let i = 0; i < apps.length; i++) { | ||
let app = apps[i]; | ||
let manifest = new ManifestHelper(app.manifest, app.origin); | ||
|
||
// First see if this url matches any manifests we have registered | ||
// If so, get the launchUrl from the manifest and we'll launch with that | ||
//let app = DOMApplicationRegistry.getAppByManifestURL(aUrl); | ||
if (app.manifestURL == aUrl) { | ||
BrowserApp.manifestUrl = aUrl; | ||
deferred.resolve(manifest.fullLaunchPath()); | ||
return; | ||
} | ||
|
||
// Otherwise, see if the apps launch path is this url | ||
if (manifest.fullLaunchPath() == aUrl) { | ||
// remove the old shortuct | ||
sendMessageToJava({ | ||
gecko: { | ||
type: "Shortcut:Remove", | ||
title: manifest.name, | ||
url: manifest.fullLaunchPath(), | ||
origin: app.origin, | ||
shortcutType: "webapp" | ||
} | ||
}); | ||
WebappsUI.createShortcut(manifest.name, manifest.fullLaunchPath(), | ||
WebappsUI.getBiggestIcon(manifest.icons, app.origin), "webapp"); | ||
|
||
BrowserApp.manifestUrl = app.manifestURL; | ||
deferred.resolve(aUrl); | ||
return; | ||
} | ||
} | ||
deferred.reject(""); | ||
}; | ||
|
||
request.onerror = function() { | ||
deferred.reject(""); | ||
}; | ||
|
||
return deferred.promise; | ||
}, | ||
|
||
getDefaultPrefs: function() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters