| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 InjectedScript* InjectedScriptManager::findInjectedScript(RemoteObjectIdBase* ob
jectId) const | 81 InjectedScript* InjectedScriptManager::findInjectedScript(RemoteObjectIdBase* ob
jectId) const |
| 82 { | 82 { |
| 83 return objectId ? findInjectedScript(objectId->contextId()) : nullptr; | 83 return objectId ? findInjectedScript(objectId->contextId()) : nullptr; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void InjectedScriptManager::discardInjectedScripts() | 86 void InjectedScriptManager::discardInjectedScripts() |
| 87 { | 87 { |
| 88 m_idToInjectedScript.clear(); | 88 m_idToInjectedScript.clear(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 int InjectedScriptManager::discardInjectedScriptFor(ScriptState* scriptState) | 91 int InjectedScriptManager::discardInjectedScriptFor(v8::Local<v8::Context> conte
xt) |
| 92 { | 92 { |
| 93 ScriptState::Scope scope(scriptState); | 93 int contextId = V8Debugger::contextId(context); |
| 94 int contextId = V8Debugger::contextId(scriptState->context()); | |
| 95 m_idToInjectedScript.remove(contextId); | 94 m_idToInjectedScript.remove(contextId); |
| 96 return contextId; | 95 return contextId; |
| 97 } | 96 } |
| 98 | 97 |
| 99 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) | 98 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) |
| 100 { | 99 { |
| 101 Vector<int> keys; | 100 Vector<int> keys; |
| 102 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k
eys().end()); | 101 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k
eys().end()); |
| 103 for (auto& key : keys) { | 102 for (auto& key : keys) { |
| 104 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(key); | 103 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(key); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 it->value->setCustomObjectFormatterEnabled(enabled); | 114 it->value->setCustomObjectFormatterEnabled(enabled); |
| 116 } | 115 } |
| 117 } | 116 } |
| 118 | 117 |
| 119 String InjectedScriptManager::injectedScriptSource() | 118 String InjectedScriptManager::injectedScriptSource() |
| 120 { | 119 { |
| 121 const WebData& injectedScriptSourceResource = Platform::current()->loadResou
rce("InjectedScriptSource.js"); | 120 const WebData& injectedScriptSourceResource = Platform::current()->loadResou
rce("InjectedScriptSource.js"); |
| 122 return String(injectedScriptSourceResource.data(), injectedScriptSourceResou
rce.size()); | 121 return String(injectedScriptSourceResource.data(), injectedScriptSourceResou
rce.size()); |
| 123 } | 122 } |
| 124 | 123 |
| 125 InjectedScript* InjectedScriptManager::injectedScriptFor(ScriptState* scriptStat
e) | 124 InjectedScript* InjectedScriptManager::injectedScriptFor(v8::Local<v8::Context>
context) |
| 126 { | 125 { |
| 127 ScriptState::Scope scope(scriptState); | 126 v8::Context::Scope scope(context); |
| 128 int contextId = V8Debugger::contextId(scriptState->context()); | 127 int contextId = V8Debugger::contextId(context); |
| 129 | 128 |
| 130 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); | 129 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(contextId); |
| 131 if (it != m_idToInjectedScript.end()) | 130 if (it != m_idToInjectedScript.end()) |
| 132 return it->value.get(); | 131 return it->value.get(); |
| 133 | 132 |
| 134 if (!m_client->canAccessContext(scriptState->context())) | 133 if (!m_client->callingContextCanAccessContext(context)) |
| 135 return nullptr; | 134 return nullptr; |
| 136 | 135 |
| 137 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(scriptState->isolate())); | 136 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(context->GetIsolate())); |
| 138 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource(
), scriptState, contextId, injectedScriptNative.get()); | 137 v8::Local<v8::Object> injectedScriptValue = createInjectedScript(injectedScr
iptSource(), context, contextId, injectedScriptNative.get()); |
| 139 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(injectedScriptVa
lue, m_client, injectedScriptNative.release(), contextId)); | 138 OwnPtr<InjectedScript> result = adoptPtr(new InjectedScript(injectedScriptVa
lue, m_client, injectedScriptNative.release(), contextId)); |
| 140 InjectedScript* resultPtr = result.get(); | 139 InjectedScript* resultPtr = result.get(); |
| 141 if (m_customObjectFormatterEnabled) | 140 if (m_customObjectFormatterEnabled) |
| 142 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); | 141 result->setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); |
| 143 m_idToInjectedScript.set(contextId, result.release()); | 142 m_idToInjectedScript.set(contextId, result.release()); |
| 144 return resultPtr; | 143 return resultPtr; |
| 145 } | 144 } |
| 146 | 145 |
| 147 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |