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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) { | 49 function onNavigateInCurrentTab(isInTab, isSourceFileUrl, url) { |
| 50 // When the PDFviewer is inside a browser tab, prefer the tabs API because | 50 // When the PDFviewer is inside a browser tab, prefer the tabs API because |
| 51 // it can navigate from one file:// URL to another. | 51 // it can navigate from one file:// URL to another. |
| 52 if (chrome.tabs && isInTab && isSourceFileUrl) | 52 if (chrome.tabs && isInTab && isSourceFileUrl) |
| 53 chrome.tabs.update({url: url}); | 53 chrome.tabs.update({url: url}); |
| 54 else | 54 else |
| 55 window.location.href = url; | 55 window.location.href = url; |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Called when navigation happens in the new tab. | 59 * Called when navigation happens in the new background tab. |
| 60 * @param {string} url The url to be opened in the new tab. | 60 * @param {string} url The url to be opened in the new background tab. |
| 61 */ | 61 */ |
| 62 function onNavigateInNewTab(url) { | 62 function onNavigateInNewBackgroundTab(url) { |
| 63 // Prefer the tabs API because it guarantees we can just open a new tab. | 63 // Prefer the tabs API because it guarantees we can just open a new tab. |
| 64 // window.open doesn't have this guarantee. | 64 // window.open doesn't have this guarantee. |
| 65 if (chrome.tabs) | 65 if (chrome.tabs) |
| 66 chrome.tabs.create({url: url}); | 66 chrome.tabs.create({url: url, active: false}); |
| 67 else | 67 else |
| 68 window.open(url); | 68 window.open(url); |
|
jaepark
2016/07/14 22:52:39
I wasn't able to find a way to create a new backgr
Lei Zhang
2016/07/14 22:57:52
I think this is just best effort.
jaepark
2016/07/15 00:23:56
Acknowledged.
| |
| 69 } | 69 } |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * Whether keydown events should currently be ignored. Events are ignored when | 72 * Whether keydown events should currently be ignored. Events are ignored when |
| 73 * an editable element has focus, to allow for proper editing controls. | 73 * an editable element has focus, to allow for proper editing controls. |
| 74 * @param {HTMLElement} activeElement The currently selected DOM node. | 74 * @param {HTMLElement} activeElement The currently selected DOM node. |
| 75 * @return {boolean} True if keydown events should be ignored. | 75 * @return {boolean} True if keydown events should be ignored. |
| 76 */ | 76 */ |
| 77 function shouldIgnoreKeyEvents(activeElement) { | 77 function shouldIgnoreKeyEvents(activeElement) { |
| 78 while (activeElement.shadowRoot != null && | 78 while (activeElement.shadowRoot != null && |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); | 257 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); |
| 258 | 258 |
| 259 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; | 259 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; |
| 260 var isSourceFileUrl = | 260 var isSourceFileUrl = |
| 261 this.originalUrl_.indexOf('file://') == 0; | 261 this.originalUrl_.indexOf('file://') == 0; |
| 262 this.navigator_ = new Navigator(this.originalUrl_, | 262 this.navigator_ = new Navigator(this.originalUrl_, |
| 263 this.viewport_, this.paramsParser_, | 263 this.viewport_, this.paramsParser_, |
| 264 onNavigateInCurrentTab.bind(undefined, | 264 onNavigateInCurrentTab.bind(undefined, |
| 265 isInTab, | 265 isInTab, |
| 266 isSourceFileUrl), | 266 isSourceFileUrl), |
| 267 onNavigateInNewTab); | 267 onNavigateInNewBackgroundTab); |
| 268 this.viewportScroller_ = | 268 this.viewportScroller_ = |
| 269 new ViewportScroller(this.viewport_, this.plugin_, window); | 269 new ViewportScroller(this.viewport_, this.plugin_, window); |
| 270 | 270 |
| 271 // Request translated strings. | 271 // Request translated strings. |
| 272 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); | 272 chrome.resourcesPrivate.getStrings('pdf', this.handleStrings_.bind(this)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 PDFViewer.prototype = { | 275 PDFViewer.prototype = { |
| 276 /** | 276 /** |
| 277 * @private | 277 * @private |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 * Each bookmark is an Object containing a: | 878 * Each bookmark is an Object containing a: |
| 879 * - title | 879 * - title |
| 880 * - page (optional) | 880 * - page (optional) |
| 881 * - array of children (themselves bookmarks) | 881 * - array of children (themselves bookmarks) |
| 882 * @type {Array} the top-level bookmarks of the PDF. | 882 * @type {Array} the top-level bookmarks of the PDF. |
| 883 */ | 883 */ |
| 884 get bookmarks() { | 884 get bookmarks() { |
| 885 return this.bookmarks_; | 885 return this.bookmarks_; |
| 886 } | 886 } |
| 887 }; | 887 }; |
| OLD | NEW |