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

Unified 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: Remove test cases 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/manifest.json ('k') | chrome/common/extensions/api/OWNERS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index c8753e14a6207dca698cd16144c70cb57dba82f9..010f83f5c2c452d691dfc63eeb914a78a967e5cb 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -255,6 +255,9 @@ function PDFViewer(browserApi) {
onNavigateInCurrentTab, onNavigateInNewTab);
this.viewportScroller_ =
new ViewportScroller(this.viewport_, this.plugin_, window);
+
+ // Request translated strings.
+ chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this));
}
PDFViewer.prototype = {
@@ -539,6 +542,22 @@ PDFViewer.prototype = {
/**
* @private
+ * Load a dictionary of translated strings into the UI. Used as a callback for
+ * chrome.resourcesPrivate.
+ * @param {Object} strings Dictionary of translated strings
+ */
+ handleStrings_: function(strings) {
+ this.passwordScreen_.text = strings.passwordPrompt;
+ if (!this.isMaterial_) {
+ this.progressBar_.text = strings.pageLoading;
+ if (!this.isPrintPreview_)
+ this.progressBar_.style.visibility = 'visible';
+ }
+ this.errorScreen_.text = strings.pageLoadFailed;
+ },
+
+ /**
+ * @private
* An event handler for handling password-submitted events. These are fired
* when an event is entered into the password screen.
* @param {Object} event a password-submitted event.
@@ -618,15 +637,6 @@ PDFViewer.prototype = {
position.y = message.data.y;
this.viewport_.position = position;
break;
- case 'setTranslatedStrings':
- this.passwordScreen_.text = message.data.getPasswordString;
- if (!this.isMaterial_) {
- this.progressBar_.text = message.data.loadingString;
- if (!this.isPrintPreview_)
- this.progressBar_.style.visibility = 'visible';
- }
- this.errorScreen_.text = message.data.loadFailedString;
- break;
case 'cancelStreamUrl':
chrome.mimeHandlerPrivate.abortStream();
break;
« no previous file with comments | « chrome/browser/resources/pdf/manifest.json ('k') | chrome/common/extensions/api/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698