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 17 matching lines...) Expand all Loading... |
28 function getFilenameFromURL(url) { | 28 function getFilenameFromURL(url) { |
29 var components = url.split(/\/|\\/); | 29 var components = url.split(/\/|\\/); |
30 return components[components.length - 1]; | 30 return components[components.length - 1]; |
31 } | 31 } |
32 | 32 |
33 /** | 33 /** |
34 * Called when navigation happens in the current tab. | 34 * Called when navigation happens in the current tab. |
35 * @param {string} url The url to be opened in the current tab. | 35 * @param {string} url The url to be opened in the current tab. |
36 */ | 36 */ |
37 function onNavigateInCurrentTab(url) { | 37 function onNavigateInCurrentTab(url) { |
38 window.location.href = url; | 38 // Prefer the tabs API because it can navigate from one file:// URL to |
| 39 // another. |
| 40 if (chrome.tabs) |
| 41 chrome.tabs.update({url: url}); |
| 42 else |
| 43 window.location.href = url; |
39 } | 44 } |
40 | 45 |
41 /** | 46 /** |
42 * Called when navigation happens in the new tab. | 47 * Called when navigation happens in the new tab. |
43 * @param {string} url The url to be opened in the new tab. | 48 * @param {string} url The url to be opened in the new tab. |
44 */ | 49 */ |
45 function onNavigateInNewTab(url) { | 50 function onNavigateInNewTab(url) { |
46 // Prefer the tabs API because it guarantees we can just open a new tab. | 51 // Prefer the tabs API because it guarantees we can just open a new tab. |
47 // window.open doesn't have this guarantee. | 52 // window.open doesn't have this guarantee. |
48 if (chrome.tabs) | 53 if (chrome.tabs) |
49 chrome.tabs.create({ url: url}); | 54 chrome.tabs.create({url: url}); |
50 else | 55 else |
51 window.open(url); | 56 window.open(url); |
52 } | 57 } |
53 | 58 |
54 /** | 59 /** |
55 * Whether keydown events should currently be ignored. Events are ignored when | 60 * Whether keydown events should currently be ignored. Events are ignored when |
56 * an editable element has focus, to allow for proper editing controls. | 61 * an editable element has focus, to allow for proper editing controls. |
57 * @param {HTMLElement} activeElement The currently selected DOM node. | 62 * @param {HTMLElement} activeElement The currently selected DOM node. |
58 * @return {boolean} True if keydown events should be ignored. | 63 * @return {boolean} True if keydown events should be ignored. |
59 */ | 64 */ |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 * Each bookmark is an Object containing a: | 822 * Each bookmark is an Object containing a: |
818 * - title | 823 * - title |
819 * - page (optional) | 824 * - page (optional) |
820 * - array of children (themselves bookmarks) | 825 * - array of children (themselves bookmarks) |
821 * @type {Array} the top-level bookmarks of the PDF. | 826 * @type {Array} the top-level bookmarks of the PDF. |
822 */ | 827 */ |
823 get bookmarks() { | 828 get bookmarks() { |
824 return this.bookmarks_; | 829 return this.bookmarks_; |
825 } | 830 } |
826 }; | 831 }; |
OLD | NEW |