Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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_) { |
| 613 this.materialToolbar_.bookmarks = this.bookmarks; | 616 this.materialToolbar_.docTitle = document.title; |
| 617 if (this.bookmarks_.length !== 0) | |
|
raymes
2015/08/27 04:07:37
I wonder if we can remove this check safely?
Sam McNally
2015/08/27 04:18:48
I wondered the same thing. Unfortunately, without
Sam McNally
2015/08/27 04:43:31
Done.
| |
| 618 this.materialToolbar_.bookmarks = this.bookmarks; | |
| 619 } | |
| 614 break; | 620 break; |
| 615 case 'setIsSelecting': | 621 case 'setIsSelecting': |
| 616 this.viewportScroller_.setEnableScrolling(message.data.isSelecting); | 622 this.viewportScroller_.setEnableScrolling(message.data.isSelecting); |
| 617 break; | 623 break; |
| 618 case 'getNamedDestinationReply': | 624 case 'getNamedDestinationReply': |
| 619 this.paramsParser_.onNamedDestinationReceived( | 625 this.paramsParser_.onNamedDestinationReceived( |
| 620 message.data.pageNumber); | 626 message.data.pageNumber); |
| 621 break; | 627 break; |
| 622 } | 628 } |
| 623 }, | 629 }, |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 * Each bookmark is an Object containing a: | 845 * Each bookmark is an Object containing a: |
| 840 * - title | 846 * - title |
| 841 * - page (optional) | 847 * - page (optional) |
| 842 * - array of children (themselves bookmarks) | 848 * - array of children (themselves bookmarks) |
| 843 * @type {Array} the top-level bookmarks of the PDF. | 849 * @type {Array} the top-level bookmarks of the PDF. |
| 844 */ | 850 */ |
| 845 get bookmarks() { | 851 get bookmarks() { |
| 846 return this.bookmarks_; | 852 return this.bookmarks_; |
| 847 } | 853 } |
| 848 }; | 854 }; |
| OLD | NEW |