| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
| 4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. 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 | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/inspector/v8/InjectedScriptManager.h" | 31 #include "core/inspector/v8/InjectedScriptManager.h" |
| 32 | 32 |
| 33 #include "core/inspector/v8/InjectedScript.h" | 33 #include "core/inspector/v8/InjectedScript.h" |
| 34 #include "core/inspector/v8/InjectedScriptHost.h" | 34 #include "core/inspector/v8/InjectedScriptHost.h" |
| 35 #include "core/inspector/v8/InjectedScriptNative.h" | 35 #include "core/inspector/v8/InjectedScriptNative.h" |
| 36 #include "core/inspector/v8/InjectedScriptSource.h" | |
| 37 #include "core/inspector/v8/RemoteObjectId.h" | 36 #include "core/inspector/v8/RemoteObjectId.h" |
| 38 #include "core/inspector/v8/V8Debugger.h" | 37 #include "core/inspector/v8/V8Debugger.h" |
| 39 #include "core/inspector/v8/V8DebuggerClient.h" | 38 #include "core/inspector/v8/V8DebuggerClient.h" |
| 40 #include "core/inspector/v8/V8InjectedScriptHost.h" | 39 #include "core/inspector/v8/V8InjectedScriptHost.h" |
| 41 #include "core/inspector/v8/V8StringUtil.h" | 40 #include "core/inspector/v8/V8StringUtil.h" |
| 41 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebData.h" |
| 42 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 PassOwnPtr<InjectedScriptManager> InjectedScriptManager::create(V8DebuggerClient
* client) | 47 PassOwnPtr<InjectedScriptManager> InjectedScriptManager::create(V8DebuggerClient
* client) |
| 47 { | 48 { |
| 48 return adoptPtr(new InjectedScriptManager(client)); | 49 return adoptPtr(new InjectedScriptManager(client)); |
| 49 } | 50 } |
| 50 | 51 |
| 51 InjectedScriptManager::InjectedScriptManager(V8DebuggerClient* client) | 52 InjectedScriptManager::InjectedScriptManager(V8DebuggerClient* client) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); | 129 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); |
| 129 if (it != m_idToInjectedScript.end()) | 130 if (it != m_idToInjectedScript.end()) |
| 130 return it->value.get(); | 131 return it->value.get(); |
| 131 | 132 |
| 132 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon
text(); | 133 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon
text(); |
| 133 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c
allingContext, context)) | 134 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c
allingContext, context)) |
| 134 return nullptr; | 135 return nullptr; |
| 135 | 136 |
| 136 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); | 137 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); |
| 137 String injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSour
ce_js), sizeof(InjectedScriptSource_js)); | 138 |
| 139 const WebData& injectedScriptSourceResource = Platform::current()->loadResou
rce("InjectedScriptSource.js"); |
| 140 String injectedScriptSource(injectedScriptSourceResource.data(), injectedScr
iptSourceResource.size()); |
| 138 | 141 |
| 139 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, co
ntext, contextId, injectedScriptNative.get()); | 142 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, co
ntext, contextId, injectedScriptNative.get()); |
| 140 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o
bject, m_client, injectedScriptNative.release(), contextId)); | 143 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o
bject, m_client, injectedScriptNative.release(), contextId)); |
| 141 InjectedScript* resultPtr = result.get(); | 144 InjectedScript* resultPtr = result.get(); |
| 142 if (m_customObjectFormatterEnabled) | 145 if (m_customObjectFormatterEnabled) |
| 143 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); | 146 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); |
| 144 m_idToInjectedScript.set(contextId, result.release()); | 147 m_idToInjectedScript.set(contextId, result.release()); |
| 145 return resultPtr; | 148 return resultPtr; |
| 146 } | 149 } |
| 147 | 150 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 176 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; | 179 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; |
| 177 v8::Local<v8::Value> injectedScriptValue; | 180 v8::Local<v8::Value> injectedScriptValue; |
| 178 if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), wi
ndowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) | 181 if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), wi
ndowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) |
| 179 return v8::Local<v8::Object>(); | 182 return v8::Local<v8::Object>(); |
| 180 if (!injectedScriptValue->IsObject()) | 183 if (!injectedScriptValue->IsObject()) |
| 181 return v8::Local<v8::Object>(); | 184 return v8::Local<v8::Object>(); |
| 182 return injectedScriptValue.As<v8::Object>(); | 185 return injectedScriptValue.As<v8::Object>(); |
| 183 } | 186 } |
| 184 | 187 |
| 185 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |