| 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" |
| 36 #include "core/inspector/v8/RemoteObjectId.h" | 37 #include "core/inspector/v8/RemoteObjectId.h" |
| 37 #include "core/inspector/v8/V8Debugger.h" | 38 #include "core/inspector/v8/V8Debugger.h" |
| 38 #include "core/inspector/v8/V8DebuggerClient.h" | 39 #include "core/inspector/v8/V8DebuggerClient.h" |
| 39 #include "core/inspector/v8/V8InjectedScriptHost.h" | 40 #include "core/inspector/v8/V8InjectedScriptHost.h" |
| 40 #include "core/inspector/v8/V8StringUtil.h" | 41 #include "core/inspector/v8/V8StringUtil.h" |
| 41 #include "public/platform/Platform.h" | |
| 42 #include "public/platform/WebData.h" | |
| 43 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
| 44 | 43 |
| 45 namespace blink { | 44 namespace blink { |
| 46 | 45 |
| 47 PassOwnPtr<InjectedScriptManager> InjectedScriptManager::create(V8DebuggerClient
* client) | 46 PassOwnPtr<InjectedScriptManager> InjectedScriptManager::create(V8DebuggerClient
* client) |
| 48 { | 47 { |
| 49 return adoptPtr(new InjectedScriptManager(client)); | 48 return adoptPtr(new InjectedScriptManager(client)); |
| 50 } | 49 } |
| 51 | 50 |
| 52 InjectedScriptManager::InjectedScriptManager(V8DebuggerClient* client) | 51 InjectedScriptManager::InjectedScriptManager(V8DebuggerClient* client) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 127 |
| 129 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); | 128 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); |
| 130 if (it != m_idToInjectedScript.end()) | 129 if (it != m_idToInjectedScript.end()) |
| 131 return it->value.get(); | 130 return it->value.get(); |
| 132 | 131 |
| 133 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon
text(); | 132 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon
text(); |
| 134 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c
allingContext, context)) | 133 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c
allingContext, context)) |
| 135 return nullptr; | 134 return nullptr; |
| 136 | 135 |
| 137 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); | 136 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); |
| 138 | 137 String injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSour
ce_js), sizeof(InjectedScriptSource_js)); |
| 139 const WebData& injectedScriptSourceResource = Platform::current()->loadResou
rce("InjectedScriptSource.js"); | |
| 140 String injectedScriptSource(injectedScriptSourceResource.data(), injectedScr
iptSourceResource.size()); | |
| 141 | 138 |
| 142 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, co
ntext, contextId, injectedScriptNative.get()); | 139 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource, co
ntext, contextId, injectedScriptNative.get()); |
| 143 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o
bject, m_client, injectedScriptNative.release(), contextId)); | 140 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o
bject, m_client, injectedScriptNative.release(), contextId)); |
| 144 InjectedScript* resultPtr = result.get(); | 141 InjectedScript* resultPtr = result.get(); |
| 145 if (m_customObjectFormatterEnabled) | 142 if (m_customObjectFormatterEnabled) |
| 146 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); | 143 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); |
| 147 m_idToInjectedScript.set(contextId, result.release()); | 144 m_idToInjectedScript.set(contextId, result.release()); |
| 148 return resultPtr; | 145 return resultPtr; |
| 149 } | 146 } |
| 150 | 147 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 179 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; | 176 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; |
| 180 v8::Local<v8::Value> injectedScriptValue; | 177 v8::Local<v8::Value> injectedScriptValue; |
| 181 if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), wi
ndowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) | 178 if (!m_client->callInternalFunction(v8::Local<v8::Function>::Cast(value), wi
ndowGlobal, WTF_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue)) |
| 182 return v8::Local<v8::Object>(); | 179 return v8::Local<v8::Object>(); |
| 183 if (!injectedScriptValue->IsObject()) | 180 if (!injectedScriptValue->IsObject()) |
| 184 return v8::Local<v8::Object>(); | 181 return v8::Local<v8::Object>(); |
| 185 return injectedScriptValue.As<v8::Object>(); | 182 return injectedScriptValue.As<v8::Object>(); |
| 186 } | 183 } |
| 187 | 184 |
| 188 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |