Index: third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h |
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h |
index a70c384d0242296dd1daa1e7f12bc0ca2fe7d931..7c8a518b036a00c77486361bd2c2900db684bf2a 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h |
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h |
@@ -17,22 +17,34 @@ |
namespace blink { |
class DOMWrapperWorld; |
-class SecurityOrigin; |
-class ScriptController; |
-class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> { |
+class CORE_EXPORT WindowProxyManagerBase |
+ : public GarbageCollected<WindowProxyManagerBase> { |
public: |
DECLARE_TRACE(); |
v8::Isolate* isolate() const { return m_isolate; } |
+ // Returns the global proxy for |world|'s WindowProxy. Note that it's possible |
+ // to return a non-empty global proxy for a detached WindowProxy. |
+ v8::Local<v8::Object> globalProxy(DOMWrapperWorld& world) { |
+ return possiblyUninitializedWindowProxy(world)->globalProxy(); |
+ } |
+ |
+ // Returns the v8::Context for |world|'s WindowProxy, initializing it first if |
+ // needed. This may not be called on a detached frame. |
+ v8::Local<v8::Context> context(DOMWrapperWorld& world) { |
+ DCHECK(frame()->client()); |
+ auto context = windowProxy(world)->contextIfInitialized(); |
+ DCHECK(!context.IsEmpty()); |
+ return context; |
+ } |
+ |
void clearForClose(); |
- void CORE_EXPORT clearForNavigation(); |
+ void clearForNavigation(); |
- void CORE_EXPORT |
- releaseGlobals(HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); |
- void CORE_EXPORT |
- setGlobals(const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); |
+ void releaseGlobals(HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); |
+ void setGlobals(const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>&); |
protected: |
using IsolatedWorldMap = HeapHashMap<int, Member<WindowProxy>>; |
@@ -40,12 +52,17 @@ class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> { |
explicit WindowProxyManagerBase(Frame&); |
Frame* frame() const { return m_frame; } |
+ // Note that this may return an uninitialized WindowProxy. |
WindowProxy* mainWorldProxy() const { return m_windowProxy.get(); } |
- WindowProxy* windowProxy(DOMWrapperWorld&); |
- |
IsolatedWorldMap& isolatedWorlds() { return m_isolatedWorlds; } |
+ // Returns the WindowProxy corresponding to |world|. The returned WindowProxy |
+ // is guaranteed to be initialized. |
+ WindowProxy* windowProxy(DOMWrapperWorld&); |
+ |
private: |
+ WindowProxy* possiblyUninitializedWindowProxy(DOMWrapperWorld&); |
+ |
v8::Isolate* const m_isolate; |
const Member<Frame> m_frame; |
const Member<WindowProxy> m_windowProxy; |
@@ -54,38 +71,29 @@ class WindowProxyManagerBase : public GarbageCollected<WindowProxyManagerBase> { |
template <typename FrameType, typename ProxyType> |
class WindowProxyManagerImplHelper : public WindowProxyManagerBase { |
- private: |
+ protected: |
using Base = WindowProxyManagerBase; |
- public: |
- FrameType* frame() const { return static_cast<FrameType*>(Base::frame()); } |
+ explicit WindowProxyManagerImplHelper(Frame& frame) |
+ : WindowProxyManagerBase(frame) {} |
+ |
+ // Note that this may return an uninitialized WindowProxy. |
ProxyType* mainWorldProxy() const { |
return static_cast<ProxyType*>(Base::mainWorldProxy()); |
} |
+ |
+ // Returns the WindowProxy corresponding to |world|. The returned WindowProxy |
+ // is guaranteed to be initialized. |
ProxyType* windowProxy(DOMWrapperWorld& world) { |
return static_cast<ProxyType*>(Base::windowProxy(world)); |
} |
- protected: |
- explicit WindowProxyManagerImplHelper(Frame& frame) |
- : WindowProxyManagerBase(frame) {} |
+ FrameType* frame() const { return static_cast<FrameType*>(Base::frame()); } |
}; |
class LocalWindowProxyManager |
: public WindowProxyManagerImplHelper<LocalFrame, LocalWindowProxy> { |
- public: |
- static LocalWindowProxyManager* create(LocalFrame& frame) { |
- return new LocalWindowProxyManager(frame); |
- } |
- |
- // Sets the given security origin to the main world's context. Also updates |
- // the security origin of the context for each isolated world. |
- void updateSecurityOrigin(SecurityOrigin*); |
- |
- private: |
- // TODO(dcheng): Merge LocalWindowProxyManager and ScriptController? |
- friend class ScriptController; |
- |
+ protected: |
explicit LocalWindowProxyManager(LocalFrame& frame) |
: WindowProxyManagerImplHelper<LocalFrame, LocalWindowProxy>(frame) {} |
}; |