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 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * 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 |
| 41 * document. | 41 * document. |
| 42 * @param {Object} streamDetails The stream object which points to the data | 42 * @param {Object} streamDetails The stream object which points to the data |
| 43 * contained in the PDF. | 43 * contained in the PDF. |
| 44 */ | 44 */ |
| 45 function PDFViewer(streamDetails) { | 45 function PDFViewer(streamDetails) { |
| 46 this.streamDetails = streamDetails; | 46 this.streamDetails = streamDetails; |
| 47 this.loaded = false; | 47 this.loaded = false; |
| 48 this.bookmarksLoaded = false; | |
| 48 | 49 |
| 49 // The sizer element is placed behind the plugin element to cause scrollbars | 50 // The sizer element is placed behind the plugin element to cause scrollbars |
| 50 // to be displayed in the window. It is sized according to the document size | 51 // to be displayed in the window. It is sized according to the document size |
| 51 // of the pdf and zoom level. | 52 // of the pdf and zoom level. |
| 52 this.sizer_ = $('sizer'); | 53 this.sizer_ = $('sizer'); |
| 53 this.toolbar_ = $('toolbar'); | 54 this.toolbar_ = $('toolbar'); |
| 54 this.pageIndicator_ = $('page-indicator'); | 55 this.pageIndicator_ = $('page-indicator'); |
| 55 this.progressBar_ = $('progress-bar'); | 56 this.progressBar_ = $('progress-bar'); |
| 56 this.passwordScreen_ = $('password-screen'); | 57 this.passwordScreen_ = $('password-screen'); |
| 57 this.passwordScreen_.addEventListener('password-submitted', | 58 this.passwordScreen_.addEventListener('password-submitted', |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 this.passwordScreen_.text = message.data.getPasswordString; | 415 this.passwordScreen_.text = message.data.getPasswordString; |
| 415 this.progressBar_.text = message.data.loadingString; | 416 this.progressBar_.text = message.data.loadingString; |
| 416 this.progressBar_.style.visibility = 'visible'; | 417 this.progressBar_.style.visibility = 'visible'; |
| 417 this.errorScreen_.text = message.data.loadFailedString; | 418 this.errorScreen_.text = message.data.loadFailedString; |
| 418 break; | 419 break; |
| 419 case 'cancelStreamUrl': | 420 case 'cancelStreamUrl': |
| 420 chrome.streamsPrivate.abort(this.streamDetails.streamUrl); | 421 chrome.streamsPrivate.abort(this.streamDetails.streamUrl); |
| 421 break; | 422 break; |
| 422 case 'bookmarks': | 423 case 'bookmarks': |
| 423 this.bookmarks = message.data.bookmarks; | 424 this.bookmarks = message.data.bookmarks; |
| 424 console.log(this.bookmarks); | 425 this.bookmarksLoaded = true; |
| 426 var loadEvent = new Event('bookmarksload'); | |
| 427 window.dispatchEvent(loadEvent); | |
| 428 this.sendScriptingMessage_({ | |
| 429 type: 'bookmarksLoaded' | |
| 430 }); | |
|
raymes
2015/01/06 05:52:29
if we ensure that bookmark information is sent her
raymes
2015/01/13 07:25:12
(we also wouldn't need the bookmarksLoaded member
Alexandre Carlton
2015/01/15 05:01:41
Done.
| |
| 425 break; | 431 break; |
| 426 } | 432 } |
| 427 }, | 433 }, |
| 428 | 434 |
| 429 /** | 435 /** |
| 430 * @private | 436 * @private |
| 431 * A callback that's called before the zoom changes. Notify the plugin to stop | 437 * A callback that's called before the zoom changes. Notify the plugin to stop |
| 432 * reacting to scroll events while zoom is taking place to avoid flickering. | 438 * reacting to scroll events while zoom is taking place to avoid flickering. |
| 433 */ | 439 */ |
| 434 beforeZoom_: function() { | 440 beforeZoom_: function() { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 this.streamDetails.tabId != -1); | 613 this.streamDetails.tabId != -1); |
| 608 }, | 614 }, |
| 609 | 615 |
| 610 /** | 616 /** |
| 611 * @type {Viewport} the viewport of the PDF viewer. | 617 * @type {Viewport} the viewport of the PDF viewer. |
| 612 */ | 618 */ |
| 613 get viewport() { | 619 get viewport() { |
| 614 return this.viewport_; | 620 return this.viewport_; |
| 615 } | 621 } |
| 616 }; | 622 }; |
| OLD | NEW |