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 23 matching lines...) Expand all Loading... | |
| 34 return decodeURIComponent(filename); | 34 return decodeURIComponent(filename); |
| 35 } catch (e) { | 35 } catch (e) { |
| 36 if (e instanceof URIError) | 36 if (e instanceof URIError) |
| 37 return filename; | 37 return filename; |
| 38 throw e; | 38 throw e; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Called when navigation happens in the current tab. | 43 * Called when navigation happens in the current tab. |
| 44 * @param {number} tabId The id of the current tab; -1 if no current tab. | |
| 44 * @param {string} url The url to be opened in the current tab. | 45 * @param {string} url The url to be opened in the current tab. |
| 45 */ | 46 */ |
| 46 function onNavigateInCurrentTab(url) { | 47 function onNavigateInCurrentTab(tabId, url) { |
| 47 // Prefer the tabs API because it can navigate from one file:// URL to | 48 // When the PDFviewer is not inside a <webview>, prefer the tabs API because |
| 48 // another. | 49 // it can navigate from one file:// URL to another. |
| 49 if (chrome.tabs) | 50 if (chrome.tabs && tabId != -1) |
|
Dan Beam
2015/09/28 15:59:11
are you using tabId == -1 basically as a check to
wjmaclean
2015/09/28 16:10:09
We could change it to
@param {boolean} inTab
pe
raymes
2015/09/29 01:46:27
I agree - there might be other cases where we don'
| |
| 50 chrome.tabs.update({url: url}); | 51 chrome.tabs.update(tabId, {url: url}); |
| 51 else | 52 else |
| 52 window.location.href = url; | 53 window.location.href = url; |
| 53 } | 54 } |
| 54 | 55 |
| 55 /** | 56 /** |
| 56 * Called when navigation happens in the new tab. | 57 * Called when navigation happens in the new tab. |
| 57 * @param {string} url The url to be opened in the new tab. | 58 * @param {string} url The url to be opened in the new tab. |
| 58 */ | 59 */ |
| 59 function onNavigateInNewTab(url) { | 60 function onNavigateInNewTab(url) { |
| 60 // Prefer the tabs API because it guarantees we can just open a new tab. | 61 // Prefer the tabs API because it guarantees we can just open a new tab. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 | 246 |
| 246 // Setup the keyboard event listener. | 247 // Setup the keyboard event listener. |
| 247 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); | 248 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); |
| 248 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); | 249 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); |
| 249 | 250 |
| 250 // Parse open pdf parameters. | 251 // Parse open pdf parameters. |
| 251 this.paramsParser_ = | 252 this.paramsParser_ = |
| 252 new OpenPDFParamsParser(this.getNamedDestination_.bind(this)); | 253 new OpenPDFParamsParser(this.getNamedDestination_.bind(this)); |
| 253 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, | 254 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, |
| 254 this.viewport_, this.paramsParser_, | 255 this.viewport_, this.paramsParser_, |
| 255 onNavigateInCurrentTab, onNavigateInNewTab); | 256 onNavigateInCurrentTab.bind(undefined, |
| 257 this.browserApi_.getStreamInfo().tabId), | |
|
Dan Beam
2015/09/28 15:59:12
wait, don't you *want* this to use the current tab
wjmaclean
2015/09/28 16:10:08
Well, yes, I think we would. However, it's not at
raymes
2015/09/29 01:46:27
Correct - the tabId will never change.
| |
| 258 onNavigateInNewTab); | |
| 256 this.viewportScroller_ = | 259 this.viewportScroller_ = |
| 257 new ViewportScroller(this.viewport_, this.plugin_, window); | 260 new ViewportScroller(this.viewport_, this.plugin_, window); |
| 258 } | 261 } |
| 259 | 262 |
| 260 PDFViewer.prototype = { | 263 PDFViewer.prototype = { |
| 261 /** | 264 /** |
| 262 * @private | 265 * @private |
| 263 * Handle key events. These may come from the user directly or via the | 266 * Handle key events. These may come from the user directly or via the |
| 264 * scripting API. | 267 * scripting API. |
| 265 * @param {KeyboardEvent} e the event to handle. | 268 * @param {KeyboardEvent} e the event to handle. |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 * Each bookmark is an Object containing a: | 875 * Each bookmark is an Object containing a: |
| 873 * - title | 876 * - title |
| 874 * - page (optional) | 877 * - page (optional) |
| 875 * - array of children (themselves bookmarks) | 878 * - array of children (themselves bookmarks) |
| 876 * @type {Array} the top-level bookmarks of the PDF. | 879 * @type {Array} the top-level bookmarks of the PDF. |
| 877 */ | 880 */ |
| 878 get bookmarks() { | 881 get bookmarks() { |
| 879 return this.bookmarks_; | 882 return this.bookmarks_; |
| 880 } | 883 } |
| 881 }; | 884 }; |
| OLD | NEW |