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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Turn a dictionary received from postMessage into a key event. 6 * Turn a dictionary received from postMessage into a key event.
7 * @param {Object} dict A dictionary representing the key event. 7 * @param {Object} dict A dictionary representing the key event.
8 * @return {Event} A key event. 8 * @return {Event} A key event.
9 */ 9 */
10 function DeserializeKeyEvent(dict) { 10 function DeserializeKeyEvent(dict) {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 /** 263 /**
264 * Creates a PDF viewer with a scripting interface. This is basically 1) an 264 * Creates a PDF viewer with a scripting interface. This is basically 1) an
265 * iframe which is navigated to the PDF viewer extension and 2) a scripting 265 * iframe which is navigated to the PDF viewer extension and 2) a scripting
266 * interface which provides access to various features of the viewer for use 266 * interface which provides access to various features of the viewer for use
267 * by print preview and accessibility. 267 * by print preview and accessibility.
268 * @param {string} src the source URL of the PDF to load initially. 268 * @param {string} src the source URL of the PDF to load initially.
269 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer. 269 * @return {HTMLIFrameElement} the iframe element containing the PDF viewer.
270 */ 270 */
271 function PDFCreateOutOfProcessPlugin(src) { 271 function PDFCreateOutOfProcessPlugin(src) {
272 var client = new PDFScriptingAPI(window);
272 var iframe = window.document.createElement('iframe'); 273 var iframe = window.document.createElement('iframe');
273 iframe.setAttribute(
274 'src',
275 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html?' + src);
276 // Prevent the frame from being tab-focusable. 274 // Prevent the frame from being tab-focusable.
277 iframe.setAttribute('tabindex', '-1'); 275 iframe.setAttribute('tabindex', '-1');
278 var client = new PDFScriptingAPI(window); 276
279 iframe.onload = function() { 277 // TODO(raymes): This below is a hack to tell if the material design PDF UI
280 client.setPlugin(iframe.contentWindow); 278 // has been enabled. Remove this as soon as we remove the material design PDF
281 }; 279 // flag.
280 var EXTENSION_URL = 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/';
281 var PAGE_NAME = 'index.html';
282 var MATERIAL_PAGE_NAME = 'index-material.html';
283 fetch(EXTENSION_URL + PAGE_NAME, {
284 method: 'get'
285 }).then(function() {
286 iframe.setAttribute('src', EXTENSION_URL + PAGE_NAME + '?' + src);
287 }, function() {
288 iframe.setAttribute('src', EXTENSION_URL + MATERIAL_PAGE_NAME + '?' + src);
289 }).then(function() {
290 iframe.onload = function() {
291 client.setPlugin(iframe.contentWindow);
292 };
293 });
294
282 // Add the functions to the iframe so that they can be called directly. 295 // Add the functions to the iframe so that they can be called directly.
283 iframe.setViewportChangedCallback = 296 iframe.setViewportChangedCallback =
284 client.setViewportChangedCallback.bind(client); 297 client.setViewportChangedCallback.bind(client);
285 iframe.setLoadCallback = client.setLoadCallback.bind(client); 298 iframe.setLoadCallback = client.setLoadCallback.bind(client);
286 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client); 299 iframe.setKeyEventCallback = client.setKeyEventCallback.bind(client);
287 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client); 300 iframe.resetPrintPreviewMode = client.resetPrintPreviewMode.bind(client);
288 iframe.loadPreviewPage = client.loadPreviewPage.bind(client); 301 iframe.loadPreviewPage = client.loadPreviewPage.bind(client);
289 iframe.sendKeyEvent = client.sendKeyEvent.bind(client); 302 iframe.sendKeyEvent = client.sendKeyEvent.bind(client);
290 return iframe; 303 return iframe;
291 } 304 }
OLDNEW
« 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