| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/WindowProxyManager.h" | 5 #include "bindings/core/v8/WindowProxyManager.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 8 #include "bindings/core/v8/WindowProxy.h" | 8 #include "bindings/core/v8/WindowProxy.h" |
| 9 #include "core/frame/Frame.h" | 9 #include "core/frame/Frame.h" |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 for (auto& entry : m_isolatedWorlds) { | 54 for (auto& entry : m_isolatedWorlds) { |
| 55 WindowProxy* isolatedWindowProxy = entry.value.get(); | 55 WindowProxy* isolatedWindowProxy = entry.value.get(); |
| 56 if (!isolatedWindowProxy->isContextInitialized()) | 56 if (!isolatedWindowProxy->isContextInitialized()) |
| 57 continue; | 57 continue; |
| 58 SecurityOrigin* isolatedSecurityOrigin = | 58 SecurityOrigin* isolatedSecurityOrigin = |
| 59 isolatedWindowProxy->world().isolatedWorldSecurityOrigin(); | 59 isolatedWindowProxy->world().isolatedWorldSecurityOrigin(); |
| 60 isolatedWindowProxy->updateSecurityOrigin(isolatedSecurityOrigin); | 60 isolatedWindowProxy->updateSecurityOrigin(isolatedSecurityOrigin); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 WindowProxy* WindowProxyManager::existingWindowProxy(DOMWrapperWorld& world) { | |
| 65 if (world.isMainWorld()) | |
| 66 return m_windowProxy->isContextInitialized() ? m_windowProxy.get() | |
| 67 : nullptr; | |
| 68 | |
| 69 IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId()); | |
| 70 if (iter == m_isolatedWorlds.end()) | |
| 71 return nullptr; | |
| 72 return iter->value->isContextInitialized() ? iter->value.get() : nullptr; | |
| 73 } | |
| 74 | |
| 75 void WindowProxyManager::releaseGlobals( | 64 void WindowProxyManager::releaseGlobals( |
| 76 HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>& map) { | 65 HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>& map) { |
| 77 map.add(&m_windowProxy->world(), m_windowProxy->releaseGlobal()); | 66 map.add(&m_windowProxy->world(), m_windowProxy->releaseGlobal()); |
| 78 for (auto& entry : m_isolatedWorlds) | 67 for (auto& entry : m_isolatedWorlds) |
| 79 map.add(&entry.value->world(), | 68 map.add(&entry.value->world(), |
| 80 windowProxy(entry.value->world())->releaseGlobal()); | 69 windowProxy(entry.value->world())->releaseGlobal()); |
| 81 } | 70 } |
| 82 | 71 |
| 83 void WindowProxyManager::setGlobals( | 72 void WindowProxyManager::setGlobals( |
| 84 const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>& map) { | 73 const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>& map) { |
| 85 for (auto& entry : map) | 74 for (auto& entry : map) |
| 86 windowProxy(*entry.key)->setGlobal(entry.value); | 75 windowProxy(*entry.key)->setGlobal(entry.value); |
| 87 } | 76 } |
| 88 | 77 |
| 89 WindowProxyManager::WindowProxyManager(Frame& frame) | 78 WindowProxyManager::WindowProxyManager(Frame& frame) |
| 90 : m_frame(&frame), | 79 : m_frame(&frame), |
| 91 m_isolate(v8::Isolate::GetCurrent()), | 80 m_isolate(v8::Isolate::GetCurrent()), |
| 92 m_windowProxy(WindowProxy::create(m_isolate, | 81 m_windowProxy(WindowProxy::create(m_isolate, |
| 93 &frame, | 82 &frame, |
| 94 DOMWrapperWorld::mainWorld())) {} | 83 DOMWrapperWorld::mainWorld())) {} |
| 95 | 84 |
| 96 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |