BrowserDOMWindow.js
Go to the documentation of this file.
1 // vim: set sw=2 :miv
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 
34 const EXPORTED_SYMBOLS = ["BrowserDOMWindow"];
35 
36 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
37 
38 function BrowserDOMWindow(aTabBrowser) {
39  this._tabBrowser = aTabBrowser;
40  this.wrappedJSObject = this;
41 }
42 
43 BrowserDOMWindow.prototype = {
44  _tabBrowser: null,
45 
46  openURI: function BrowserDOMWindow_openURI(aURI, aOpener, aWhere, aContext) {
47  // XXX Mook: for now, just always open in new tab (ignore aWhere)
48  if (aURI instanceof Components.interfaces.nsIURI)
49  aURI = aURI.spec;
50  // XXX Mook: if the tab isn't loaded in the background,
51  // onLocationChange freaks out; so we focus it later if needed
52  var newTab = this._tabBrowser.addTab("about:blank", null, null, null, true, false);
53  var newWindow = this._tabBrowser
54  .getBrowserForTab(newTab)
55  .docShell
56  .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
57  .getInterface(Components.interfaces.nsIDOMWindow);
58  try {
59  var loadflags = (aContext == Components.interfaces.nsIBrowserDOMWindow.OPEN_EXTERNAL) ?
60  Components.interfaces.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
61  Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
62  if (aOpener) {
63  var referrer =
64  Components.classes["@mozilla.org/network/io-service;1"]
65  .getService(Components.interfaces.nsIIOService)
66  .newURI(aOpener.location, null, null);
67  }
68  if (!aURI)
69  aURI = "about:blank";
70  newWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
71  .getInterface(Components.interfaces.nsIWebNavigation)
72  .loadURI(aURI, loadflags, referrer, null, null);
73  } catch(e) {
74  // silently eat the error
75  }
76  var loadInBackground = this._tabBrowser
77  .mPrefs
78  .getBoolPref("browser.tabs.loadDivertedInBackground");
79  if (!loadInBackground) {
80  this._tabBrowser.selectedTab = newTab;
81  }
82  return newWindow;
83  },
84 
85  isTabContentWindow: function BrowserDOMWindow_isTabContentWindow(aWindow) {
86  for (var ctr = 0; ctr < this._tabBrowser.browsers.length; ctr++)
87  if (this._tabBrowser.browsers.item(ctr).contentWindow == aWindow)
88  return true;
89  return false;
90  },
91 
92  QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIBrowserDOMWindow])
93 };
sbOSDControlService prototype QueryInterface
function BrowserDOMWindow(aTabBrowser)
const EXPORTED_SYMBOLS
return null
Definition: FeedWriter.js:1143
if(DEBUG_DATAREMOTES)