Chromium Code Reviews| 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 #ifndef WindowProxyManager_h | 5 #ifndef WindowProxyManager_h |
| 6 #define WindowProxyManager_h | 6 #define WindowProxyManager_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/LocalWindowProxy.h" | 8 #include "bindings/core/v8/LocalWindowProxy.h" |
| 9 #include "bindings/core/v8/RemoteWindowProxy.h" | 9 #include "bindings/core/v8/RemoteWindowProxy.h" |
| 10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 void clearForClose(); | 29 void clearForClose(); |
| 30 void CORE_EXPORT clearForNavigation(); | 30 void CORE_EXPORT clearForNavigation(); |
| 31 | 31 |
| 32 void CORE_EXPORT | 32 void CORE_EXPORT |
| 33 releaseGlobals(HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); | 33 releaseGlobals(HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); |
| 34 void CORE_EXPORT | 34 void CORE_EXPORT |
| 35 setGlobals(const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); | 35 setGlobals(const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); |
| 36 | 36 |
| 37 protected: | 37 protected: |
| 38 friend v8::Local<v8::Value> ToV8(WindowProxyManagerBase*, | |
|
dcheng
2017/01/18 07:02:00
Since this is a temporary hack, I've opted to just
| |
| 39 v8::Local<v8::Object> creationContext, | |
| 40 v8::Isolate*); | |
| 41 | |
| 38 using IsolatedWorldMap = HeapHashMap<int, Member<WindowProxy>>; | 42 using IsolatedWorldMap = HeapHashMap<int, Member<WindowProxy>>; |
| 39 | 43 |
| 40 explicit WindowProxyManagerBase(Frame&); | 44 explicit WindowProxyManagerBase(Frame&); |
| 41 | 45 |
| 42 Frame* frame() const { return m_frame; } | 46 Frame* frame() const { return m_frame; } |
| 43 WindowProxy* mainWorldProxy() const { return m_windowProxy.get(); } | 47 WindowProxy* mainWorldProxy() const { return m_windowProxy.get(); } |
| 44 WindowProxy* windowProxy(DOMWrapperWorld&); | 48 WindowProxy* windowProxy(DOMWrapperWorld&); |
| 45 | 49 |
| 46 IsolatedWorldMap& isolatedWorlds() { return m_isolatedWorlds; } | 50 IsolatedWorldMap& isolatedWorlds() { return m_isolatedWorlds; } |
| 47 | 51 |
| 48 private: | 52 private: |
| 49 v8::Isolate* const m_isolate; | 53 v8::Isolate* const m_isolate; |
| 50 const Member<Frame> m_frame; | 54 const Member<Frame> m_frame; |
| 51 const Member<WindowProxy> m_windowProxy; | 55 const Member<WindowProxy> m_windowProxy; |
| 52 IsolatedWorldMap m_isolatedWorlds; | 56 IsolatedWorldMap m_isolatedWorlds; |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 template <typename FrameType, typename ProxyType> | 59 template <typename FrameType, typename ProxyType> |
| 56 class WindowProxyManagerImplHelper : public WindowProxyManagerBase { | 60 class WindowProxyManagerImplHelper : public WindowProxyManagerBase { |
| 57 private: | 61 private: |
| 58 using Base = WindowProxyManagerBase; | 62 using Base = WindowProxyManagerBase; |
| 59 | 63 |
| 60 public: | 64 public: |
| 61 FrameType* frame() const { return static_cast<FrameType*>(Base::frame()); } | |
| 62 ProxyType* mainWorldProxy() const { | 65 ProxyType* mainWorldProxy() const { |
| 63 return static_cast<ProxyType*>(Base::mainWorldProxy()); | 66 return static_cast<ProxyType*>(Base::mainWorldProxy()); |
| 64 } | 67 } |
| 65 ProxyType* windowProxy(DOMWrapperWorld& world) { | 68 ProxyType* windowProxy(DOMWrapperWorld& world) { |
| 66 return static_cast<ProxyType*>(Base::windowProxy(world)); | 69 return static_cast<ProxyType*>(Base::windowProxy(world)); |
| 67 } | 70 } |
| 68 | 71 |
| 69 protected: | 72 protected: |
| 70 explicit WindowProxyManagerImplHelper(Frame& frame) | 73 explicit WindowProxyManagerImplHelper(Frame& frame) |
| 71 : WindowProxyManagerBase(frame) {} | 74 : WindowProxyManagerBase(frame) {} |
| 75 | |
| 76 FrameType* frame() const { return static_cast<FrameType*>(Base::frame()); } | |
|
dcheng
2017/01/18 07:02:00
To avoid DOMWindow from getting frame() from its w
| |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 class LocalWindowProxyManager | 79 class LocalWindowProxyManager |
| 75 : public WindowProxyManagerImplHelper<LocalFrame, LocalWindowProxy> { | 80 : public WindowProxyManagerImplHelper<LocalFrame, LocalWindowProxy> { |
| 76 public: | 81 public: |
| 77 static LocalWindowProxyManager* create(LocalFrame& frame) { | 82 static LocalWindowProxyManager* create(LocalFrame& frame) { |
| 78 return new LocalWindowProxyManager(frame); | 83 return new LocalWindowProxyManager(frame); |
| 79 } | 84 } |
| 80 | 85 |
| 81 // Sets the given security origin to the main world's context. Also updates | 86 // Sets the given security origin to the main world's context. Also updates |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 98 } | 103 } |
| 99 | 104 |
| 100 private: | 105 private: |
| 101 explicit RemoteWindowProxyManager(RemoteFrame& frame) | 106 explicit RemoteWindowProxyManager(RemoteFrame& frame) |
| 102 : WindowProxyManagerImplHelper<RemoteFrame, RemoteWindowProxy>(frame) {} | 107 : WindowProxyManagerImplHelper<RemoteFrame, RemoteWindowProxy>(frame) {} |
| 103 }; | 108 }; |
| 104 | 109 |
| 105 } // namespace blink | 110 } // namespace blink |
| 106 | 111 |
| 107 #endif // WindowProxyManager_h | 112 #endif // WindowProxyManager_h |
| OLD | NEW |