OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "core/html/HTMLPlugInElement.h" | 55 #include "core/html/HTMLPlugInElement.h" |
56 #include "core/inspector/ConsoleMessage.h" | 56 #include "core/inspector/ConsoleMessage.h" |
57 #include "core/inspector/InspectorInstrumentation.h" | 57 #include "core/inspector/InspectorInstrumentation.h" |
58 #include "core/inspector/InspectorTraceEvents.h" | 58 #include "core/inspector/InspectorTraceEvents.h" |
59 #include "core/inspector/MainThreadDebugger.h" | 59 #include "core/inspector/MainThreadDebugger.h" |
60 #include "core/loader/DocumentLoader.h" | 60 #include "core/loader/DocumentLoader.h" |
61 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" |
62 #include "core/loader/NavigationScheduler.h" | 62 #include "core/loader/NavigationScheduler.h" |
63 #include "core/loader/ProgressTracker.h" | 63 #include "core/loader/ProgressTracker.h" |
64 #include "core/plugins/PluginView.h" | 64 #include "core/plugins/PluginView.h" |
| 65 #include "platform/FrameViewBase.h" |
65 #include "platform/Histogram.h" | 66 #include "platform/Histogram.h" |
66 #include "platform/UserGestureIndicator.h" | 67 #include "platform/UserGestureIndicator.h" |
67 #include "platform/Widget.h" | |
68 #include "platform/instrumentation/tracing/TraceEvent.h" | 68 #include "platform/instrumentation/tracing/TraceEvent.h" |
69 #include "platform/weborigin/SecurityOrigin.h" | 69 #include "platform/weborigin/SecurityOrigin.h" |
70 #include "public/platform/Platform.h" | 70 #include "public/platform/Platform.h" |
71 #include "wtf/CurrentTime.h" | 71 #include "wtf/CurrentTime.h" |
72 #include "wtf/StdLibExtras.h" | 72 #include "wtf/StdLibExtras.h" |
73 #include "wtf/StringExtras.h" | 73 #include "wtf/StringExtras.h" |
74 #include "wtf/text/CString.h" | 74 #include "wtf/text/CString.h" |
75 #include "wtf/text/StringBuilder.h" | 75 #include "wtf/text/StringBuilder.h" |
76 #include "wtf/text/TextPosition.h" | 76 #include "wtf/text/TextPosition.h" |
77 | 77 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 v8::Local<v8::Context> v8Context = | 198 v8::Local<v8::Context> v8Context = |
199 m_windowProxyManager->mainWorldProxy()->contextIfInitialized(); | 199 m_windowProxyManager->mainWorldProxy()->contextIfInitialized(); |
200 if (v8Context.IsEmpty()) | 200 if (v8Context.IsEmpty()) |
201 return; | 201 return; |
202 v8Context->AllowCodeGenerationFromStrings(false); | 202 v8Context->AllowCodeGenerationFromStrings(false); |
203 v8Context->SetErrorMessageForCodeGenerationFromStrings( | 203 v8Context->SetErrorMessageForCodeGenerationFromStrings( |
204 v8String(isolate(), errorMessage)); | 204 v8String(isolate(), errorMessage)); |
205 } | 205 } |
206 | 206 |
207 PassRefPtr<SharedPersistent<v8::Object>> ScriptController::createPluginWrapper( | 207 PassRefPtr<SharedPersistent<v8::Object>> ScriptController::createPluginWrapper( |
208 Widget* widget) { | 208 FrameViewBase* frameViewBase) { |
209 ASSERT(widget); | 209 DCHECK(frameViewBase); |
210 | 210 |
211 if (!widget->isPluginView()) | 211 if (!frameViewBase->isPluginView()) |
212 return nullptr; | 212 return nullptr; |
213 | 213 |
214 v8::HandleScope handleScope(isolate()); | 214 v8::HandleScope handleScope(isolate()); |
215 v8::Local<v8::Object> scriptableObject = | 215 v8::Local<v8::Object> scriptableObject = |
216 toPluginView(widget)->scriptableObject(isolate()); | 216 toPluginView(frameViewBase)->scriptableObject(isolate()); |
217 | 217 |
218 if (scriptableObject.IsEmpty()) | 218 if (scriptableObject.IsEmpty()) |
219 return nullptr; | 219 return nullptr; |
220 | 220 |
221 return SharedPersistent<v8::Object>::create(scriptableObject, isolate()); | 221 return SharedPersistent<v8::Object>::create(scriptableObject, isolate()); |
222 } | 222 } |
223 | 223 |
224 V8Extensions& ScriptController::registeredExtensions() { | 224 V8Extensions& ScriptController::registeredExtensions() { |
225 DEFINE_STATIC_LOCAL(V8Extensions, extensions, ()); | 225 DEFINE_STATIC_LOCAL(V8Extensions, extensions, ()); |
226 return extensions; | 226 return extensions; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 return true; | 287 return true; |
288 | 288 |
289 if (result.IsEmpty() || !result->IsString()) { | 289 if (result.IsEmpty() || !result->IsString()) { |
290 if (progressNotificationsNeeded) | 290 if (progressNotificationsNeeded) |
291 frame()->loader().progress().progressCompleted(); | 291 frame()->loader().progress().progressCompleted(); |
292 return true; | 292 return true; |
293 } | 293 } |
294 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); | 294 String scriptResult = toCoreString(v8::Local<v8::String>::Cast(result)); |
295 | 295 |
296 // We're still in a frame, so there should be a DocumentLoader. | 296 // We're still in a frame, so there should be a DocumentLoader. |
297 ASSERT(frame()->document()->loader()); | 297 DCHECK(frame()->document()->loader()); |
298 if (!locationChangeBefore && | 298 if (!locationChangeBefore && |
299 frame()->navigationScheduler().locationChangePending()) | 299 frame()->navigationScheduler().locationChangePending()) |
300 return true; | 300 return true; |
301 | 301 |
302 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResult, | 302 frame()->loader().replaceDocumentWhileExecutingJavaScriptURL(scriptResult, |
303 ownerDocument); | 303 ownerDocument); |
304 return true; | 304 return true; |
305 } | 305 } |
306 | 306 |
307 void ScriptController::executeScriptInMainWorld(const String& script, | 307 void ScriptController::executeScriptInMainWorld(const String& script, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 if (object.IsEmpty()) | 348 if (object.IsEmpty()) |
349 return v8::Local<v8::Value>(); | 349 return v8::Local<v8::Value>(); |
350 | 350 |
351 return handleScope.Escape(object); | 351 return handleScope.Escape(object); |
352 } | 352 } |
353 | 353 |
354 void ScriptController::executeScriptInIsolatedWorld( | 354 void ScriptController::executeScriptInIsolatedWorld( |
355 int worldID, | 355 int worldID, |
356 const HeapVector<ScriptSourceCode>& sources, | 356 const HeapVector<ScriptSourceCode>& sources, |
357 Vector<v8::Local<v8::Value>>* results) { | 357 Vector<v8::Local<v8::Value>>* results) { |
358 ASSERT(worldID > 0); | 358 DCHECK_GT(worldID, 0); |
359 | 359 |
360 RefPtr<DOMWrapperWorld> world = | 360 RefPtr<DOMWrapperWorld> world = |
361 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID); | 361 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID); |
362 LocalWindowProxy* isolatedWorldWindowProxy = windowProxy(*world); | 362 LocalWindowProxy* isolatedWorldWindowProxy = windowProxy(*world); |
363 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); | 363 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); |
364 if (!scriptState->contextIsValid()) | 364 if (!scriptState->contextIsValid()) |
365 return; | 365 return; |
366 v8::Context::Scope scope(scriptState->context()); | 366 v8::Context::Scope scope(scriptState->context()); |
367 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); | 367 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); |
368 | 368 |
(...skipping 12 matching lines...) Expand all Loading... |
381 for (size_t i = 0; i < resultArray->Length(); ++i) { | 381 for (size_t i = 0; i < resultArray->Length(); ++i) { |
382 v8::Local<v8::Value> value; | 382 v8::Local<v8::Value> value; |
383 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 383 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
384 return; | 384 return; |
385 results->push_back(value); | 385 results->push_back(value); |
386 } | 386 } |
387 } | 387 } |
388 } | 388 } |
389 | 389 |
390 } // namespace blink | 390 } // namespace blink |
OLD | NEW |