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

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

Issue 1332273003: Change the print preview UI to use the material design style buttons for zoom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | chrome/browser/resources/pdf/toolbar_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | chrome/browser/resources/pdf/toolbar_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698