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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 function onNavigateInNewTab(url, active) { | 63 function onNavigateInNewTab(url, active) { |
64 // Prefer the tabs API because it guarantees we can just open a new tab. | 64 // Prefer the tabs API because it guarantees we can just open a new tab. |
65 // window.open doesn't have this guarantee. | 65 // window.open doesn't have this guarantee. |
66 if (chrome.tabs) | 66 if (chrome.tabs) |
67 chrome.tabs.create({url: url, active: active}); | 67 chrome.tabs.create({url: url, active: active}); |
68 else | 68 else |
69 window.open(url); | 69 window.open(url); |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
| 73 * Called when navigation happens in the new window. |
| 74 * @param {string} url The url to be opened in the new window. |
| 75 */ |
| 76 function onNavigateInNewWindow(url) { |
| 77 // Prefer the windows API because it guarantees we can just open a new window. |
| 78 // window.open with '_blank' argument doesn't have this guarantee. |
| 79 if (chrome.windows) |
| 80 chrome.windows.create({url: url}); |
| 81 else |
| 82 window.open(url, '_blank'); |
| 83 } |
| 84 |
| 85 /** |
73 * Whether keydown events should currently be ignored. Events are ignored when | 86 * Whether keydown events should currently be ignored. Events are ignored when |
74 * an editable element has focus, to allow for proper editing controls. | 87 * an editable element has focus, to allow for proper editing controls. |
75 * @param {HTMLElement} activeElement The currently selected DOM node. | 88 * @param {HTMLElement} activeElement The currently selected DOM node. |
76 * @return {boolean} True if keydown events should be ignored. | 89 * @return {boolean} True if keydown events should be ignored. |
77 */ | 90 */ |
78 function shouldIgnoreKeyEvents(activeElement) { | 91 function shouldIgnoreKeyEvents(activeElement) { |
79 while (activeElement.shadowRoot != null && | 92 while (activeElement.shadowRoot != null && |
80 activeElement.shadowRoot.activeElement != null) { | 93 activeElement.shadowRoot.activeElement != null) { |
81 activeElement = activeElement.shadowRoot.activeElement; | 94 activeElement = activeElement.shadowRoot.activeElement; |
82 } | 95 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); | 271 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); |
259 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); | 272 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); |
260 | 273 |
261 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; | 274 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; |
262 var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0; | 275 var isSourceFileUrl = this.originalUrl_.indexOf('file://') == 0; |
263 this.navigator_ = new Navigator(this.originalUrl_, | 276 this.navigator_ = new Navigator(this.originalUrl_, |
264 this.viewport_, this.paramsParser_, | 277 this.viewport_, this.paramsParser_, |
265 onNavigateInCurrentTab.bind(undefined, | 278 onNavigateInCurrentTab.bind(undefined, |
266 isInTab, | 279 isInTab, |
267 isSourceFileUrl), | 280 isSourceFileUrl), |
268 onNavigateInNewTab); | 281 onNavigateInNewTab, onNavigateInNewWindow); |
269 this.viewportScroller_ = | 282 this.viewportScroller_ = |
270 new ViewportScroller(this.viewport_, this.plugin_, window); | 283 new ViewportScroller(this.viewport_, this.plugin_, window); |
271 | 284 |
272 // Request translated strings. | 285 // Request translated strings. |
273 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); | 286 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); |
274 } | 287 } |
275 | 288 |
276 PDFViewer.prototype = { | 289 PDFViewer.prototype = { |
277 /** | 290 /** |
278 * @private | 291 * @private |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 * Each bookmark is an Object containing a: | 893 * Each bookmark is an Object containing a: |
881 * - title | 894 * - title |
882 * - page (optional) | 895 * - page (optional) |
883 * - array of children (themselves bookmarks) | 896 * - array of children (themselves bookmarks) |
884 * @type {Array} the top-level bookmarks of the PDF. | 897 * @type {Array} the top-level bookmarks of the PDF. |
885 */ | 898 */ |
886 get bookmarks() { | 899 get bookmarks() { |
887 return this.bookmarks_; | 900 return this.bookmarks_; |
888 } | 901 } |
889 }; | 902 }; |
OLD | NEW |