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

Side by Side Diff: chrome/renderer/extensions/event_bindings.cc

Issue 173034: Validation of extension api callback and event parameters in DEBUG (Closed)
Patch Set: build docs Created 11 years, 4 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/renderer/extensions/event_bindings.h" 5 #include "chrome/renderer/extensions/event_bindings.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 // static 282 // static
283 void EventBindings::CallFunction(const std::string& function_name, 283 void EventBindings::CallFunction(const std::string& function_name,
284 int argc, v8::Handle<v8::Value>* argv, 284 int argc, v8::Handle<v8::Value>* argv,
285 RenderView* render_view) { 285 RenderView* render_view) {
286 for (ContextList::iterator it = GetContexts().begin(); 286 for (ContextList::iterator it = GetContexts().begin();
287 it != GetContexts().end(); ++it) { 287 it != GetContexts().end(); ++it) {
288 if (render_view && render_view != (*it)->render_view) 288 if (render_view && render_view != (*it)->render_view)
289 continue; 289 continue;
290 CallFunctionInContext((*it)->context, function_name, argc, argv); 290 v8::Handle<v8::Value> retval = CallFunctionInContext((*it)->context,
291 function_name, argc, argv);
292 // In debug, the js will validate the event parameters and return a
293 // string if a validation error has occured.
294 // TODO(rafaelw): Consider only doing this check if function_name ==
295 // "Event.dispatchJSON".
296 #ifdef _DEBUG
297 if (!retval.IsEmpty() && !retval->IsUndefined()) {
298 std::string error = *v8::String::AsciiValue(retval);
299 DCHECK(false) << error;
300 }
301 #endif
291 } 302 }
292 } 303 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/event_bindings.h ('k') | chrome/renderer/extensions/extension_api_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698