expose way to access browsers from a chrome window



11 years ago
10 years ago


(Reporter: dougt, Unassigned)


Bug Flags:
wanted-fennec1.0 +



(1 obsolete attachment)



11 years ago
Created attachment 338966 [details] [diff] [review]
patch v.1

we have code in the mochitests (and I would assume others do things similar) that enumerates all of the chrome windows.  For each chrome window, it wants to access each browser window.

For example:

var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].getService(Components.interfaces.nsIWindowWatcher);
var enumerator = ww.getWindowEnumerator();
var contentWindows = [];   
while (enumerator.hasMoreElements()) {
  var win = enumerator.getNext();
  if (typeof ChromeWindow != "undefined" && win instanceof ChromeWindow) {
    if (win.gBrowser) {
      var tabs = win.gBrowser.browsers;
        for (var i = 0; i < tabs.length; i++)

For Fennec, we are not going to have a gBrowser that is equal to the firefox gBrowser.  In our case, we can do something like:

for each (node in win.getBrowsers())
Attachment #338966 - Flags: review?(mark.finkle)


11 years ago
Blocks: 455611
Comment on attachment 338966 [details] [diff] [review]
patch v.1

>diff --git a/chrome/content/browser.js b/chrome/content/browser.js

>+function getBrowsers() {
>+  return Browser.content.getBrowsers();

I'd like to get more consensus about the naming here. We have a separate bug to cleanup our API a bit, so I want gavin's input here too.

getBrowsers() and getBrowser() is a little too close for my liking.

> function getBrowser() {
>   return Browser.content.browser;

>diff --git a/chrome/content/deckbrowser.xml b/chrome/content/deckbrowser.xml

>+      <method name="getBrowsers">
>+        <body><![CDATA[
>+          var browsers = [];
>+          var displayList = this.displayList.childNodes;
>+          for (var t = 0; t < displayList.length; t++) {
>+            var display = displayList[t];
>+            var browser = this.getBrowserForDisplay(display);
>+            if (browser)
>+              browsers.push(browser)
>+          }
>+          return browsers;
>+        ]]>
>+        </body>
>       </method>

Looks good, but I think I want to use:
<property name="browsers" readonly="true">

like we find in tabbrowser:
Attachment #338966 - Flags: review?(mark.finkle)
Attachment #338966 - Flags: review?(gavin.sharp)
Attachment #338966 - Flags: review-

Comment 2

11 years ago
we probably don't need this now.  no longer blocks 455611
Assignee: doug.turner → nobody
No longer blocks: 455611
Severity: critical → normal
No longer blocks: 455611


11 years ago
Assignee: nobody → gavin.sharp
Flags: wanted-fennec1.0+
Attachment #338966 - Attachment is obsolete: true
Attachment #338966 - Flags: review?(gavin.sharp)
Looks like this is mostly irrelevant now (part of that patch is already in deckbrowser, in fact). We should still think about cleaning up our APIs and making them look similar to Firefox to ease extension porting, but I think we have existing bugs on that?
Assignee: gavin.sharp → nobody
(In reply to comment #3)
> We should still think about cleaning up our APIs and
> making them look similar to Firefox to ease extension porting, but I think we
> have existing bugs on that?

We do - closing this one
Last Resolved: 10 years ago
Resolution: --- → WONTFIX
fair enough, marking as verified.
You need to log in before you can comment on or make changes to this bug.