OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // ========================================================== | |
6 // Enums. | |
7 // ========================================================== | |
8 /** | |
9 * The desired behavior for navigateContentWindow. | |
10 * @enum {string} | |
11 * @private | |
12 */ | |
13 var WindowOpenDisposition_ = { | |
samarth
2013/01/10 21:42:04
How come this doesn't match the other enum?
dougw
2013/01/18 23:54:30
Done.
| |
14 UNKNOWN: 'a', | |
15 SUPPRESS_OPEN: 'b', | |
16 CURRENT_TAB: 'c', | |
17 // Indicates that only one tab with the url should exist in the same window. | |
18 SINGLETON_TAB: 'd', | |
19 NEW_FOREGROUND_TAB: 'e', | |
20 NEW_BACKGROUND_TAB: 'f', | |
21 NEW_POPUP: 'g', | |
22 NEW_WINDOW: 'h', | |
23 SAVE_TO_DISK: 'i', | |
24 OFF_THE_RECORD: 'j', | |
25 IGNORE_ACTION: 'k' | |
26 }; | |
27 | |
5 // ============================================================================= | 28 // ============================================================================= |
6 // Util functions | 29 // Util functions |
7 // ============================================================================= | 30 // ============================================================================= |
8 | 31 |
9 // The maximum number of suggestions to show. | 32 // The maximum number of suggestions to show. |
10 var MAX_SUGGESTIONS_TO_SHOW = 5; | 33 var MAX_SUGGESTIONS_TO_SHOW = 5; |
11 | 34 |
12 /** | 35 /** |
13 * Displays a suggestion. | 36 * Displays a suggestion. |
14 * @param {Object} suggestion The suggestion to render. | 37 * @param {Object} suggestion The suggestion to render. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 } | 186 } |
164 | 187 |
165 /** | 188 /** |
166 * Handles suggestion clicks. | 189 * Handles suggestion clicks. |
167 * @param {integer} restrictedId The restricted id of the suggestion being | 190 * @param {integer} restrictedId The restricted id of the suggestion being |
168 * clicked. | 191 * clicked. |
169 */ | 192 */ |
170 function handleSuggestionClick(restrictedId) { | 193 function handleSuggestionClick(restrictedId) { |
171 var apiHandle = getApiObjectHandle(); | 194 var apiHandle = getApiObjectHandle(); |
172 clearSuggestions(); | 195 clearSuggestions(); |
173 apiHandle.navigateContentWindow(restrictedId); | 196 apiHandle.navigateContentWindow(restrictedId, |
197 WindowOpenDisposition_.CURRENT_TAB); | |
samarth
2013/01/10 21:42:04
Middle clicking should work correctly here as well
dougw
2013/01/18 23:54:30
I'd like to do this in a separate cl :)
| |
174 } | 198 } |
175 | 199 |
176 /** | 200 /** |
177 * chrome.searchBox.onkeypress implementation. | 201 * chrome.searchBox.onkeypress implementation. |
178 * @param {Object} e The key being pressed. | 202 * @param {Object} e The key being pressed. |
179 */ | 203 */ |
180 function handleKeyPress(e) { | 204 function handleKeyPress(e) { |
181 var apiHandle = getApiObjectHandle(); | 205 var apiHandle = getApiObjectHandle(); |
182 function callback(restrictedId) { | 206 function callback(restrictedId) { |
183 apiHandle.setRestrictedValue(restrictedId); | 207 apiHandle.setRestrictedValue(restrictedId); |
(...skipping 19 matching lines...) Expand all Loading... | |
203 * Sets up the searchBox API. | 227 * Sets up the searchBox API. |
204 */ | 228 */ |
205 function setUpApi() { | 229 function setUpApi() { |
206 var apiHandle = getApiObjectHandle(); | 230 var apiHandle = getApiObjectHandle(); |
207 apiHandle.onnativesuggestions = handleNativeSuggestions; | 231 apiHandle.onnativesuggestions = handleNativeSuggestions; |
208 apiHandle.onkeypress = handleKeyPress; | 232 apiHandle.onkeypress = handleKeyPress; |
209 apiHandle.onsubmit = onSubmit; | 233 apiHandle.onsubmit = onSubmit; |
210 } | 234 } |
211 | 235 |
212 document.addEventListener('DOMContentLoaded', setUpApi); | 236 document.addEventListener('DOMContentLoaded', setUpApi); |
OLD | NEW |