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 * Possible behaviors for navigateContentWindow. | |
10 * @enum {number} | |
11 * @private | |
12 */ | |
13 var WindowOpenDisposition_ = { | |
14 CURRENT_TAB: 1, | |
15 NEW_BACKGROUND_TAB: 2 | |
16 }; | |
17 | |
18 // ========================================================== | |
19 // Component dependencies. | |
sreeram
2013/01/22 06:01:19
Huh? That's a strange name. Also, why define this
samarth
2013/01/22 16:13:32
Agreed. As you have it right now, you could just l
dougw
2013/01/24 03:05:25
Done.
dougw
2013/01/24 03:05:25
Done.
| |
20 // ========================================================== | |
21 /** | |
22 * @type {number} | |
23 * @private | |
24 * @const | |
25 */ | |
26 var MIDDLE_MOUSE_BUTTON_ = 1; | |
27 | |
5 // ============================================================================= | 28 // ============================================================================= |
6 // Util functions | 29 // Util functions |
7 // ============================================================================= | 30 // ============================================================================= |
8 | 31 |
9 /** | 32 /** |
10 * The maximum number of suggestions to show. | 33 * The maximum number of suggestions to show. |
11 * @type {number} | 34 * @type {number} |
12 * @const | 35 * @const |
13 */ | 36 */ |
14 var MAX_SUGGESTIONS_TO_SHOW = 5; | 37 var MAX_SUGGESTIONS_TO_SHOW = 5; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 document.querySelector('head').appendChild(style); | 218 document.querySelector('head').appendChild(style); |
196 } | 219 } |
197 | 220 |
198 /** | 221 /** |
199 * Handles suggestion clicks. | 222 * Handles suggestion clicks. |
200 * @param {integer} restrictedId The restricted id of the suggestion being | 223 * @param {integer} restrictedId The restricted id of the suggestion being |
201 * clicked. | 224 * clicked. |
202 */ | 225 */ |
203 function handleSuggestionClick(restrictedId) { | 226 function handleSuggestionClick(restrictedId) { |
204 clearSuggestions(); | 227 clearSuggestions(); |
205 getApiObjectHandle().navigateContentWindow(restrictedId); | 228 var disposition = WindowOpenDisposition_.CURRENT_TAB; |
229 getApiObjectHandle().navigateContentWindow( | |
230 restrictedId, disposition); | |
206 } | 231 } |
207 | 232 |
208 /** | 233 /** |
209 * chrome.searchBox.onkeypress implementation. | 234 * chrome.searchBox.onkeypress implementation. |
210 * @param {Object} e The key being pressed. | 235 * @param {Object} e The key being pressed. |
211 */ | 236 */ |
212 function handleKeyPress(e) { | 237 function handleKeyPress(e) { |
213 switch (e.keyCode) { | 238 switch (e.keyCode) { |
214 case 38: // Up arrow | 239 case 38: // Up arrow |
215 updateSelectedSuggestion(false); | 240 updateSelectedSuggestion(false); |
(...skipping 14 matching lines...) Expand all Loading... | |
230 * Sets up the searchBox API. | 255 * Sets up the searchBox API. |
231 */ | 256 */ |
232 function setUpApi() { | 257 function setUpApi() { |
233 var apiHandle = getApiObjectHandle(); | 258 var apiHandle = getApiObjectHandle(); |
234 apiHandle.onnativesuggestions = handleNativeSuggestions; | 259 apiHandle.onnativesuggestions = handleNativeSuggestions; |
235 apiHandle.onkeypress = handleKeyPress; | 260 apiHandle.onkeypress = handleKeyPress; |
236 apiHandle.onsubmit = onSubmit; | 261 apiHandle.onsubmit = onSubmit; |
237 } | 262 } |
238 | 263 |
239 document.addEventListener('DOMContentLoaded', setUpApi); | 264 document.addEventListener('DOMContentLoaded', setUpApi); |
OLD | NEW |