Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: chrome/browser/resources/pdf/pdf_scripting_api.js

Issue 1217503012: Avoid cross-origin iframe issues when loading PDF in print preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/pdf/pdf_scripting_api.js
diff --git a/chrome/browser/resources/pdf/pdf_scripting_api.js b/chrome/browser/resources/pdf/pdf_scripting_api.js
index c75820c957a1dd8781e50ecfbfb87abab66a8d7f..28bf7959755721843cd07b6dd9437869751d1535 100644
--- a/chrome/browser/resources/pdf/pdf_scripting_api.js
+++ b/chrome/browser/resources/pdf/pdf_scripting_api.js
@@ -56,7 +56,8 @@ function PDFScriptingAPI(window, plugin) {
this.setPlugin(plugin);
window.addEventListener('message', function(event) {
- if (event.origin != 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai') {
+ if (event.origin != 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai' &&
+ event.origin != 'chrome://print') {
console.error('Received message that was not from the extension: ' +
event);
return;
@@ -271,12 +272,10 @@ PDFScriptingAPI.prototype = {
function PDFCreateOutOfProcessPlugin(src) {
var client = new PDFScriptingAPI(window);
var iframe = window.document.createElement('iframe');
+ iframe.setAttribute('src', 'pdf_preview.html?' + src);
// Prevent the frame from being tab-focusable.
iframe.setAttribute('tabindex', '-1');
- var EXTENSION_URL =
- 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html';
- iframe.setAttribute('src', EXTENSION_URL + '?' + src);
iframe.onload = function() {
client.setPlugin(iframe.contentWindow);
};

Powered by Google App Engine
This is Rietveld 408576698