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 12 matching lines...) Expand all Loading... |
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
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/InjectedScriptManager.h" | 31 #include "core/inspector/InjectedScriptManager.h" |
32 | 32 |
33 #include "bindings/core/v8/ScriptValue.h" | |
34 #include "core/inspector/InjectedScript.h" | 33 #include "core/inspector/InjectedScript.h" |
35 #include "core/inspector/InjectedScriptHost.h" | 34 #include "core/inspector/InjectedScriptHost.h" |
36 #include "core/inspector/InjectedScriptNative.h" | 35 #include "core/inspector/InjectedScriptNative.h" |
37 #include "core/inspector/RemoteObjectId.h" | 36 #include "core/inspector/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 "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
41 #include "public/platform/WebData.h" | 40 #include "public/platform/WebData.h" |
42 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
43 | 42 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 83 } |
85 | 84 |
86 void InjectedScriptManager::discardInjectedScripts() | 85 void InjectedScriptManager::discardInjectedScripts() |
87 { | 86 { |
88 m_idToInjectedScript.clear(); | 87 m_idToInjectedScript.clear(); |
89 } | 88 } |
90 | 89 |
91 int InjectedScriptManager::discardInjectedScriptFor(v8::Local<v8::Context> conte
xt) | 90 int InjectedScriptManager::discardInjectedScriptFor(v8::Local<v8::Context> conte
xt) |
92 { | 91 { |
93 int contextId = V8Debugger::contextId(context); | 92 int contextId = V8Debugger::contextId(context); |
| 93 discardInjectedScript(contextId); |
| 94 return contextId; |
| 95 } |
| 96 |
| 97 void InjectedScriptManager::discardInjectedScript(int contextId) |
| 98 { |
94 m_idToInjectedScript.remove(contextId); | 99 m_idToInjectedScript.remove(contextId); |
95 return contextId; | |
96 } | 100 } |
97 | 101 |
98 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) | 102 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) |
99 { | 103 { |
100 Vector<int> keys; | 104 Vector<int> keys; |
101 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k
eys().end()); | 105 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k
eys().end()); |
102 for (auto& key : keys) { | 106 for (auto& key : keys) { |
103 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(key); | 107 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(key); |
104 if (s != m_idToInjectedScript.end()) | 108 if (s != m_idToInjectedScript.end()) |
105 s->value->releaseObjectGroup(objectGroup); // m_idToInjectedScript m
ay change here. | 109 s->value->releaseObjectGroup(objectGroup); // m_idToInjectedScript m
ay change here. |
(...skipping 17 matching lines...) Expand all Loading... |
123 | 127 |
124 InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context>
context) | 128 InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context>
context) |
125 { | 129 { |
126 v8::Context::Scope scope(context); | 130 v8::Context::Scope scope(context); |
127 int contextId = V8Debugger::contextId(context); | 131 int contextId = V8Debugger::contextId(context); |
128 | 132 |
129 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); | 133 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); |
130 if (it != m_idToInjectedScript.end()) | 134 if (it != m_idToInjectedScript.end()) |
131 return it->value.get(); | 135 return it->value.get(); |
132 | 136 |
133 if (!m_client->callingContextCanAccessContext(context)) | 137 v8::Local<v8::Context> callingContext = context->GetIsolate()->GetCallingCon
text(); |
| 138 if (!callingContext.IsEmpty() && !m_client->callingContextCanAccessContext(c
allingContext, context)) |
134 return nullptr; | 139 return nullptr; |
135 | 140 |
136 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); | 141 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); |
137 v8::Local<v8::Object> injectedScriptValue = createInjectedScript(injectedScr
iptSource(), context, contextId, injectedScriptNative.get()); | 142 v8::Local<v8::Object> object = createInjectedScript(injectedScriptSource(),
context, contextId, injectedScriptNative.get()); |
138 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(injectedScriptVa
lue, m_client, injectedScriptNative.release(), contextId)); | 143 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(this, context, o
bject, m_client, injectedScriptNative.release(), contextId)); |
139 InjectedScript* resultPtr = result.get(); | 144 InjectedScript* resultPtr = result.get(); |
140 if (m_customObjectFormatterEnabled) | 145 if (m_customObjectFormatterEnabled) |
141 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); | 146 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); |
142 m_idToInjectedScript.set(contextId, result.release()); | 147 m_idToInjectedScript.set(contextId, result.release()); |
143 return resultPtr; | 148 return resultPtr; |
144 } | 149 } |
145 | 150 |
146 } // namespace blink | 151 } // namespace blink |
OLD | NEW |