| 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 * Javascript for omnibox.html, served from chrome://omnibox/ | 6 * Javascript for omnibox.html, served from chrome://omnibox/ |
| 7 * This is used to debug omnibox ranking. The user enters some text | 7 * This is used to debug omnibox ranking. The user enters some text |
| 8 * into a box, submits it, and then sees lots of debug information | 8 * into a box, submits it, and then sees lots of debug information |
| 9 * from the autocompleter that shows what omnibox would do with that | 9 * from the autocompleter that shows what omnibox would do with that |
| 10 * input. | 10 * input. |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 // Display the results. | 400 // Display the results. |
| 401 var showIncompleteResults = $('show-incomplete-results').checked; | 401 var showIncompleteResults = $('show-incomplete-results').checked; |
| 402 var startIndex = showIncompleteResults ? 0 : | 402 var startIndex = showIncompleteResults ? 0 : |
| 403 progressiveAutocompleteResults.length - 1; | 403 progressiveAutocompleteResults.length - 1; |
| 404 for (var i = startIndex; i < progressiveAutocompleteResults.length; i++) { | 404 for (var i = startIndex; i < progressiveAutocompleteResults.length; i++) { |
| 405 addResultToOutput(progressiveAutocompleteResults[i]); | 405 addResultToOutput(progressiveAutocompleteResults[i]); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 /** | |
| 411 * Helper to convert callback-based define() API to a promise-based API. | |
| 412 * @param {!Array<string>} moduleNames | |
| 413 * @return {!Promise} | |
| 414 */ | |
| 415 function importModules(moduleNames) { | |
| 416 return new Promise(function(resolve, reject) { | |
| 417 define(moduleNames, function(var_args) { | |
| 418 resolve(Array.prototype.slice.call(arguments, 0)); | |
| 419 }); | |
| 420 }); | |
| 421 } | |
| 422 | |
| 423 // NOTE: Need to keep a global reference to the |pageImpl| such that it is not | 410 // NOTE: Need to keep a global reference to the |pageImpl| such that it is not |
| 424 // garbage collected, which causes the pipe to close and future calls from C++ | 411 // garbage collected, which causes the pipe to close and future calls from C++ |
| 425 // to JS to get dropped. | 412 // to JS to get dropped. |
| 426 var pageImpl = null; | 413 var pageImpl = null; |
| 427 var browserProxy = null; | 414 var browserProxy = null; |
| 428 | 415 |
| 429 function initializeProxies() { | 416 function initializeProxies() { |
| 430 return importModules([ | 417 return importModules([ |
| 431 'mojo/public/js/connection', | 418 'mojo/public/js/connection', |
| 432 'chrome/browser/ui/webui/omnibox/omnibox.mojom', | 419 'chrome/browser/ui/webui/omnibox/omnibox.mojom', |
| (...skipping 29 matching lines...) Expand all Loading... |
| 462 browserProxy.setClientPage(handle); | 449 browserProxy.setClientPage(handle); |
| 463 }); | 450 }); |
| 464 } | 451 } |
| 465 | 452 |
| 466 document.addEventListener('DOMContentLoaded', function() { | 453 document.addEventListener('DOMContentLoaded', function() { |
| 467 return initializeProxies().then(function() { | 454 return initializeProxies().then(function() { |
| 468 initialize(); | 455 initialize(); |
| 469 }); | 456 }); |
| 470 }); | 457 }); |
| 471 })(); | 458 })(); |
| OLD | NEW |