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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 return InjectedScript(); | 113 return InjectedScript(); |
114 } | 114 } |
115 | 115 |
116 void InjectedScriptManager::discardInjectedScripts() | 116 void InjectedScriptManager::discardInjectedScripts() |
117 { | 117 { |
118 m_idToInjectedScript.clear(); | 118 m_idToInjectedScript.clear(); |
119 m_scriptStateToId.clear(); | 119 m_scriptStateToId.clear(); |
120 } | 120 } |
121 | 121 |
122 void InjectedScriptManager::discardInjectedScriptsFor(LocalDOMWindow* window) | 122 void InjectedScriptManager::discardInjectedScriptFor(ScriptState* scriptState) |
123 { | 123 { |
124 if (m_scriptStateToId.isEmpty()) | 124 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); |
| 125 if (it == m_scriptStateToId.end()) |
125 return; | 126 return; |
126 | 127 |
127 Vector<long> idsToRemove; | 128 m_idToInjectedScript.remove(it->value); |
128 IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end(); | 129 m_scriptStateToId.remove(it); |
129 for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it !
= end; ++it) { | |
130 ScriptState* scriptState = it->value.scriptState(); | |
131 if (window != scriptState->domWindow()) | |
132 continue; | |
133 m_scriptStateToId.remove(scriptState); | |
134 idsToRemove.append(it->key); | |
135 } | |
136 m_idToInjectedScript.removeAll(idsToRemove); | |
137 | |
138 // Now remove script states that have id but no injected script. | |
139 Vector<ScriptState*> scriptStatesToRemove; | |
140 for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scrip
tStateToId.end(); ++it) { | |
141 ScriptState* scriptState = it->key.get(); | |
142 if (window == scriptState->domWindow()) | |
143 scriptStatesToRemove.append(scriptState); | |
144 } | |
145 m_scriptStateToId.removeAll(scriptStatesToRemove); | |
146 } | 130 } |
147 | 131 |
148 bool InjectedScriptManager::canAccessInspectedWorkerGlobalScope(ScriptState*) | 132 bool InjectedScriptManager::canAccessInspectedWorkerGlobalScope(ScriptState*) |
149 { | 133 { |
150 return true; | 134 return true; |
151 } | 135 } |
152 | 136 |
153 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) | 137 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) |
154 { | 138 { |
155 Vector<int> keys; | 139 Vector<int> keys; |
(...skipping 25 matching lines...) Expand all Loading... |
181 | 165 |
182 int id = injectedScriptIdFor(inspectedScriptState); | 166 int id = injectedScriptIdFor(inspectedScriptState); |
183 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource(
), inspectedScriptState, id); | 167 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource(
), inspectedScriptState, id); |
184 InjectedScript result(injectedScriptValue, m_inspectedStateAccessCheck); | 168 InjectedScript result(injectedScriptValue, m_inspectedStateAccessCheck); |
185 m_idToInjectedScript.set(id, result); | 169 m_idToInjectedScript.set(id, result); |
186 return result; | 170 return result; |
187 } | 171 } |
188 | 172 |
189 } // namespace blink | 173 } // namespace blink |
190 | 174 |
OLD | NEW |