| 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 4a08195c83c5777d1b51c17883e9bde18ed3a017..06fc8b546c4ab15d308a6748e4738729bb41549d 100644
|
| --- a/chrome/browser/resources/pdf/pdf_scripting_api.js
|
| +++ b/chrome/browser/resources/pdf/pdf_scripting_api.js
|
| @@ -269,16 +269,29 @@ PDFScriptingAPI.prototype = {
|
| * @return {HTMLIFrameElement} the iframe element containing the PDF viewer.
|
| */
|
| function PDFCreateOutOfProcessPlugin(src) {
|
| + var client = new PDFScriptingAPI(window);
|
| var iframe = window.document.createElement('iframe');
|
| - iframe.setAttribute(
|
| - 'src',
|
| - 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?' + src);
|
| // Prevent the frame from being tab-focusable.
|
| iframe.setAttribute('tabindex', '-1');
|
| - var client = new PDFScriptingAPI(window);
|
| - iframe.onload = function() {
|
| - client.setPlugin(iframe.contentWindow);
|
| - };
|
| +
|
| + // TODO(raymes): This below is a hack to tell if the material design PDF UI
|
| + // has been enabled. Remove this as soon as we remove the material design PDF
|
| + // flag.
|
| + var EXTENSION_URL = 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/';
|
| + var PAGE_NAME = 'index.html';
|
| + var MATERIAL_PAGE_NAME = 'index-material.html';
|
| + fetch(EXTENSION_URL + PAGE_NAME, {
|
| + method: 'get'
|
| + }).then(function() {
|
| + iframe.setAttribute('src', EXTENSION_URL + PAGE_NAME + '?' + src);
|
| + }, function() {
|
| + iframe.setAttribute('src', EXTENSION_URL + MATERIAL_PAGE_NAME + '?' + src);
|
| + }).then(function() {
|
| + iframe.onload = function() {
|
| + client.setPlugin(iframe.contentWindow);
|
| + };
|
| + });
|
| +
|
| // Add the functions to the iframe so that they can be called directly.
|
| iframe.setViewportChangedCallback =
|
| client.setViewportChangedCallback.bind(client);
|
|
|