| 1 | | /* ***** BEGIN LICENSE BLOCK Version: GPL 3.0 ***** |
| 2 | | * FireMobileFimulator is a Firefox add-on that simulate web browsers of |
| 3 | | * japanese mobile phones. |
| 4 | | * Copyright (C) 2008 Takahiro Horikawa <horikawa.takahiro@gmail.com> |
| 5 | | * |
| 6 | | * This program is free software: you can redistribute it and/or modify |
| 7 | | * it under the terms of the GNU General Public License as published by |
| 8 | | * the Free Software Foundation, either version 3 of the License, or |
| 9 | | * (at your option) any later version. |
| 10 | | * |
| 11 | | * This program is distributed in the hope that it will be useful, |
| 12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | | * GNU General Public License for more details. |
| 15 | | * |
| 16 | | * You should have received a copy of the GNU General Public License |
| 17 | | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | | * ***** END LICENSE BLOCK ***** */ |
| | 1 | /******************************************************************************* |
| | 2 | * ***** BEGIN LICENSE BLOCK Version: GPL 3.0 FireMobileFimulator is a Firefox |
| | 3 | * add-on that simulate web browsers of japanese mobile phones. Copyright (C) |
| | 4 | * 2008 Takahiro Horikawa <horikawa.takahiro@gmail.com> |
| | 5 | * |
| | 6 | * This program is free software: you can redistribute it and/or modify it under |
| | 7 | * the terms of the GNU General Public License as published by the Free Software |
| | 8 | * Foundation, either version 3 of the License, or (at your option) any later |
| | 9 | * version. |
| | 10 | * |
| | 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| | 13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| | 14 | * details. |
| | 15 | * |
| | 16 | * You should have received a copy of the GNU General Public License along with |
| | 17 | * this program. If not, see <http://www.gnu.org/licenses/>. ***** END LICENSE |
| | 18 | * BLOCK ***** |
| | 19 | */ |
| 312 | | .getInterface(Ci.nsIWebNavigation); |
| 313 | | webNav.loadURI(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); |
| 314 | | //webNav.loadURI(url, subject.loadFlags, null, null, null); |
| | 321 | .getInterface(Ci.nsIWebNavigation); |
| | 322 | webNav.loadURI(url, Ci.nsIWebNavigation.LOAD_FLAGS_NONE, null, null, |
| | 323 | null); |
| | 324 | // webNav.loadURI(url, subject.loadFlags, null, null, null); |
| | 327 | |
| | 328 | function firemobilesimulator_getTabIdForHttpChannel(httpChannel) { |
| | 329 | if (httpChannel.notificationCallbacks) { |
| | 330 | var interfaceRequestor = httpChannel.notificationCallbacks |
| | 331 | .QueryInterface(Components.interfaces.nsIInterfaceRequestor); |
| | 332 | var targetDoc = interfaceRequestor |
| | 333 | .getInterface(Components.interfaces.nsIDOMWindow).document; |
| | 334 | |
| | 335 | var webNav = httpChannel.notificationCallbacks |
| | 336 | .getInterface(Ci.nsIWebNavigation); |
| | 337 | var mainWindow = webNav.QueryInterface(Components.interfaces.nsIDocShellTreeItem) |
| | 338 | .rootTreeItem |
| | 339 | .QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
| | 340 | .getInterface(Components.interfaces.nsIDOMWindow); |
| | 341 | //var subWindow = interfaceRequestor |
| | 342 | // .getInterface(Components.interfaces.nsIDOMWindow); |
| | 343 | |
| | 344 | dump("mainWindow:"+mainWindow+"\n"); |
| | 345 | //for(var i in mainWindow){ |
| | 346 | // dump(i+":"+mainWindow[i]+"\n"); |
| | 347 | //} |
| | 348 | var gBrowser = mainWindow.getBrowser(); |
| | 349 | dump("gBrowser:"+gBrowser+"\n"); |
| | 350 | |
| | 351 | var tab = null; |
| | 352 | var targetBrowserIndex = gBrowser.getBrowserIndexForDocument(targetDoc); |
| | 353 | |
| | 354 | // handle the case where there was no tab associated with the request |
| | 355 | // (rss, etc) |
| | 356 | if (targetBrowserIndex != -1) |
| | 357 | tab = gBrowser.tabContainer.childNodes[targetBrowserIndex]; |
| | 358 | else |
| | 359 | return (null); |
| | 360 | |
| | 361 | // return(tab.linkedPanel); |
| | 362 | return tab; |
| | 363 | } else |
| | 364 | return (null); |
| | 365 | } |