Bug 916166 - [app manager] Disable the network monitor. r=ochameau, a=lsblakk
authorPaul Rouget <paul@mozilla.com>
Tue, 17 Sep 2013 07:30:00 +0200
changeset 160365 eb106e9876fdef97be287163ffe8d63dc6d1d53e
parent 160364 ef734225adc863ff2611e025adc56463805ef42b
child 160366 0f3e5fbcc0bf65517ad361c6122491dab9ddff44
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, lsblakk
bugs916166
milestone26.0a2
Bug 916166 - [app manager] Disable the network monitor. r=ochameau, a=lsblakk
browser/devtools/app-manager/content/device.js
browser/devtools/app-manager/content/projects.js
browser/devtools/main.js
toolkit/devtools/apps/app-actor-front.js
--- a/browser/devtools/app-manager/content/device.js
+++ b/browser/devtools/app-manager/content/device.js
@@ -6,16 +6,17 @@ const Cu = Components.utils;
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource:///modules/devtools/gDevTools.jsm");
 
 const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 const {require} = devtools;
 
 const {ConnectionManager, Connection} = require("devtools/client/connection-manager");
 const {getDeviceFront} = require("devtools/server/actors/device");
+const {getTargetForApp} = require("devtools/app-actor-front");
 const DeviceStore = require("devtools/app-manager/device-store");
 const WebappsStore = require("devtools/app-manager/webapps-store");
 const promise = require("sdk/core/promise");
 
 window.addEventListener("message", function(event) {
   try {
     let message = JSON.parse(event.data);
     if (message.name == "connection") {
@@ -129,49 +130,22 @@ let UI = {
       let tab = gBrowser.selectedTab = gBrowser.addTab(url);
       tab.addEventListener("TabClose", function onTabClose() {
         tab.removeEventListener("TabClose", onTabClose, false);
         topWindow.URL.revokeObjectURL(url);
       }, false);
     }).then(null, console.error);
   },
 
-  _getTargetForApp: function(manifest) { // FIXME <- will be implemented in bug 912476
+  openToolbox: function(manifest) {
     if (!this.listTabsResponse)
-      return null;
-
-    let actor = this.listTabsResponse.webappsActor;
-    let deferred = promise.defer();
-    let request = {
-      to: actor,
-      type: "getAppActor",
-      manifestURL: manifest,
-    }
-    this.connection.client.request(request, (res) => {
-      if (res.error) {
-        deferred.reject(res.error);
-      } else {
-        let options = {
-          form: res.actor,
-          client: this.connection.client,
-          chrome: false
-        };
-
-        devtools.TargetFactory.forRemoteTab(options).then((target) => {
-          deferred.resolve(target)
-        }, (error) => {
-          deferred.reject(error);
-        });
-      }
-    });
-    return deferred.promise;
-  },
-
-  openToolbox: function(manifest) {
-    this._getTargetForApp(manifest).then((target) => {
+      return;
+    getTargetForApp(this.connection.client,
+                    this.listTabsResponse.webappsActor,
+                    manifest).then((target) => {
       gDevTools.showToolbox(target,
                             null,
                             devtools.Toolbox.HostType.WINDOW).then(toolbox => {
         this.connection.once(Connection.Events.DISCONNECTED, () => {
           toolbox.destroy();
         });
       });
     }, console.error);
--- a/browser/devtools/app-manager/content/projects.js
+++ b/browser/devtools/app-manager/content/projects.js
@@ -9,17 +9,17 @@ const Cr = Components.results;
 Cu.import("resource:///modules/devtools/gDevTools.jsm");
 const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 const {require} = devtools;
 const {ConnectionManager, Connection} = require("devtools/client/connection-manager");
 const {AppProjects} = require("devtools/app-manager/app-projects");
 const {AppValidator} = require("devtools/app-manager/app-validator");
 const {Services} = Cu.import("resource://gre/modules/Services.jsm");
 const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
-const {installHosted, installPackaged} = require("devtools/app-actor-front");
+const {installHosted, installPackaged, getTargetForApp} = require("devtools/app-actor-front");
 
 const promise = require("sdk/core/promise");
 
 window.addEventListener("message", function(event) {
   try {
     let json = JSON.parse(event.data);
     if (json.name == "connection") {
       let cid = parseInt(json.cid);
@@ -251,46 +251,16 @@ let UI = {
       manifestURL: this._getProjectManifestURL(project)
     };
     this.connection.client.request(request, (res) => {
       promive.resolve(res);
     });
     return deferred.promise;
   },
 
-  _getTargetForApp: function(manifest) { // FIXME <- will be implemented in bug 912476
-    if (!this.listTabsResponse)
-      return null;
-    let actor = this.listTabsResponse.webappsActor;
-    let deferred = promise.defer();
-    let request = {
-      to: actor,
-      type: "getAppActor",
-      manifestURL: manifest,
-    }
-    this.connection.client.request(request, (res) => {
-      if (res.error) {
-        deferred.reject(res.error);
-      } else {
-        let options = {
-          form: res.actor,
-          client: this.connection.client,
-          chrome: false
-        };
-
-        devtools.TargetFactory.forRemoteTab(options).then((target) => {
-          deferred.resolve(target)
-        }, (error) => {
-          deferred.reject(error);
-        });
-      }
-    });
-    return deferred.promise;
-  },
-
   debug: function(button, location) {
     button.disabled = true;
     let project = AppProjects.get(location);
     // First try to open the app
     this.start(project)
         .then(
          null,
          (error) => {
@@ -315,17 +285,19 @@ let UI = {
            alert(msg);
            this.connection.log(msg);
          });
   },
 
   openToolbox: function(project) {
     let deferred = promise.defer();
     let manifest = this._getProjectManifestURL(project);
-    this._getTargetForApp(manifest).then((target) => {
+    getTargetForApp(this.connection.client,
+                    this.listTabsResponse.webappsActor,
+                    manifest).then((target) => {
       gDevTools.showToolbox(target,
                             null,
                             devtools.Toolbox.HostType.WINDOW).then(toolbox => {
         this.connection.once(Connection.Events.DISCONNECTED, () => {
           toolbox.destroy();
         });
         deferred.resolve();
       });
--- a/browser/devtools/main.js
+++ b/browser/devtools/main.js
@@ -188,17 +188,17 @@ Tools.netMonitor = {
   modifiers: osString == "Darwin" ? "accel,alt" : "accel,shift",
   visibilityswitch: "devtools.netmonitor.enabled",
   icon: "chrome://browser/skin/devtools/tool-network.png",
   url: "chrome://browser/content/devtools/netmonitor.xul",
   label: l10n("netmonitor.label", netMonitorStrings),
   tooltip: l10n("netmonitor.tooltip", netMonitorStrings),
 
   isTargetSupported: function(target) {
-    return true;
+    return !target.isApp;
   },
 
   build: function(iframeWindow, toolbox) {
     let panel = new NetMonitorPanel(iframeWindow, toolbox);
     return panel.open();
   }
 };
 
--- a/toolkit/devtools/apps/app-actor-front.js
+++ b/toolkit/devtools/apps/app-actor-front.js
@@ -1,12 +1,13 @@
 const {Ci, Cc, Cu, Cr} = require("chrome");
 Cu.import("resource://gre/modules/osfile.jsm");
 const {Services} = Cu.import("resource://gre/modules/Services.jsm");
 const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
+const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 const promise = require("sdk/core/promise");
 
 // XXX: bug 912476 make this module a real protocol.js front
 // by converting webapps actor to protocol.js
 
 const PR_USEC_PER_MSEC = 1000;
 const PR_RDWR = 0x04;
 const PR_CREATE_FILE = 0x08;
@@ -205,8 +206,37 @@ function installHosted(client, webappsAc
       deferred.reject({error: res.error, message: res.message});
     else
       deferred.resolve({appId: res.appId});
   });
   return deferred.promise;
 }
 exports.installHosted = installHosted;
 
+function getTargetForApp(client, webappsActor, manifestURL) {
+  let deferred = promise.defer();
+  let request = {
+    to: webappsActor,
+    type: "getAppActor",
+    manifestURL: manifestURL,
+  }
+  client.request(request, (res) => {
+    if (res.error) {
+      deferred.reject(res.error);
+    } else {
+      let options = {
+        form: res.actor,
+        client: client,
+        chrome: false
+      };
+
+      devtools.TargetFactory.forRemoteTab(options).then((target) => {
+        target.isApp = true;
+        deferred.resolve(target)
+      }, (error) => {
+        deferred.reject(error);
+      });
+    }
+  });
+  return deferred.promise;
+}
+exports.getTargetForApp = getTargetForApp;
+