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

Side by Side Diff: Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

Issue 15496007: Validate types of arguments passed to V8InjectedScriptHost custom methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: re-order calls to get "cast" closer to check and avoid needless work on error. Created 7 years, 7 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
« no previous file with comments | « no previous file | 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 /* 1 /*
2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. 2 * Copyright (C) 2007-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); 270 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
271 ScriptValue object(args[0]); 271 ScriptValue object(args[0]);
272 ScriptValue hints(args[1]); 272 ScriptValue hints(args[1]);
273 host->inspectImpl(object.toInspectorValue(ScriptState::current()), hints.toI nspectorValue(ScriptState::current())); 273 host->inspectImpl(object.toInspectorValue(ScriptState::current()), hints.toI nspectorValue(ScriptState::current()));
274 274
275 return v8::Undefined(); 275 return v8::Undefined();
276 } 276 }
277 277
278 v8::Handle<v8::Value> V8InjectedScriptHost::databaseIdMethodCustom(const v8::Arg uments& args) 278 v8::Handle<v8::Value> V8InjectedScriptHost::databaseIdMethodCustom(const v8::Arg uments& args)
279 { 279 {
280 if (args.Length() < 1) 280 if (args.Length() > 0 && V8Database::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
281 return v8::Undefined(); 281 Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(a rgs[0]));
282 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); 282 if (database) {
283 Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(args[ 0])); 283 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holde r());
284 if (database) 284 return v8StringOrUndefined(host->databaseIdImpl(database), args.GetI solate());
285 return v8StringOrUndefined(host->databaseIdImpl(database), args.GetIsola te()); 285 }
286 }
286 return v8::Undefined(); 287 return v8::Undefined();
287 } 288 }
288 289
289 v8::Handle<v8::Value> V8InjectedScriptHost::storageIdMethodCustom(const v8::Argu ments& args) 290 v8::Handle<v8::Value> V8InjectedScriptHost::storageIdMethodCustom(const v8::Argu ments& args)
290 { 291 {
291 if (args.Length() < 1) 292 if (args.Length() > 0 && V8Storage::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
292 return v8::Undefined(); 293 Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(args [0]));
293 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); 294 if (storage) {
294 Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(args[0]) ); 295 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holde r());
295 if (storage) 296 return v8StringOrUndefined(host->storageIdImpl(storage), args.GetIso late());
296 return v8StringOrUndefined(host->storageIdImpl(storage), args.GetIsolate ()); 297 }
298 }
297 return v8::Undefined(); 299 return v8::Undefined();
298 } 300 }
299 301
300 v8::Handle<v8::Value> V8InjectedScriptHost::evaluateMethodCustom(const v8::Argum ents& args) 302 v8::Handle<v8::Value> V8InjectedScriptHost::evaluateMethodCustom(const v8::Argum ents& args)
301 { 303 {
302 if (args.Length() < 1) 304 if (args.Length() < 1)
303 return v8::ThrowException(v8::Exception::Error(v8::String::New("One argu ment expected."))); 305 return v8::ThrowException(v8::Exception::Error(v8::String::New("One argu ment expected.")));
304 306
305 v8::Handle<v8::String> expression = args[0]->ToString(); 307 v8::Handle<v8::String> expression = args[0]->ToString();
306 if (expression.IsEmpty()) 308 if (expression.IsEmpty())
(...skipping 13 matching lines...) Expand all
320 v8::Handle<v8::Value> newValue = args[3]; 322 v8::Handle<v8::Value> newValue = args[3];
321 323
322 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); 324 InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
323 ScriptDebugServer& debugServer = host->scriptDebugServer(); 325 ScriptDebugServer& debugServer = host->scriptDebugServer();
324 return debugServer.setFunctionVariableValue(functionValue, scopeIndex, varia bleName, newValue); 326 return debugServer.setFunctionVariableValue(functionValue, scopeIndex, varia bleName, newValue);
325 } 327 }
326 328
327 329
328 } // namespace WebCore 330 } // namespace WebCore
329 331
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698