| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (scriptHostWrapper.IsEmpty()) | 95 if (scriptHostWrapper.IsEmpty()) |
| 96 return ScriptValue(); | 96 return ScriptValue(); |
| 97 | 97 |
| 98 injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper); | 98 injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper); |
| 99 | 99 |
| 100 // Inject javascript into the context. The compiled script is supposed to ev
aluate into | 100 // Inject javascript into the context. The compiled script is supposed to ev
aluate into |
| 101 // a single anonymous function(it's anonymous to avoid cluttering the global
object with | 101 // a single anonymous function(it's anonymous to avoid cluttering the global
object with |
| 102 // inspector's stuff) the function is called a few lines below with Injected
ScriptHost wrapper, | 102 // inspector's stuff) the function is called a few lines below with Injected
ScriptHost wrapper, |
| 103 // injected script id and explicit reference to the inspected global object.
The function is expected | 103 // injected script id and explicit reference to the inspected global object.
The function is expected |
| 104 // to create and configure InjectedScript instance that is going to be used
by the inspector. | 104 // to create and configure InjectedScript instance that is going to be used
by the inspector. |
| 105 v8::Local<v8::Value> value = V8ScriptRunner::compileAndRunInternalScript(v8S
tring(isolate, scriptSource), isolate); | 105 v8::Local<v8::Value> value; |
| 106 ASSERT(!value.IsEmpty()); | 106 if (!V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, scriptSou
rce), isolate).ToLocal(&value)) |
| 107 return ScriptValue(); |
| 107 ASSERT(value->IsFunction()); | 108 ASSERT(value->IsFunction()); |
| 108 | 109 |
| 109 v8::Local<v8::Object> windowGlobal = inspectedScriptState->context()->Global
(); | 110 v8::Local<v8::Object> windowGlobal = inspectedScriptState->context()->Global
(); |
| 110 v8::Handle<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number
::New(inspectedScriptState->isolate(), id) }; | 111 v8::Handle<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number
::New(inspectedScriptState->isolate(), id) }; |
| 111 v8::Local<v8::Value> injectedScriptValue = V8ScriptRunner::callInternalFunct
ion(v8::Local<v8::Function>::Cast(value), windowGlobal, WTF_ARRAY_LENGTH(info),
info, inspectedScriptState->isolate()); | 112 v8::Local<v8::Value> injectedScriptValue = V8ScriptRunner::callInternalFunct
ion(v8::Local<v8::Function>::Cast(value), windowGlobal, WTF_ARRAY_LENGTH(info),
info, inspectedScriptState->isolate()); |
| 112 return ScriptValue(inspectedScriptState, injectedScriptValue); | 113 return ScriptValue(inspectedScriptState, injectedScriptValue); |
| 113 } | 114 } |
| 114 | 115 |
| 115 bool InjectedScriptManager::canAccessInspectedWindow(ScriptState* scriptState) | 116 bool InjectedScriptManager::canAccessInspectedWindow(ScriptState* scriptState) |
| 116 { | 117 { |
| 117 ScriptState::Scope scope(scriptState); | 118 ScriptState::Scope scope(scriptState); |
| 118 v8::Local<v8::Object> global = scriptState->context()->Global(); | 119 v8::Local<v8::Object> global = scriptState->context()->Global(); |
| 119 if (global.IsEmpty()) | 120 if (global.IsEmpty()) |
| 120 return false; | 121 return false; |
| 121 v8::Handle<v8::Object> holder = V8Window::findInstanceInPrototypeChain(globa
l, scriptState->isolate()); | 122 v8::Handle<v8::Object> holder = V8Window::findInstanceInPrototypeChain(globa
l, scriptState->isolate()); |
| 122 if (holder.IsEmpty()) | 123 if (holder.IsEmpty()) |
| 123 return false; | 124 return false; |
| 124 LocalFrame* frame = toLocalDOMWindow(V8Window::toImpl(holder))->frame(); | 125 LocalFrame* frame = toLocalDOMWindow(V8Window::toImpl(holder))->frame(); |
| 125 | 126 |
| 126 return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), fra
me, DoNotReportSecurityError); | 127 return BindingSecurity::shouldAllowAccessToFrame(scriptState->isolate(), fra
me, DoNotReportSecurityError); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void InjectedScriptManager::setWeakCallback(const v8::WeakCallbackData<v8::Objec
t, InjectedScriptManager::CallbackData>& data) | 130 void InjectedScriptManager::setWeakCallback(const v8::WeakCallbackData<v8::Objec
t, InjectedScriptManager::CallbackData>& data) |
| 130 { | 131 { |
| 131 InjectedScriptManager::CallbackData* callbackData = data.GetParameter(); | 132 InjectedScriptManager::CallbackData* callbackData = data.GetParameter(); |
| 132 callbackData->injectedScriptManager->removeCallbackData(callbackData); | 133 callbackData->injectedScriptManager->removeCallbackData(callbackData); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |