From dd9a59db218b2de5345047e5327c797620b8ec7b Mon Sep 17 00:00:00 2001 From: Ratnadeep Debnath Date: Tue, 11 Mar 2014 17:01:29 -0400 Subject: [PATCH] Bug 912900 - Show open tabs in connected device's Firefox in AppManager. r=jryans --- .../devtools/app-manager/content/device.js | 31 +++++++++++++++++-- .../devtools/app-manager/content/device.xhtml | 18 ++++++++++- browser/devtools/app-manager/device-store.js | 18 ++++++++++- .../chrome/browser/devtools/app-manager.dtd | 4 +++ .../shared/devtools/app-manager/device.css | 16 ++++++---- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/browser/devtools/app-manager/content/device.js b/browser/devtools/app-manager/content/device.js index f1748e0e897..23d754f6b0a 100644 --- a/browser/devtools/app-manager/content/device.js +++ b/browser/devtools/app-manager/content/device.js @@ -4,7 +4,8 @@ const Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource:///modules/devtools/gDevTools.jsm"); +Cu.import("resource://gre/modules/devtools/dbg-client.jsm"); +const {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const {require} = devtools; @@ -17,6 +18,7 @@ const {getTargetForApp, launchApp, closeApp} const DeviceStore = require("devtools/app-manager/device-store"); const WebappsStore = require("devtools/app-manager/webapps-store"); const promise = require("sdk/core/promise"); +const DEFAULT_APP_ICON = "chrome://browser/skin/devtools/app-manager/default-app-icon.png"; window.addEventListener("message", function(event) { try { @@ -141,7 +143,7 @@ let UI = { if (panel) panel.classList.add("selected"); }, - openToolbox: function(manifest) { + openToolboxForApp: function(manifest) { if (!this.connected) { return; } @@ -155,6 +157,31 @@ let UI = { }, console.error); }, + _getTargetForTab: function (form) { + let options = { + form: form, + client: this.connection.client, + chrome: false + }; + let deferred = promise.defer(); + return devtools.TargetFactory.forRemoteTab(options); + }, + + openToolboxForTab: function (aNode) { + let index = Array.prototype.indexOf.apply( + aNode.parentNode.parentNode.parentNode.children, + [aNode.parentNode.parentNode]); + this.connection.client.listTabs( + response => { + let tab = response.tabs[index]; + this._getTargetForTab(tab).then(target => { + top.UI.openAndShowToolboxForTarget( + target, tab.title, DEFAULT_APP_ICON); + }, console.error); + } + ); + }, + startApp: function(manifest) { if (!this.connected) { return promise.reject(); diff --git a/browser/devtools/app-manager/content/device.xhtml b/browser/devtools/app-manager/content/device.xhtml index 2ed66769e3e..bd19968ac3e 100644 --- a/browser/devtools/app-manager/content/device.xhtml +++ b/browser/devtools/app-manager/content/device.xhtml @@ -44,6 +44,7 @@ + @@ -68,6 +69,9 @@
&device.deny;
+
+
+
@@ -83,12 +87,24 @@ + +