| Index: third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
|
| index aeadf0611815e4309a02ae1ff14b3d0e32f98888..500557034989ca5fd6a91d5cec4df1d95a04007a 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
|
| @@ -35,6 +35,7 @@
|
| #include "core/CoreExport.h"
|
| #include "platform/weborigin/SecurityOrigin.h"
|
| #include "wtf/MainThread.h"
|
| +#include "wtf/OwnPtr.h"
|
| #include "wtf/PassRefPtr.h"
|
| #include "wtf/RefCounted.h"
|
| #include "wtf/RefPtr.h"
|
| @@ -60,6 +61,33 @@ template<typename T> class DOMObjectHolder;
|
| // This class represent a collection of DOM wrappers for a specific world.
|
| class CORE_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
|
| public:
|
| + class OriginWorldScope {
|
| + WTF_MAKE_NONCOPYABLE(OriginWorldScope);
|
| +
|
| + public:
|
| + explicit OriginWorldScope(PassRefPtr<DOMWrapperWorld> originWorld)
|
| + : m_hasPushed(false)
|
| + {
|
| + ASSERT(isMainThread());
|
| + if (originWorld) {
|
| + DOMWrapperWorld::originWorldStack().append(originWorld);
|
| + m_hasPushed = true;
|
| + }
|
| + }
|
| +
|
| + ~OriginWorldScope()
|
| + {
|
| + ASSERT(isMainThread());
|
| + // "Pop" the origin world to avoid tainting the entire document.
|
| + if (m_hasPushed) {
|
| + DOMWrapperWorld::originWorldStack().removeLast();
|
| + }
|
| + }
|
| +
|
| + private:
|
| + bool m_hasPushed;
|
| + };
|
| +
|
| static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, int worldId = -1, int extensionGroup = -1);
|
|
|
| static const int mainWorldExtensionGroup = 0;
|
| @@ -115,9 +143,23 @@ public:
|
| bool isPrivateScriptIsolatedWorld() const { return m_worldId == PrivateScriptIsolatedWorldId; }
|
| bool isWorkerWorld() const { return m_worldId == WorkerWorldId; }
|
| bool isIsolatedWorld() const { return MainWorldId < m_worldId && m_worldId < IsolatedWorldIdLimit; }
|
| + DOMWrapperWorld* originWorld()
|
| + {
|
| + if (isIsolatedWorld())
|
| + return this;
|
| + if (isMainThread() && !originWorldStack().isEmpty())
|
| + return originWorldStack().last().get();
|
| + return nullptr;
|
| + };
|
| + bool isOfIsolatedWorldOrigin() const
|
| + {
|
| + ASSERT(isMainThread());
|
| + return isIsolatedWorld() ? true : originWorldStack().isEmpty() ? false : originWorldStack().last().get()->isIsolatedWorld();
|
| + };
|
|
|
| int worldId() const { return m_worldId; }
|
| int extensionGroup() const { return m_extensionGroup; }
|
| +
|
| DOMDataStore& domDataStore() const { return *m_domDataStore; }
|
|
|
| static void setWorldOfInitializingWindow(DOMWrapperWorld* world)
|
| @@ -133,6 +175,8 @@ public:
|
| private:
|
| DOMWrapperWorld(v8::Isolate*, int worldId, int extensionGroup);
|
|
|
| + static Vector<RefPtr<DOMWrapperWorld>>& originWorldStack();
|
| +
|
| static void weakCallbackForDOMObjectHolder(const v8::WeakCallbackInfo<DOMObjectHolderBase>&);
|
| void registerDOMObjectHolderInternal(PassOwnPtr<DOMObjectHolderBase>);
|
| void unregisterDOMObjectHolder(DOMObjectHolderBase*);
|
|
|