| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return it->value; | 90 return it->value; |
| 91 for (auto& state : m_scriptStateToId) { | 91 for (auto& state : m_scriptStateToId) { |
| 92 if (state.value == id) | 92 if (state.value == id) |
| 93 return injectedScriptFor(state.key.get()); | 93 return injectedScriptFor(state.key.get()); |
| 94 } | 94 } |
| 95 return InjectedScript(); | 95 return InjectedScript(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 int InjectedScriptManager::injectedScriptIdFor(ScriptState* scriptState) | 98 int InjectedScriptManager::injectedScriptIdFor(ScriptState* scriptState) |
| 99 { | 99 { |
| 100 ASSERT(scriptState->isJavaScript()); | |
| 101 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); | 100 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); |
| 102 if (it != m_scriptStateToId.end()) | 101 if (it != m_scriptStateToId.end()) |
| 103 return it->value; | 102 return it->value; |
| 104 int id = m_nextInjectedScriptId++; | 103 int id = m_nextInjectedScriptId++; |
| 105 m_scriptStateToId.set(scriptState, id); | 104 m_scriptStateToId.set(scriptState, id); |
| 106 return id; | 105 return id; |
| 107 } | 106 } |
| 108 | 107 |
| 109 InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& ob
jectId) | 108 InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& ob
jectId) |
| 110 { | 109 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 162 } |
| 164 | 163 |
| 165 String InjectedScriptManager::injectedScriptSource() | 164 String InjectedScriptManager::injectedScriptSource() |
| 166 { | 165 { |
| 167 const WebData& injectedScriptSourceResource = Platform::current()->loadResou
rce("InjectedScriptSource.js"); | 166 const WebData& injectedScriptSourceResource = Platform::current()->loadResou
rce("InjectedScriptSource.js"); |
| 168 return String(injectedScriptSourceResource.data(), injectedScriptSourceResou
rce.size()); | 167 return String(injectedScriptSourceResource.data(), injectedScriptSourceResou
rce.size()); |
| 169 } | 168 } |
| 170 | 169 |
| 171 InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedSc
riptState) | 170 InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* inspectedSc
riptState) |
| 172 { | 171 { |
| 173 ASSERT(inspectedScriptState->isJavaScript()); | |
| 174 ScriptStateToId::iterator it = m_scriptStateToId.find(inspectedScriptState); | 172 ScriptStateToId::iterator it = m_scriptStateToId.find(inspectedScriptState); |
| 175 if (it != m_scriptStateToId.end()) { | 173 if (it != m_scriptStateToId.end()) { |
| 176 IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->valu
e); | 174 IdToInjectedScriptMap::iterator it1 = m_idToInjectedScript.find(it->valu
e); |
| 177 if (it1 != m_idToInjectedScript.end()) | 175 if (it1 != m_idToInjectedScript.end()) |
| 178 return it1->value; | 176 return it1->value; |
| 179 } | 177 } |
| 180 | 178 |
| 181 if (!m_inspectedStateAccessCheck(inspectedScriptState)) | 179 if (!m_inspectedStateAccessCheck(inspectedScriptState)) |
| 182 return InjectedScript(); | 180 return InjectedScript(); |
| 183 | 181 |
| 184 int id = injectedScriptIdFor(inspectedScriptState); | 182 int id = injectedScriptIdFor(inspectedScriptState); |
| 185 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(inspectedScriptState->isolate())); | 183 RefPtr<InjectedScriptNative> injectedScriptNative = adoptRef(new InjectedScr
iptNative(inspectedScriptState->isolate())); |
| 186 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource(
), inspectedScriptState, id, injectedScriptNative.get()); | 184 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource(
), inspectedScriptState, id, injectedScriptNative.get()); |
| 187 InjectedScript result(injectedScriptValue, m_inspectedStateAccessCheck, inje
ctedScriptNative.release()); | 185 InjectedScript result(injectedScriptValue, m_inspectedStateAccessCheck, inje
ctedScriptNative.release()); |
| 188 if (m_customObjectFormatterEnabled) | 186 if (m_customObjectFormatterEnabled) |
| 189 result.setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); | 187 result.setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); |
| 190 m_idToInjectedScript.set(id, result); | 188 m_idToInjectedScript.set(id, result); |
| 191 return result; | 189 return result; |
| 192 } | 190 } |
| 193 | 191 |
| 194 } // namespace blink | 192 } // namespace blink |
| OLD | NEW |