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

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

Issue 1303103003: PDF: Use PDF metadata for the title instead of the last path element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 6f8e0318d412d53b6646945aeaaa5c609f192466..9be132e7381fe3939c4d0b95d1a5054b4efb91fa 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -149,8 +149,6 @@ function PDFViewer(browserApi) {
window.addEventListener('message', this.handleScriptingMessage.bind(this),
false);
- document.title = decodeURIComponent(
- getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl));
this.plugin_.setAttribute('src',
this.browserApi_.getStreamInfo().originalUrl);
this.plugin_.setAttribute('stream-url',
@@ -198,7 +196,6 @@ function PDFViewer(browserApi) {
this.viewport_.zoomOut.bind(this.viewport_));
this.materialToolbar_ = $('material-toolbar');
- this.materialToolbar_.docTitle = document.title;
this.materialToolbar_.addEventListener('save', this.save_.bind(this));
this.materialToolbar_.addEventListener('print', this.print_.bind(this));
this.materialToolbar_.addEventListener('rotate-right',
@@ -607,10 +604,18 @@ PDFViewer.prototype = {
case 'cancelStreamUrl':
chrome.mimeHandlerPrivate.abortStream();
break;
- case 'bookmarks':
+ case 'metadata':
+ if (message.data.title) {
+ document.title = message.data.title;
+ } else {
+ document.title = decodeURIComponent(
+ getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl));
+ }
this.bookmarks_ = message.data.bookmarks;
- if (this.isMaterial_ && this.bookmarks_.length !== 0)
+ if (this.isMaterial_) {
+ this.materialToolbar_.docTitle = document.title;
this.materialToolbar_.bookmarks = this.bookmarks;
+ }
break;
case 'setIsSelecting':
this.viewportScroller_.setEnableScrolling(message.data.isSelecting);

Powered by Google App Engine
This is Rietveld 408576698