Permalink
Browse files

don't install app mgmt handlers on desktop

  • Loading branch information...
1 parent d9fbf89 commit 9e0070546268f1ffeef9812f406773607a877190 @andreasgal andreasgal committed Mar 29, 2012
Showing with 18 additions and 14 deletions.
  1. +18 −14 apps/homescreen/js/homescreen.js
@@ -1067,23 +1067,27 @@ function AppScreen() {
}
});
- // Listen for app installations and rebuild the appscreen when we get one
- navigator.mozApps.mgmt.oninstall = function(event) {
- var newapp = event.application;
- appscreen.installedApps[newapp.origin] = newapp;
- appscreen.build(true);
- };
-
- // Do the same for uninstalls
- navigator.mozApps.mgmt.onuninstall = function(event) {
- var newapp = event.application;
- delete appscreen.installedApps[newapp.origin];
- appscreen.build(true);
- };
-
window.addEventListener('resize', function() {
appscreen.grid.update();
});
+
+ // Installing these handlers on desktop causes JS execution to stop silently,
+ // so work around that for now here.
+ if (navigator.userAgent.indexOf('Mobile') != -1) {
+ // Listen for app installations and rebuild the appscreen when we get one
+ navigator.mozApps.mgmt.oninstall = function(event) {
+ var newapp = event.application;
+ appscreen.installedApps[newapp.origin] = newapp;
+ appscreen.build(true);
+ };
+
+ // Do the same for uninstalls
+ navigator.mozApps.mgmt.onuninstall = function(event) {
+ var newapp = event.application;
+ delete appscreen.installedApps[newapp.origin];
+ appscreen.build(true);
+ };
+ }
}
// Look up the app object for a specified app origin

0 comments on commit 9e00705

Please sign in to comment.