Authentic redirection - opening a local HTML document in a new tab in the Firefox extension

I am currently trying to connect the Chrome extension to Firefox.

The Chrome extension has a Login page that opens in a new tab as an HTML document. The HTML document is stored in a local directory with other extension files. The user enters a URL that should represent the server on which our application is running, where the user will be prompted to log in. After a successful login, the user is redirected back to the options.html page, which is updated to show user settings.

I would like to duplicate this in the Firefox extension, i.e. I would like not to write anything in XUL to create a parameter page.

I tried to open a new tab with my HTML page as follows:

var url = "chrome://myextension/content/options.html";
        var win = Components.classes['@mozilla.org/appshell/window-mediator;1']
                    .getService(Components.interfaces.nsIWindowMediator)
                    .getMostRecentWindow('navigator:browser');
        win.gBrowser.selectedTab = win.gBrowser.addTab(url);

But I don’t like it for several reasons: 1) In the navigation bar on a new tab, the URL "chrome: // ..." is displayed, and 2) it interrupts the authentication process. Authentication is performed using a system such as OAuth, and the current URL is passed to the API so that the user can be redirected back after successful authentication. Authentication fails with the error "chrome: //" as part of the URL.

Just out of curiosity, I tried hard-coding the url like this:

http://myextension/content/options.html

And the user is actually authenticated successfully, but then the redirect obviously does not work.

The Chrome extension seems to work without problems or weird hacks. From what I can say, opening it works as follows:

chrome.tabs.create({"url":chrome.extension.getURL("options.html"), "selected":true});

URL- , , :

var options_url = chrome.extension.getURL('options.html');

, : HTML- Firefox "chrome://"? , Google Chrome?

23/5/12

, , ://URL- , .

http://adblockplus.org/blog/web-pages-accessing-chrome-is-forbidden

, . HTML chrome://.

07/6/12

(, ) :

URL- , . , "chrome://myextension/content/options.html" URL-, , URL-, "http://myextension/thisis/madeup.html".

overlay.js HTTP-, URL-. GET URL-, "chrome://myextension/content/options.html".

. :

https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIObserver https://developer.mozilla.org/en/XUL_School/Intercepting_Page_Loads#HTTP_Observers

+3
1

OAuth, OAuthorizer Mozilla . , !

0

All Articles