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

Side by Side 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, 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 this.plugin_.type = 'application/x-google-chrome-pdf'; 142 this.plugin_.type = 'application/x-google-chrome-pdf';
143 this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this), 143 this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this),
144 false); 144 false);
145 145
146 // Handle scripting messages from outside the extension that wish to interact 146 // Handle scripting messages from outside the extension that wish to interact
147 // with it. We also send a message indicating that extension has loaded and 147 // with it. We also send a message indicating that extension has loaded and
148 // is ready to receive messages. 148 // is ready to receive messages.
149 window.addEventListener('message', this.handleScriptingMessage.bind(this), 149 window.addEventListener('message', this.handleScriptingMessage.bind(this),
150 false); 150 false);
151 151
152 document.title = decodeURIComponent(
153 getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl));
154 this.plugin_.setAttribute('src', 152 this.plugin_.setAttribute('src',
155 this.browserApi_.getStreamInfo().originalUrl); 153 this.browserApi_.getStreamInfo().originalUrl);
156 this.plugin_.setAttribute('stream-url', 154 this.plugin_.setAttribute('stream-url',
157 this.browserApi_.getStreamInfo().streamUrl); 155 this.browserApi_.getStreamInfo().streamUrl);
158 var headers = ''; 156 var headers = '';
159 for (var header in this.browserApi_.getStreamInfo().responseHeaders) { 157 for (var header in this.browserApi_.getStreamInfo().responseHeaders) {
160 headers += header + ': ' + 158 headers += header + ': ' +
161 this.browserApi_.getStreamInfo().responseHeaders[header] + '\n'; 159 this.browserApi_.getStreamInfo().responseHeaders[header] + '\n';
162 } 160 }
163 this.plugin_.setAttribute('headers', headers); 161 this.plugin_.setAttribute('headers', headers);
(...skipping 27 matching lines...) Expand all
191 this.zoomToolbar_.addEventListener('fit-to-width', 189 this.zoomToolbar_.addEventListener('fit-to-width',
192 this.viewport_.fitToWidth.bind(this.viewport_)); 190 this.viewport_.fitToWidth.bind(this.viewport_));
193 this.zoomToolbar_.addEventListener('fit-to-page', 191 this.zoomToolbar_.addEventListener('fit-to-page',
194 this.fitToPage_.bind(this)); 192 this.fitToPage_.bind(this));
195 this.zoomToolbar_.addEventListener('zoom-in', 193 this.zoomToolbar_.addEventListener('zoom-in',
196 this.viewport_.zoomIn.bind(this.viewport_)); 194 this.viewport_.zoomIn.bind(this.viewport_));
197 this.zoomToolbar_.addEventListener('zoom-out', 195 this.zoomToolbar_.addEventListener('zoom-out',
198 this.viewport_.zoomOut.bind(this.viewport_)); 196 this.viewport_.zoomOut.bind(this.viewport_));
199 197
200 this.materialToolbar_ = $('material-toolbar'); 198 this.materialToolbar_ = $('material-toolbar');
201 this.materialToolbar_.docTitle = document.title;
202 this.materialToolbar_.addEventListener('save', this.save_.bind(this)); 199 this.materialToolbar_.addEventListener('save', this.save_.bind(this));
203 this.materialToolbar_.addEventListener('print', this.print_.bind(this)); 200 this.materialToolbar_.addEventListener('print', this.print_.bind(this));
204 this.materialToolbar_.addEventListener('rotate-right', 201 this.materialToolbar_.addEventListener('rotate-right',
205 this.rotateClockwise_.bind(this)); 202 this.rotateClockwise_.bind(this));
206 this.materialToolbar_.addEventListener('rotate-left', 203 this.materialToolbar_.addEventListener('rotate-left',
207 this.rotateCounterClockwise_.bind(this)); 204 this.rotateCounterClockwise_.bind(this));
208 205
209 document.body.addEventListener('change-page', function(e) { 206 document.body.addEventListener('change-page', function(e) {
210 this.viewport_.goToPage(e.detail.page); 207 this.viewport_.goToPage(e.detail.page);
211 }.bind(this)); 208 }.bind(this));
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 if (!this.isMaterial_) { 597 if (!this.isMaterial_) {
601 this.progressBar_.text = message.data.loadingString; 598 this.progressBar_.text = message.data.loadingString;
602 if (!this.isPrintPreview_) 599 if (!this.isPrintPreview_)
603 this.progressBar_.style.visibility = 'visible'; 600 this.progressBar_.style.visibility = 'visible';
604 } 601 }
605 this.errorScreen_.text = message.data.loadFailedString; 602 this.errorScreen_.text = message.data.loadFailedString;
606 break; 603 break;
607 case 'cancelStreamUrl': 604 case 'cancelStreamUrl':
608 chrome.mimeHandlerPrivate.abortStream(); 605 chrome.mimeHandlerPrivate.abortStream();
609 break; 606 break;
610 case 'bookmarks': 607 case 'metadata':
608 if (message.data.title) {
609 document.title = message.data.title;
610 } else {
611 document.title = decodeURIComponent(
612 getFilenameFromURL(this.browserApi_.getStreamInfo().originalUrl));
613 }
611 this.bookmarks_ = message.data.bookmarks; 614 this.bookmarks_ = message.data.bookmarks;
612 if (this.isMaterial_ && this.bookmarks_.length !== 0) 615 if (this.isMaterial_) {
616 this.materialToolbar_.docTitle = document.title;
613 this.materialToolbar_.bookmarks = this.bookmarks; 617 this.materialToolbar_.bookmarks = this.bookmarks;
618 }
614 break; 619 break;
615 case 'setIsSelecting': 620 case 'setIsSelecting':
616 this.viewportScroller_.setEnableScrolling(message.data.isSelecting); 621 this.viewportScroller_.setEnableScrolling(message.data.isSelecting);
617 break; 622 break;
618 case 'getNamedDestinationReply': 623 case 'getNamedDestinationReply':
619 this.paramsParser_.onNamedDestinationReceived( 624 this.paramsParser_.onNamedDestinationReceived(
620 message.data.pageNumber); 625 message.data.pageNumber);
621 break; 626 break;
622 } 627 }
623 }, 628 },
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 * Each bookmark is an Object containing a: 844 * Each bookmark is an Object containing a:
840 * - title 845 * - title
841 * - page (optional) 846 * - page (optional)
842 * - array of children (themselves bookmarks) 847 * - array of children (themselves bookmarks)
843 * @type {Array} the top-level bookmarks of the PDF. 848 * @type {Array} the top-level bookmarks of the PDF.
844 */ 849 */
845 get bookmarks() { 850 get bookmarks() {
846 return this.bookmarks_; 851 return this.bookmarks_;
847 } 852 }
848 }; 853 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698