Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h

Issue 1615523002: Transitively keep track of an isolated world's children scripts and worlds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..36f0ae4506bce28d4142416f32967ba0d2d60e17 100644
--- a/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
+++ b/third_party/WebKit/Source/bindings/core/v8/DOMWrapperWorld.h
@@ -60,6 +60,29 @@ 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 OriginWorldPusher {
+ WTF_MAKE_NONCOPYABLE(OriginWorldPusher);
+
+ public:
+ explicit OriginWorldPusher(DOMWrapperWorld& currentWorld, PassRefPtr<DOMWrapperWorld> originWorld)
+ : m_oldOriginWorld(currentWorld.m_originWorld)
+ , m_currentWorld(currentWorld)
+ {
+ // "Push" the origin world.
+ currentWorld.setOriginWorld(originWorld);
+ }
+
+ ~OriginWorldPusher()
+ {
+ // "Pop" the origin world to avoid tainting the entire document.
+ m_currentWorld.setOriginWorld(m_oldOriginWorld);
+ }
+
+ private:
+ RefPtr<DOMWrapperWorld> m_oldOriginWorld;
+ DOMWrapperWorld& m_currentWorld;
haraken 2016/01/21 10:16:15 I'm wondering if we could simplify the logic aroun
Joe Mason 2016/01/21 16:13:50 That seems more complicated to me rather than simp
+ };
+
static PassRefPtr<DOMWrapperWorld> create(v8::Isolate*, int worldId = -1, int extensionGroup = -1);
static const int mainWorldExtensionGroup = 0;
@@ -115,9 +138,22 @@ 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; }
+ void setOriginWorld(PassRefPtr<DOMWrapperWorld> originWorld)
+ {
+ m_originWorld = originWorld;
+ };
+ DOMWrapperWorld* originWorld()
+ {
+ return isIsolatedWorld() ? this : m_originWorld.get();
+ };
+ bool isOfIsolatedWorldOrigin() const
+ {
+ return isIsolatedWorld() || (m_originWorld && m_originWorld->isIsolatedWorld());
+ };
int worldId() const { return m_worldId; }
int extensionGroup() const { return m_extensionGroup; }
+
DOMDataStore& domDataStore() const { return *m_domDataStore; }
static void setWorldOfInitializingWindow(DOMWrapperWorld* world)
@@ -142,6 +178,7 @@ private:
const int m_worldId;
const int m_extensionGroup;
+ RefPtr<DOMWrapperWorld> m_originWorld;
OwnPtr<DOMDataStore> m_domDataStore;
HashSet<OwnPtr<DOMObjectHolderBase>> m_domObjectHolders;
};

Powered by Google App Engine
This is Rietveld 408576698