Skip to content

Commit

Permalink
Wrap BrowserViewSourceOfDocument() to detect view source tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Jan 19, 2016
1 parent 8706d1b commit abdcfe7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ var privateTab = {
this.patchWarnAboutClosingWindow(window, true);
// Wait to not break BROWSER_NEW_TAB_URL in detached window
this.patchTabBrowserDND(window, gBrowser, true);
this.patchViewSourceTab(window, true);
}.bind(this), 50);
// Import data from privateTab.tabLabelIsEmpty() API
if(!this.emptyTabLabelsImported) {
Expand Down Expand Up @@ -513,6 +514,7 @@ var privateTab = {
}
this.patchBrowsers(gBrowser, false, !force);
this.patchTabBrowserDND(window, gBrowser, false, false, !force);
this.patchViewSourceTab(window, false, !force);
this.patchWarnAboutClosingWindow(window, false, !force);
if(!prefs.get("allowOpenExternalLinksInPrivateTabs"))
this.patchBrowserLoadURI(window, false, !force);
Expand Down Expand Up @@ -890,6 +892,26 @@ var privateTab = {
forceDestroy
);
},
patchViewSourceTab: function(window, applyPatch, forceDestroy) {
var fnViewSource = "BrowserViewSourceOfDocument";
if(!(fnViewSource in window)) {
_log("Can't patch " + fnViewSource + "(): function not found");
return;
}
if(applyPatch) {
patcher.wrapFunction(
window, fnViewSource, fnViewSource,
function before(argsOrDoc) {
var isPrivate = this.isPrivateContent(window);
_log(fnViewSource + "(): wait for tab to make " + (isPrivate ? "private" : "not private"));
this.readyToOpenTab(window, isPrivate);
}.bind(this)
);
}
else {
patcher.unwrapFunction(window, fnViewSource, fnViewSource, forceDestroy);
}
},
patchBrowserLoadURI: function(window, applyPatch, forceDestroy) {
var gBrowser = window.gBrowser;
var browser = gBrowser.browsers && gBrowser.browsers[0];
Expand Down

0 comments on commit abdcfe7

Please sign in to comment.