Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/resources/omnibox/omnibox.js

Issue 2470063003: Move importModules function to util.js (Closed)
Patch Set: Add suppress Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/bluetooth_internals/bluetooth_internals.js ('k') | chrome/browser/resources/plugins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698