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

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

Issue 10890002: Make V8ValueConverter.FromV8Value behave similarly to JSON.stringify (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use the actual objects, not empty objects Created 8 years, 3 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 | Annotate | Revision Log
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 bindings for the contextMenus API. 5 // Custom bindings for the contextMenus API.
6 6
7 var contextMenus = requireNative('context_menus'); 7 var contextMenus = requireNative('context_menus');
8 var GetNextContextMenuId = contextMenus.GetNextContextMenuId; 8 var GetNextContextMenuId = contextMenus.GetNextContextMenuId;
9 var sendRequest = require('sendRequest').sendRequest; 9 var sendRequest = require('sendRequest').sendRequest;
10 10
(...skipping 30 matching lines...) Expand all
41 if (onclick) { 41 if (onclick) {
42 onclick.apply(null, arguments); 42 onclick.apply(null, arguments);
43 } 43 }
44 }); 44 });
45 }; 45 };
46 46
47 apiFunctions.setHandleRequest('create', function() { 47 apiFunctions.setHandleRequest('create', function() {
48 var args = arguments; 48 var args = arguments;
49 var id = GetNextContextMenuId(); 49 var id = GetNextContextMenuId();
50 args[0].generatedId = id; 50 args[0].generatedId = id;
51 sendRequest(this.name, 51 var optArgs = {
52 args, 52 customCallback: this.customCallback,
53 this.definition.parameters, 53 // Functions aren't usually serializable, but the browser needs to know
54 {customCallback: this.customCallback}); 54 // if there's an onclick handler, so convert it to an object.
55 // TODO(kalman): write this custom binding in such a way that we don't.
56 allowFunctionsInObjects: true
57 };
58 sendRequest(this.name, args, this.definition.parameters, optArgs);
55 return chromeHidden.contextMenus.getIdFromCreateProperties(args[0]); 59 return chromeHidden.contextMenus.getIdFromCreateProperties(args[0]);
56 }); 60 });
57 61
58 apiFunctions.setCustomCallback('create', function(name, request, response) { 62 apiFunctions.setCustomCallback('create', function(name, request, response) {
59 if (chrome.runtime.lastError) { 63 if (chrome.runtime.lastError) {
60 return; 64 return;
61 } 65 }
62 66
63 var id = chromeHidden.contextMenus.getIdFromCreateProperties( 67 var id = chromeHidden.contextMenus.getIdFromCreateProperties(
64 request.args[0]); 68 request.args[0]);
(...skipping 26 matching lines...) Expand all
91 95
92 apiFunctions.setCustomCallback('removeAll', 96 apiFunctions.setCustomCallback('removeAll',
93 function(name, request, response) { 97 function(name, request, response) {
94 if (chrome.runtime.lastError) { 98 if (chrome.runtime.lastError) {
95 return; 99 return;
96 } 100 }
97 chromeHidden.contextMenus.generatedIdHandlers = {}; 101 chromeHidden.contextMenus.generatedIdHandlers = {};
98 chromeHidden.contextMenus.stringIdHandlers = {}; 102 chromeHidden.contextMenus.stringIdHandlers = {};
99 }); 103 });
100 }); 104 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698