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

Side by Side Diff: chrome/renderer/resources/extensions/omnibox_custom_bindings.js

Issue 12314164: Modified Omnibox extension api to use JSON Schema Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced include with forward declaration Created 7 years, 8 months 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
« no previous file with comments | « chrome/common/extensions/api/omnibox.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Custom binding for the omnibox API. Only injected into the v8 contexts 5 // Custom binding for the omnibox API. Only injected into the v8 contexts
6 // for extensions which have permission for the omnibox API. 6 // for extensions which have permission for the omnibox API.
7 7
8 var binding = require('binding').Binding.create('omnibox'); 8 var binding = require('binding').Binding.create('omnibox');
9 9
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 }; 78 };
79 walk(root); 79 walk(root);
80 80
81 return result; 81 return result;
82 } 82 }
83 83
84 binding.registerCustomHook(function(bindingsAPI) { 84 binding.registerCustomHook(function(bindingsAPI) {
85 var apiFunctions = bindingsAPI.apiFunctions; 85 var apiFunctions = bindingsAPI.apiFunctions;
86 86
87 apiFunctions.setUpdateArgumentsPreValidate('setDefaultSuggestion',
88 function(suggestResult) {
89 if (suggestResult.content != undefined) { // null, etc.
90 throw new Error(
91 'setDefaultSuggestion cannot contain the "content" field');
92 }
93 suggestResult.content = '';
94 return [suggestResult];
95 });
96
87 apiFunctions.setHandleRequest('setDefaultSuggestion', function(details) { 97 apiFunctions.setHandleRequest('setDefaultSuggestion', function(details) {
88 var parseResult = parseOmniboxDescription(details.description); 98 var parseResult = parseOmniboxDescription(details.description);
89 sendRequest(this.name, [parseResult], this.definition.parameters); 99 sendRequest(this.name, [parseResult], this.definition.parameters);
90 }); 100 });
91 101
92 apiFunctions.setUpdateArgumentsPostValidate( 102 apiFunctions.setUpdateArgumentsPostValidate(
93 'sendSuggestions', function(requestId, userSuggestions) { 103 'sendSuggestions', function(requestId, userSuggestions) {
94 var suggestions = []; 104 var suggestions = [];
95 for (var i = 0; i < userSuggestions.length; i++) { 105 for (var i = 0; i < userSuggestions.length; i++) {
96 var parseResult = parseOmniboxDescription( 106 var parseResult = parseOmniboxDescription(
97 userSuggestions[i].description); 107 userSuggestions[i].description);
98 parseResult.content = userSuggestions[i].content; 108 parseResult.content = userSuggestions[i].content;
99 suggestions.push(parseResult); 109 suggestions.push(parseResult);
100 } 110 }
101 return [requestId, suggestions]; 111 return [requestId, suggestions];
102 }); 112 });
103 }); 113 });
104 114
105 chromeHidden.Event.registerArgumentMassager('omnibox.onInputChanged', 115 chromeHidden.Event.registerArgumentMassager('omnibox.onInputChanged',
106 function(args, dispatch) { 116 function(args, dispatch) {
107 var text = args[0]; 117 var text = args[0];
108 var requestId = args[1]; 118 var requestId = args[1];
109 var suggestCallback = function(suggestions) { 119 var suggestCallback = function(suggestions) {
110 chrome.omnibox.sendSuggestions(requestId, suggestions); 120 chrome.omnibox.sendSuggestions(requestId, suggestions);
111 }; 121 };
112 dispatch([text, suggestCallback]); 122 dispatch([text, suggestCallback]);
113 }); 123 });
114 124
115 exports.binding = binding.generate(); 125 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/omnibox.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698