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

Side by Side Diff: chrome/browser/resources/pdf/pdf.js

Issue 1329213002: PDF: Use chrome.resourcesPrivate instead of Pepper to display translated strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@i18n_api
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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 236 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
237 237
238 // Parse open pdf parameters. 238 // Parse open pdf parameters.
239 this.paramsParser_ = 239 this.paramsParser_ =
240 new OpenPDFParamsParser(this.getNamedDestination_.bind(this)); 240 new OpenPDFParamsParser(this.getNamedDestination_.bind(this));
241 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, 241 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl,
242 this.viewport_, this.paramsParser_, 242 this.viewport_, this.paramsParser_,
243 onNavigateInCurrentTab, onNavigateInNewTab); 243 onNavigateInCurrentTab, onNavigateInNewTab);
244 this.viewportScroller_ = 244 this.viewportScroller_ =
245 new ViewportScroller(this.viewport_, this.plugin_, window); 245 new ViewportScroller(this.viewport_, this.plugin_, window);
246
247 // Request translated strings.
248 chrome.i18nPrivate.getStrings('pdf', this.handleStrings_.bind(this));
246 } 249 }
247 250
248 PDFViewer.prototype = { 251 PDFViewer.prototype = {
249 /** 252 /**
250 * @private 253 * @private
251 * Handle key events. These may come from the user directly or via the 254 * Handle key events. These may come from the user directly or via the
252 * scripting API. 255 * scripting API.
253 * @param {KeyboardEvent} e the event to handle. 256 * @param {KeyboardEvent} e the event to handle.
254 */ 257 */
255 handleKeyEvent_: function(e) { 258 handleKeyEvent_: function(e) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 this.loadState_ = LoadState.SUCCESS; 518 this.loadState_ = LoadState.SUCCESS;
516 this.sendDocumentLoadedMessage_(); 519 this.sendDocumentLoadedMessage_();
517 while (this.delayedScriptingMessages_.length > 0) 520 while (this.delayedScriptingMessages_.length > 0)
518 this.handleScriptingMessage(this.delayedScriptingMessages_.shift()); 521 this.handleScriptingMessage(this.delayedScriptingMessages_.shift());
519 522
520 if (this.isMaterial_) 523 if (this.isMaterial_)
521 this.toolbarManager_.hideToolbarsAfterTimeout(); 524 this.toolbarManager_.hideToolbarsAfterTimeout();
522 } 525 }
523 }, 526 },
524 527
528 handleStrings_: function(strings) {
raymes 2015/09/17 03:56:43 nit: add some jsdoc
529 this.passwordScreen_.text = strings.passwordPrompt;
530 if (!this.isMaterial_) {
531 this.progressBar_.text = strings.pageLoading;
532 if (!this.isPrintPreview_)
533 this.progressBar_.style.visibility = 'visible';
534 }
535 this.errorScreen_.text = strings.pageLoadFailed;
536 },
537
525 /** 538 /**
526 * @private 539 * @private
527 * An event handler for handling password-submitted events. These are fired 540 * An event handler for handling password-submitted events. These are fired
528 * when an event is entered into the password screen. 541 * when an event is entered into the password screen.
529 * @param {Object} event a password-submitted event. 542 * @param {Object} event a password-submitted event.
530 */ 543 */
531 onPasswordSubmitted_: function(event) { 544 onPasswordSubmitted_: function(event) {
532 this.plugin_.postMessage({ 545 this.plugin_.postMessage({
533 type: 'getPasswordComplete', 546 type: 'getPasswordComplete',
534 password: event.detail.password 547 password: event.detail.password
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 this.navigator_.navigate(message.data.url, message.data.newTab); 605 this.navigator_.navigate(message.data.url, message.data.newTab);
593 break; 606 break;
594 case 'setScrollPosition': 607 case 'setScrollPosition':
595 var position = this.viewport_.position; 608 var position = this.viewport_.position;
596 if (message.data.x !== undefined) 609 if (message.data.x !== undefined)
597 position.x = message.data.x; 610 position.x = message.data.x;
598 if (message.data.y !== undefined) 611 if (message.data.y !== undefined)
599 position.y = message.data.y; 612 position.y = message.data.y;
600 this.viewport_.position = position; 613 this.viewport_.position = position;
601 break; 614 break;
602 case 'setTranslatedStrings':
603 this.passwordScreen_.text = message.data.getPasswordString;
604 if (!this.isMaterial_) {
605 this.progressBar_.text = message.data.loadingString;
606 if (!this.isPrintPreview_)
607 this.progressBar_.style.visibility = 'visible';
608 }
609 this.errorScreen_.text = message.data.loadFailedString;
610 break;
611 case 'cancelStreamUrl': 615 case 'cancelStreamUrl':
612 chrome.mimeHandlerPrivate.abortStream(); 616 chrome.mimeHandlerPrivate.abortStream();
613 break; 617 break;
614 case 'metadata': 618 case 'metadata':
615 if (message.data.title) { 619 if (message.data.title) {
616 document.title = message.data.title; 620 document.title = message.data.title;
617 } else { 621 } else {
618 document.title = 622 document.title =
619 getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl); 623 getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl);
620 } 624 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 * Each bookmark is an Object containing a: 855 * Each bookmark is an Object containing a:
852 * - title 856 * - title
853 * - page (optional) 857 * - page (optional)
854 * - array of children (themselves bookmarks) 858 * - array of children (themselves bookmarks)
855 * @type {Array} the top-level bookmarks of the PDF. 859 * @type {Array} the top-level bookmarks of the PDF.
856 */ 860 */
857 get bookmarks() { 861 get bookmarks() {
858 return this.bookmarks_; 862 return this.bookmarks_;
859 } 863 }
860 }; 864 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698