Bug 742761 - Remove some warnings in b2g/. r=fabrice
authorVivien Nicolas <21@vingtetun.org>
Wed, 11 Apr 2012 10:05:35 -0700
changeset 94756 8a0213203d8dce758d1a60f42c74096de0a7a9ba
parent 94755 03cb4bb5662190ae9b2a8e73b638ad5405997e47
child 94757 41b018c6b752c98529c21f30f9c4a92016703a8a
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs742761
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 742761 - Remove some warnings in b2g/. r=fabrice
b2g/chrome/content/shell.js
b2g/chrome/content/shell.xul
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -25,18 +25,24 @@ XPCOMUtils.defineLazyGetter(Services, 's
 });
 
 XPCOMUtils.defineLazyGetter(Services, 'idle', function() {
   return Cc['@mozilla.org/widget/idleservice;1']
            .getService(Ci.nsIIdleService);
 });
 
 XPCOMUtils.defineLazyGetter(Services, 'audioManager', function() {
+#ifdef MOZ_WIDGET_GONK
   return Cc['@mozilla.org/telephony/audiomanager;1']
            .getService(Ci.nsIAudioManager);
+#else
+  return {
+    "masterVolume": 0
+  };
+#endif
 });
 
 XPCOMUtils.defineLazyServiceGetter(Services, 'fm', function() {
   return Cc['@mozilla.org/focus-manager;1']
            .getService(Ci.nsFocusManager);
 });
 
 // FIXME Bug 707625
@@ -74,40 +80,39 @@ var shell = {
       let homeSrc = Services.env.get('B2G_HOMESCREEN');
       if (homeSrc)
         return homeSrc;
     } catch (e) {}
 
     return Services.prefs.getCharPref('browser.homescreenURL');
   },
 
-  start: function shell_init() {
+  start: function shell_start() {
     let homeURL = this.homeURL;
     if (!homeURL) {
       let msg = 'Fatal error during startup: No homescreen found: try setting B2G_HOMESCREEN';
-      return alert(msg);
+      alert(msg);
+      return;
     }
 
     ['keydown', 'keypress', 'keyup'].forEach((function listenKey(type) {
       window.addEventListener(type, this, false, true);
       window.addEventListener(type, this, true, true);
     }).bind(this));
 
     window.addEventListener('MozApplicationManifest', this);
     window.addEventListener('mozfullscreenchange', this);
     window.addEventListener('sizemodechange', this);
     this.contentBrowser.addEventListener('load', this, true);
 
     // Until the volume can be set from the content side, set it to a
     // a specific value when the device starts. This way the front-end
     // can display a notification when the volume change and show a volume
     // level modified from this point.
-    try {
-      Services.audioManager.masterVolume = 0.5;
-    } catch(e) {}
+    Services.audioManager.masterVolume = 0.5;
 
     let domains = "";
     try {
       domains = Services.prefs.getCharPref('b2g.privileged.domains');
     } catch(e) {}
 
     addPermissions(domains.split(","));
 
@@ -292,47 +297,54 @@ var shell = {
   let power = navigator.mozPower;
   let idleHandler = function idleHandler(subject, topic, time) {
     if (topic === "idle") {
       if (power.getWakeLockState("screen") != "locked-foreground") {
         navigator.mozPower.screenEnabled = false;
       }
     }
   }
+
   let wakeLockHandler = function wakeLockHandler(topic, state) {
     // Turn off the screen when no one needs the it or all of them are
     // invisible, otherwise turn the screen on. Note that the CPU
     // might go to sleep as soon as the screen is turned off and
     // acquiring wake lock will not bring it back (actually the code
     // is not executed at all).
     if (topic == "screen") {
       if (state != "locked-foreground") {
         if (Services.idle.idleTime > idleTimeout*1000) {
           navigator.mozPower.screenEnabled = false;
         }
       } else {
         navigator.mozPower.screenEnabled = true;
       }
     }
   }
+
   let idleTimeout = Services.prefs.getIntPref("power.screen.timeout");
+  if (!('mozSettings' in navigator))
+    return;
+
   let request = navigator.mozSettings.getLock().get("power.screen.timeout");
   request.onsuccess = function onSuccess() {
     idleTimeout = request.result["power.screen.timeout"] || idleTimeout;
     if (idleTimeout) {
       Services.idle.addIdleObserver(idleHandler, idleTimeout);
       power.addWakeLockListener(wakeLockHandler);
     }
-  }
+  };
+
   request.onerror = function onError() {
     if (idleTimeout) {
       Services.idle.addIdleObserver(idleHandler, idleTimeout);
       power.addWakeLockListener(wakeLockHandler);
     }
-  }
+  };
+
   // XXX We may override other's callback here, but this is the only
   // user of mozSettings in shell.js at this moment.
   navigator.mozSettings.onsettingchange = function onSettingChange(e) {
     if (e.settingName == "power.screen.timeout" && e.settingValue) {
       Services.idle.removeIdleObserver(idleHandler, idleTimeout);
       idleTimeout = e.settingValue;
       Services.idle.addIdleObserver(idleHandler, idleTimeout);
     }
--- a/b2g/chrome/content/shell.xul
+++ b/b2g/chrome/content/shell.xul
@@ -14,19 +14,16 @@
         style="background: black; overflow: hidden;"
         onload="shell.start();"
         onunload="shell.stop();">
 
   <script type="application/javascript" src="chrome://browser/content/shell.js"/>
 #ifndef MOZ_TOUCH
   <script type="application/javascript" src="chrome://browser/content/touch.js"/>
 #endif
-#ifndef MOZ_WIDGET_GONK
-  <script type="application/javascript" src="chrome://browser/content/httpd.js"/>
-#endif
 
   <browser id="homescreen"
            type="content-primary"
            flex="1"
            style="overflow: hidden;"
-           src="data:text/html,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/>
+           src="data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;'>"/>
 </window>