OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * @fileoverview This file provides a class that can be used to open URLs based | 6 * @fileoverview This file provides a class that can be used to open URLs based |
7 * on user interactions. It ensures a consistent behavior when it comes to | 7 * on user interactions. It ensures a consistent behavior when it comes to |
8 * holding down Ctrl and Shift while clicking or activating the a link. | 8 * holding down Ctrl and Shift while clicking or activating the a link. |
9 * | 9 * |
10 * This depends on the {@code chrome.windows} and {@code chrome.tabs} | 10 * This depends on the {@code chrome.windows} and {@code chrome.tabs} |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return this.localStrings_.getStringF('should_open_all', String(count)); | 74 return this.localStrings_.getStringF('should_open_all', String(count)); |
75 }, | 75 }, |
76 | 76 |
77 /** | 77 /** |
78 * Open an URL from a mouse or keyboard event. | 78 * Open an URL from a mouse or keyboard event. |
79 * @param {string} url The URL to open. | 79 * @param {string} url The URL to open. |
80 * @param {!Event} e The event triggering the opening of the URL. | 80 * @param {!Event} e The event triggering the opening of the URL. |
81 */ | 81 */ |
82 openUrlFromEvent: function(url, e) { | 82 openUrlFromEvent: function(url, e) { |
83 // We only support keydown Enter and non right click events. | 83 // We only support keydown Enter and non right click events. |
84 if (e.type == 'keydown' && e.keyIdentifier == 'Enter' || | 84 if (e.type == 'keydown' && e.key == 'Enter' || e.button != 2) { |
85 e.button != 2) { | |
86 var kind; | 85 var kind; |
87 var ctrl = cr.isMac && e.metaKey || !cr.isMac && e.ctrlKey; | 86 var ctrl = cr.isMac && e.metaKey || !cr.isMac && e.ctrlKey; |
88 | 87 |
89 if (e.button == 1 || ctrl) // middle, ctrl or keyboard | 88 if (e.button == 1 || ctrl) // middle, ctrl or keyboard |
90 kind = e.shiftKey ? cr.LinkKind.FOREGROUND_TAB : | 89 kind = e.shiftKey ? cr.LinkKind.FOREGROUND_TAB : |
91 cr.LinkKind.BACKGROUND_TAB; | 90 cr.LinkKind.BACKGROUND_TAB; |
92 else // left or keyboard | 91 else // left or keyboard |
93 kind = e.shiftKey ? cr.LinkKind.WINDOW : cr.LinkKind.SELF; | 92 kind = e.shiftKey ? cr.LinkKind.WINDOW : cr.LinkKind.SELF; |
94 | 93 |
95 this.openUrls([url], kind); | 94 this.openUrls([url], kind); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 this.window.location.href = urls[0]; | 144 this.window.location.href = urls[0]; |
146 } | 145 } |
147 } | 146 } |
148 }; | 147 }; |
149 | 148 |
150 // Export | 149 // Export |
151 return { | 150 return { |
152 LinkController: LinkController, | 151 LinkController: LinkController, |
153 }; | 152 }; |
154 }); | 153 }); |
OLD | NEW |