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

Side by Side Diff: chrome/renderer/extensions/extension_process_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/extension_process_bindings.h" 5 #include "chrome/renderer/extensions/extension_process_bindings.h"
6 6
7 #include "base/singleton.h" 7 #include "base/singleton.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (request == pending_requests.end()) 291 if (request == pending_requests.end())
292 return; // The frame went away. 292 return; // The frame went away.
293 293
294 v8::HandleScope handle_scope; 294 v8::HandleScope handle_scope;
295 v8::Handle<v8::Value> argv[5]; 295 v8::Handle<v8::Value> argv[5];
296 argv[0] = v8::Integer::New(request_id); 296 argv[0] = v8::Integer::New(request_id);
297 argv[1] = v8::String::New(request->second->name.c_str()); 297 argv[1] = v8::String::New(request->second->name.c_str());
298 argv[2] = v8::Boolean::New(success); 298 argv[2] = v8::Boolean::New(success);
299 argv[3] = v8::String::New(response.c_str()); 299 argv[3] = v8::String::New(response.c_str());
300 argv[4] = v8::String::New(error.c_str()); 300 argv[4] = v8::String::New(error.c_str());
301 bindings_utils::CallFunctionInContext( 301 v8::Handle<v8::Value> retval = bindings_utils::CallFunctionInContext(
302 request->second->context, "handleResponse", arraysize(argv), argv); 302 request->second->context, "handleResponse", arraysize(argv), argv);
303 // In debug, the js will validate the callback parameters and return a
304 // string if a validation error has occured.
305 #ifdef _DEBUG
306 if (!retval.IsEmpty() && !retval->IsUndefined()) {
307 std::string error = *v8::String::AsciiValue(retval);
308 DCHECK(false) << error;
309 }
310 #endif
303 311
304 pending_requests.erase(request); 312 pending_requests.erase(request);
305 } 313 }
306 314
307 // static 315 // static
308 void ExtensionProcessBindings::SetPageActions( 316 void ExtensionProcessBindings::SetPageActions(
309 const std::string& extension_id, 317 const std::string& extension_id,
310 const std::vector<std::string>& page_actions) { 318 const std::vector<std::string>& page_actions) {
311 PageActionIdMap& page_action_map = *GetPageActionMap(); 319 PageActionIdMap& page_action_map = *GetPageActionMap();
312 if (!page_actions.empty()) { 320 if (!page_actions.empty()) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 389
382 v8::Local<v8::Function> function = 390 v8::Local<v8::Function> function =
383 v8::Local<v8::Function>::Cast(console_error); 391 v8::Local<v8::Function>::Cast(console_error);
384 v8::Local<v8::Value> argv[] = { v8::String::New(error_msg.c_str()) }; 392 v8::Local<v8::Value> argv[] = { v8::String::New(error_msg.c_str()) };
385 if (!function.IsEmpty()) 393 if (!function.IsEmpty())
386 function->Call(console->ToObject(), arraysize(argv), argv); 394 function->Call(console->ToObject(), arraysize(argv), argv);
387 395
388 return v8::Undefined(); 396 return v8::Undefined();
389 #endif 397 #endif
390 } 398 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_api_client_unittest.cc ('k') | chrome/renderer/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698