| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 v8::Local<v8::FunctionTemplate> wrapperTemplate = m_injectedScriptHost->wrap
perTemplate(isolate); | 51 v8::Local<v8::FunctionTemplate> wrapperTemplate = m_injectedScriptHost->wrap
perTemplate(isolate); |
| 52 if (wrapperTemplate.IsEmpty()) { | 52 if (wrapperTemplate.IsEmpty()) { |
| 53 wrapperTemplate = V8InjectedScriptHost::createWrapperTemplate(isolate); | 53 wrapperTemplate = V8InjectedScriptHost::createWrapperTemplate(isolate); |
| 54 m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate); | 54 m_injectedScriptHost->setWrapperTemplate(wrapperTemplate, isolate); |
| 55 } | 55 } |
| 56 | 56 |
| 57 v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::wrap(wrapper
Template, inspectedScriptState->context(), m_injectedScriptHost); | 57 v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::wrap(wrapper
Template, inspectedScriptState->context(), m_injectedScriptHost); |
| 58 if (scriptHostWrapper.IsEmpty()) | 58 if (scriptHostWrapper.IsEmpty()) |
| 59 return ScriptValue(); | 59 return ScriptValue(); |
| 60 | 60 |
| 61 // Store the inspectedScriptState on the scriptHostWrapper if it is |
| 62 // different from the ScriptState associated with the context. |
| 63 // This is needed to support Dart as Dart does not create a separate V8 |
| 64 // context for every Dart library. |
| 65 if (inspectedScriptState != ScriptState::from(inspectedScriptState->context(
))) |
| 66 V8HiddenValue::setHiddenValue(isolate, scriptHostWrapper, V8HiddenValue:
:scriptState(isolate), v8::External::New(isolate, inspectedScriptState)); |
| 67 |
| 61 injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper); | 68 injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper); |
| 62 | 69 |
| 63 // Inject javascript into the context. The compiled script is supposed to ev
aluate into | 70 // Inject javascript into the context. The compiled script is supposed to ev
aluate into |
| 64 // a single anonymous function(it's anonymous to avoid cluttering the global
object with | 71 // a single anonymous function(it's anonymous to avoid cluttering the global
object with |
| 65 // inspector's stuff) the function is called a few lines below with Injected
ScriptHost wrapper, | 72 // inspector's stuff) the function is called a few lines below with Injected
ScriptHost wrapper, |
| 66 // injected script id and explicit reference to the inspected global object.
The function is expected | 73 // injected script id and explicit reference to the inspected global object.
The function is expected |
| 67 // to create and configure InjectedScript instance that is going to be used
by the inspector. | 74 // to create and configure InjectedScript instance that is going to be used
by the inspector. |
| 68 v8::Local<v8::Value> value; | 75 v8::Local<v8::Value> value; |
| 69 if (!V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, scriptSou
rce), isolate).ToLocal(&value)) | 76 if (!V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, scriptSou
rce), isolate).ToLocal(&value)) |
| 70 return ScriptValue(); | 77 return ScriptValue(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 88 return false; | 95 return false; |
| 89 v8::Local<v8::Object> holder = V8Window::findInstanceInPrototypeChain(global
, scriptState->isolate()); | 96 v8::Local<v8::Object> holder = V8Window::findInstanceInPrototypeChain(global
, scriptState->isolate()); |
| 90 if (holder.IsEmpty()) | 97 if (holder.IsEmpty()) |
| 91 return false; | 98 return false; |
| 92 LocalFrame* frame = toLocalDOMWindow(V8Window::toImpl(holder))->frame(); | 99 LocalFrame* frame = toLocalDOMWindow(V8Window::toImpl(holder))->frame(); |
| 93 | 100 |
| 94 return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), fra
me, DoNotReportSecurityError); | 101 return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), fra
me, DoNotReportSecurityError); |
| 95 } | 102 } |
| 96 | 103 |
| 97 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |