Bug 836448 - Make browser-data-submission-info-bar.js not pollute the global window scope. r=gavin
authorDão Gottwald <dao@mozilla.com>
Wed, 30 Jan 2013 21:56:49 +0100
changeset 120401 885f8166c008f0be0fe86ef2586e2c6211ff18a4
parent 120400 78ecce4ba21467747c77bb7293f3a071c44ad5d0
child 120402 30a252389a7883a0302bd32d78ed787f04ba6f6b
push id24251
push userryanvm@gmail.com
push dateThu, 31 Jan 2013 20:56:22 +0000
treeherdermozilla-central@683b08dc1afd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs836448
milestone21.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 836448 - Make browser-data-submission-info-bar.js not pollute the global window scope. r=gavin
browser/base/content/browser-data-submission-info-bar.js
browser/base/content/browser.js
--- a/browser/base/content/browser-data-submission-info-bar.js
+++ b/browser/base/content/browser-data-submission-info-bar.js
@@ -1,34 +1,31 @@
-/* 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/. */
-
-"use strict";
-
-Cu.import("resource://services-common/log4moz.js");
+# 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/.
 
 /**
  * Represents an info bar that shows a data submission notification.
  */
-function DataNotificationInfoBar() {
-  let log4moz = Cu.import("resource://services-common/log4moz.js", {}).Log4Moz;
-  this._log = log4moz.repository.getLogger("Services.DataReporting.InfoBar");
-
-  this._notificationBox = null;
-}
-
-DataNotificationInfoBar.prototype = {
+let gDataNotificationInfoBar = {
   _OBSERVERS: [
     "datareporting:notify-data-policy:request",
     "datareporting:notify-data-policy:close",
   ],
 
   _DATA_REPORTING_NOTIFICATION: "data-reporting",
 
+  _notificationBox: null,
+
+  get _log() {
+    let log4moz = Cu.import("resource://services-common/log4moz.js", {}).Log4Moz;
+    delete this._log;
+    return this._log = log4moz.repository.getLogger("Services.DataReporting.InfoBar");
+  },
+
   init: function() {
     window.addEventListener("unload", function onUnload() {
       window.removeEventListener("unload", onUnload, false);
 
       for (let o of this._OBSERVERS) {
         Services.obs.removeObserver(this, o);
       }
     }.bind(this), false);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -154,18 +154,16 @@ let gInitialPages = [
 #include browser-social.js
 #include browser-tabPreviews.js
 #include browser-tabview.js
 #include browser-thumbnails.js
 #include browser-webrtcUI.js
 
 #ifdef MOZ_DATA_REPORTING
 #include browser-data-submission-info-bar.js
-
-let gDataNotificationInfoBar = new DataNotificationInfoBar();
 #endif
 
 #ifdef MOZ_SERVICES_SYNC
 #include browser-syncui.js
 #endif
 
 XPCOMUtils.defineLazyGetter(this, "Win7Features", function () {
 #ifdef XP_WIN