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

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

Issue 814763002: Set the document title in the PDF viewer to be the name of the PDF file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « no previous file | no next file » | 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 57b80c35179b1f14b2f566f7ef64464aaa848faf..ef89c325c7591e4894b81f19b084033baefbbad0 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -21,6 +21,16 @@ function getScrollbarWidth() {
}
/**
+ * Return the filename component of a URL.
+ * @param {string} url The URL to get the filename from.
+ * @return {string} The filename component.
+ */
+function getFilenameFromURL(url) {
+ var components = url.split(/\/|\\/);
+ return components[components.length - 1];
+}
+
+/**
* The minimum number of pixels to offset the toolbar by from the bottom and
* right side of the screen.
*/
@@ -81,6 +91,7 @@ function PDFViewer(streamDetails) {
false);
this.sendScriptingMessage_({type: 'readyToReceive'});
+ document.title = getFilenameFromURL(this.streamDetails.originalUrl);
this.plugin_.setAttribute('src', this.streamDetails.originalUrl);
this.plugin_.setAttribute('stream-url', this.streamDetails.streamUrl);
var headers = '';
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698