| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 408 } |
| 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/connection', | 419 'mojo/public/js/connection', |
| 419 'chrome/browser/ui/webui/omnibox/omnibox.mojom', | 420 'chrome/browser/ui/webui/omnibox/omnibox.mojom', |
| 420 'content/public/renderer/frame_interfaces', | 421 'content/public/renderer/frame_interfaces', |
| 421 ]).then(function(modules) { | 422 ]).then(function(modules) { |
| 422 var connection = modules[0]; | 423 var bindings = modules[0]; |
| 423 var mojom = modules[1]; | 424 var connection = modules[1]; |
| 424 var frameInterfaces = modules[2]; | 425 var mojom = modules[2]; |
| 426 var frameInterfaces = modules[3]; |
| 425 | 427 |
| 426 browserProxy = connection.bindHandleToProxy( | 428 browserProxy = connection.bindHandleToProxy( |
| 427 frameInterfaces.getInterface(mojom.OmniboxPageHandler.name), | 429 frameInterfaces.getInterface(mojom.OmniboxPageHandler.name), |
| 428 mojom.OmniboxPageHandler); | 430 mojom.OmniboxPageHandler); |
| 429 | 431 |
| 430 /** @constructor */ | 432 /** @constructor */ |
| 431 var OmniboxPageImpl = function() {}; | 433 var OmniboxPageImpl = function() { |
| 434 this.binding = new bindings.Binding(mojom.OmniboxPage, this); |
| 435 }; |
| 432 | 436 |
| 433 OmniboxPageImpl.prototype = { | 437 OmniboxPageImpl.prototype = { |
| 434 __proto__: mojom.OmniboxPage.stubClass.prototype, | |
| 435 | |
| 436 /** @override */ | 438 /** @override */ |
| 437 handleNewAutocompleteResult: function(result) { | 439 handleNewAutocompleteResult: function(result) { |
| 438 progressiveAutocompleteResults.push(result); | 440 progressiveAutocompleteResults.push(result); |
| 439 refresh(); | 441 refresh(); |
| 440 }, | 442 }, |
| 441 }; | 443 }; |
| 442 | 444 |
| 443 pageImpl = new OmniboxPageImpl(); | 445 pageImpl = new OmniboxPageImpl(); |
| 444 | 446 browserProxy.setClientPage(pageImpl.binding.createInterfacePtrAndBind()); |
| 445 // Create a message pipe, with one end of the pipe already connected to | |
| 446 // JS. | |
| 447 var handle = connection.bindStubDerivedImpl(pageImpl); | |
| 448 // Send the other end of the pipe to C++. | |
| 449 browserProxy.setClientPage(handle); | |
| 450 }); | 447 }); |
| 451 } | 448 } |
| 452 | 449 |
| 453 document.addEventListener('DOMContentLoaded', function() { | 450 document.addEventListener('DOMContentLoaded', function() { |
| 454 return initializeProxies().then(function() { | 451 return initializeProxies().then(function() { |
| 455 initialize(); | 452 initialize(); |
| 456 }); | 453 }); |
| 457 }); | 454 }); |
| 458 })(); | 455 })(); |
| OLD | NEW |