| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 // 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 |
| 411 // 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++ |
| 412 // to JS to get dropped. | 412 // to JS to get dropped. |
| 413 var pageImpl = null; | 413 var pageImpl = null; |
| 414 var browserProxy = null; | 414 var browserProxy = null; |
| 415 | 415 |
| 416 function initializeProxies() { | 416 function initializeProxies() { |
| 417 return importModules([ | 417 return importModules([ |
| 418 'mojo/public/js/bindings', | 418 'mojo/public/js/bindings', |
| 419 'mojo/public/js/connection', | |
| 420 'chrome/browser/ui/webui/omnibox/omnibox.mojom', | 419 'chrome/browser/ui/webui/omnibox/omnibox.mojom', |
| 421 'content/public/renderer/frame_interfaces', | 420 'content/public/renderer/frame_interfaces', |
| 422 ]).then(function(modules) { | 421 ]).then(function(modules) { |
| 423 var bindings = modules[0]; | 422 var bindings = modules[0]; |
| 424 var connection = modules[1]; | 423 var mojom = modules[1]; |
| 425 var mojom = modules[2]; | 424 var frameInterfaces = modules[2]; |
| 426 var frameInterfaces = modules[3]; | |
| 427 | 425 |
| 428 browserProxy = connection.bindHandleToProxy( | 426 browserProxy = new mojom.OmniboxPageHandlerPtr( |
| 429 frameInterfaces.getInterface(mojom.OmniboxPageHandler.name), | 427 frameInterfaces.getInterface(mojom.OmniboxPageHandler.name)); |
| 430 mojom.OmniboxPageHandler); | |
| 431 | 428 |
| 432 /** @constructor */ | 429 /** @constructor */ |
| 433 var OmniboxPageImpl = function() { | 430 var OmniboxPageImpl = function() { |
| 434 this.binding = new bindings.Binding(mojom.OmniboxPage, this); | 431 this.binding = new bindings.Binding(mojom.OmniboxPage, this); |
| 435 }; | 432 }; |
| 436 | 433 |
| 437 OmniboxPageImpl.prototype = { | 434 OmniboxPageImpl.prototype = { |
| 438 /** @override */ | 435 /** @override */ |
| 439 handleNewAutocompleteResult: function(result) { | 436 handleNewAutocompleteResult: function(result) { |
| 440 progressiveAutocompleteResults.push(result); | 437 progressiveAutocompleteResults.push(result); |
| 441 refresh(); | 438 refresh(); |
| 442 }, | 439 }, |
| 443 }; | 440 }; |
| 444 | 441 |
| 445 pageImpl = new OmniboxPageImpl(); | 442 pageImpl = new OmniboxPageImpl(); |
| 446 browserProxy.setClientPage(pageImpl.binding.createInterfacePtrAndBind()); | 443 browserProxy.setClientPage(pageImpl.binding.createInterfacePtrAndBind()); |
| 447 }); | 444 }); |
| 448 } | 445 } |
| 449 | 446 |
| 450 document.addEventListener('DOMContentLoaded', function() { | 447 document.addEventListener('DOMContentLoaded', function() { |
| 451 return initializeProxies().then(function() { | 448 return initializeProxies().then(function() { |
| 452 initialize(); | 449 initialize(); |
| 453 }); | 450 }); |
| 454 }); | 451 }); |
| 455 })(); | 452 })(); |
| OLD | NEW |