|
|
@ -306,24 +306,30 @@ let PdfjsChromeUtils = { |
|
|
|
* a pdf displayed correctly. |
|
|
|
* a pdf displayed correctly. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
_displayWarning: function (aMsg) { |
|
|
|
_displayWarning: function (aMsg) { |
|
|
|
let json = aMsg.data; |
|
|
|
let data = aMsg.data; |
|
|
|
let browser = aMsg.target; |
|
|
|
let browser = aMsg.target; |
|
|
|
let cpowCallback = aMsg.objects.callback; |
|
|
|
|
|
|
|
let tabbrowser = browser.getTabBrowser(); |
|
|
|
let tabbrowser = browser.getTabBrowser(); |
|
|
|
let notificationBox = tabbrowser.getNotificationBox(browser); |
|
|
|
let notificationBox = tabbrowser.getNotificationBox(browser); |
|
|
|
// Flag so we don't call the response callback twice, since if the user
|
|
|
|
|
|
|
|
// clicks open with different viewer both the button callback and
|
|
|
|
// Flag so we don't send the message twice, since if the user clicks
|
|
|
|
|
|
|
|
// "open with different viewer" both the button callback and
|
|
|
|
// eventCallback will be called.
|
|
|
|
// eventCallback will be called.
|
|
|
|
let responseSent = false; |
|
|
|
let messageSent = false; |
|
|
|
|
|
|
|
function sendMessage(download) { |
|
|
|
|
|
|
|
let mm = browser.messageManager; |
|
|
|
|
|
|
|
mm.sendAsyncMessage('PDFJS:Child:fallbackDownload', |
|
|
|
|
|
|
|
{ download: download }); |
|
|
|
|
|
|
|
} |
|
|
|
let buttons = [{ |
|
|
|
let buttons = [{ |
|
|
|
label: json.label, |
|
|
|
label: data.label, |
|
|
|
accessKey: json.accessKey, |
|
|
|
accessKey: data.accessKey, |
|
|
|
callback: function() { |
|
|
|
callback: function() { |
|
|
|
responseSent = true; |
|
|
|
messageSent = true; |
|
|
|
cpowCallback(true); |
|
|
|
sendMessage(true); |
|
|
|
} |
|
|
|
} |
|
|
|
}]; |
|
|
|
}]; |
|
|
|
notificationBox.appendNotification(json.message, 'pdfjs-fallback', null, |
|
|
|
notificationBox.appendNotification(data.message, 'pdfjs-fallback', null, |
|
|
|
notificationBox.PRIORITY_INFO_LOW, |
|
|
|
notificationBox.PRIORITY_INFO_LOW, |
|
|
|
buttons, |
|
|
|
buttons, |
|
|
|
function eventsCallback(eventType) { |
|
|
|
function eventsCallback(eventType) { |
|
|
@ -334,10 +340,10 @@ let PdfjsChromeUtils = { |
|
|
|
} |
|
|
|
} |
|
|
|
// Don't send a response again if we already responded when the button was
|
|
|
|
// Don't send a response again if we already responded when the button was
|
|
|
|
// clicked.
|
|
|
|
// clicked.
|
|
|
|
if (responseSent) { |
|
|
|
if (messageSent) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
cpowCallback(false); |
|
|
|
sendMessage(false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|