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

Side by Side Diff: Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp

Issue 24758003: ScriptController: limit script execution API to executeScript and callFunction, pass valid ScriptEx… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: w/ ScheduledAction executing in given context. Created 7 years, 2 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 | « Source/bindings/v8/V8Callback.cpp ('k') | Source/bindings/v8/V8ErrorHandler.cpp » ('j') | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (callback.IsEmpty()) 177 if (callback.IsEmpty())
178 return; 178 return;
179 179
180 if (receiver.IsEmpty()) 180 if (receiver.IsEmpty())
181 receiver = toV8(element, context->Global(), isolate).As<v8::Object>(); 181 receiver = toV8(element, context->Global(), isolate).As<v8::Object>();
182 182
183 ASSERT(!receiver.IsEmpty()); 183 ASSERT(!receiver.IsEmpty());
184 184
185 v8::TryCatch exceptionCatcher; 185 v8::TryCatch exceptionCatcher;
186 exceptionCatcher.SetVerbose(true); 186 exceptionCatcher.SetVerbose(true);
187 ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0, isolate); 187 ScriptController::callFunction(scriptExecutionContext(), callback, receiver, 0, 0, isolate);
188 } 188 }
189 189
190 void V8CustomElementLifecycleCallbacks::enteredView(Element* element) 190 void V8CustomElementLifecycleCallbacks::enteredView(Element* element)
191 { 191 {
192 call(m_enteredView, element); 192 call(m_enteredView, element);
193 } 193 }
194 194
195 void V8CustomElementLifecycleCallbacks::leftView(Element* element) 195 void V8CustomElementLifecycleCallbacks::leftView(Element* element)
196 { 196 {
197 call(m_leftView, element); 197 call(m_leftView, element);
(...skipping 20 matching lines...) Expand all
218 return; 218 return;
219 219
220 v8::Handle<v8::Value> argv[] = { 220 v8::Handle<v8::Value> argv[] = {
221 v8String(name, isolate), 221 v8String(name, isolate),
222 oldValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl e<v8::Value>(v8String(oldValue, isolate)), 222 oldValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl e<v8::Value>(v8String(oldValue, isolate)),
223 newValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl e<v8::Value>(v8String(newValue, isolate)) 223 newValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl e<v8::Value>(v8String(newValue, isolate))
224 }; 224 };
225 225
226 v8::TryCatch exceptionCatcher; 226 v8::TryCatch exceptionCatcher;
227 exceptionCatcher.SetVerbose(true); 227 exceptionCatcher.SetVerbose(true);
228 ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv, isolate); 228 ScriptController::callFunction(scriptExecutionContext(), callback, receiver, WTF_ARRAY_LENGTH(argv), argv, isolate);
229 } 229 }
230 230
231 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function >& weakCallback, Element* element) 231 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function >& weakCallback, Element* element)
232 { 232 {
233 if (!canInvokeCallback()) 233 if (!canInvokeCallback())
234 return; 234 return;
235 235
236 v8::HandleScope handleScope(toIsolate(scriptExecutionContext())); 236 v8::HandleScope handleScope(toIsolate(scriptExecutionContext()));
237 v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_wo rld.get()); 237 v8::Handle<v8::Context> context = toV8Context(scriptExecutionContext(), m_wo rld.get());
238 if (context.IsEmpty()) 238 if (context.IsEmpty())
239 return; 239 return;
240 240
241 v8::Context::Scope scope(context); 241 v8::Context::Scope scope(context);
242 v8::Isolate* isolate = context->GetIsolate(); 242 v8::Isolate* isolate = context->GetIsolate();
243 243
244 v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate); 244 v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate);
245 if (callback.IsEmpty()) 245 if (callback.IsEmpty())
246 return; 246 return;
247 247
248 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate). As<v8::Object>(); 248 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate). As<v8::Object>();
249 ASSERT(!receiver.IsEmpty()); 249 ASSERT(!receiver.IsEmpty());
250 250
251 v8::TryCatch exceptionCatcher; 251 v8::TryCatch exceptionCatcher;
252 exceptionCatcher.SetVerbose(true); 252 exceptionCatcher.SetVerbose(true);
253 ScriptController::callFunctionWithInstrumentation(scriptExecutionContext(), callback, receiver, 0, 0, isolate); 253 ScriptController::callFunction(scriptExecutionContext(), callback, receiver, 0, 0, isolate);
254 } 254 }
255 255
256 } // namespace WebCore 256 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Callback.cpp ('k') | Source/bindings/v8/V8ErrorHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698