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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
11 var div = document.createElement('div'); 11 var div = document.createElement('div');
12 div.style.visibility = 'hidden'; 12 div.style.visibility = 'hidden';
13 div.style.overflow = 'scroll'; 13 div.style.overflow = 'scroll';
14 div.style.width = '50px'; 14 div.style.width = '50px';
15 div.style.height = '50px'; 15 div.style.height = '50px';
16 div.style.position = 'absolute'; 16 div.style.position = 'absolute';
17 document.body.appendChild(div); 17 document.body.appendChild(div);
18 var result = div.offsetWidth - div.clientWidth; 18 var result = div.offsetWidth - div.clientWidth;
19 div.parentNode.removeChild(div); 19 div.parentNode.removeChild(div);
20 return result; 20 return result;
21 } 21 }
22 22
23 /** 23 /**
24 * Return the filename component of a URL.
25 * @param {string} url The URL to get the filename from.
26 * @return {string} The filename component.
27 */
28 function getFilenameFromURL(url) {
29 var components = url.split(/\/|\\/);
30 return components[components.length - 1];
31 }
32
33 /**
24 * The minimum number of pixels to offset the toolbar by from the bottom and 34 * The minimum number of pixels to offset the toolbar by from the bottom and
25 * right side of the screen. 35 * right side of the screen.
26 */ 36 */
27 PDFViewer.MIN_TOOLBAR_OFFSET = 15; 37 PDFViewer.MIN_TOOLBAR_OFFSET = 15;
28 38
29 /** 39 /**
30 * Creates a new PDFViewer. There should only be one of these objects per 40 * Creates a new PDFViewer. There should only be one of these objects per
31 * document. 41 * document.
32 * @param {Object} streamDetails The stream object which points to the data 42 * @param {Object} streamDetails The stream object which points to the data
33 * contained in the PDF. 43 * contained in the PDF.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this), 84 this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this),
75 false); 85 false);
76 86
77 // Handle scripting messages from outside the extension that wish to interact 87 // Handle scripting messages from outside the extension that wish to interact
78 // with it. We also send a message indicating that extension has loaded and 88 // with it. We also send a message indicating that extension has loaded and
79 // is ready to receive messages. 89 // is ready to receive messages.
80 window.addEventListener('message', this.handleScriptingMessage_.bind(this), 90 window.addEventListener('message', this.handleScriptingMessage_.bind(this),
81 false); 91 false);
82 this.sendScriptingMessage_({type: 'readyToReceive'}); 92 this.sendScriptingMessage_({type: 'readyToReceive'});
83 93
94 document.title = getFilenameFromURL(this.streamDetails.originalUrl);
84 this.plugin_.setAttribute('src', this.streamDetails.originalUrl); 95 this.plugin_.setAttribute('src', this.streamDetails.originalUrl);
85 this.plugin_.setAttribute('stream-url', this.streamDetails.streamUrl); 96 this.plugin_.setAttribute('stream-url', this.streamDetails.streamUrl);
86 var headers = ''; 97 var headers = '';
87 for (var header in this.streamDetails.responseHeaders) { 98 for (var header in this.streamDetails.responseHeaders) {
88 headers += header + ': ' + 99 headers += header + ': ' +
89 this.streamDetails.responseHeaders[header] + '\n'; 100 this.streamDetails.responseHeaders[header] + '\n';
90 } 101 }
91 this.plugin_.setAttribute('headers', headers); 102 this.plugin_.setAttribute('headers', headers);
92 103
93 if (!this.streamDetails.embedded) 104 if (!this.streamDetails.embedded)
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 this.streamDetails.tabId != -1); 602 this.streamDetails.tabId != -1);
592 }, 603 },
593 604
594 /** 605 /**
595 * @type {Viewport} the viewport of the PDF viewer. 606 * @type {Viewport} the viewport of the PDF viewer.
596 */ 607 */
597 get viewport() { 608 get viewport() {
598 return this.viewport_; 609 return this.viewport_;
599 } 610 }
600 }; 611 };
OLDNEW
« 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