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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.cpp

Issue 2630693002: Make ScriptController inherit LocalWindowProxyManager
Patch Set: rebase Created 3 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/WindowProxyManager.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.cpp b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.cpp
index 8e7a752720b45b56d834a48b14ccebe4d2bc6a43..c169ef2767828ac4e8ef9f131d025d23de6be4a8 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.cpp
@@ -12,7 +12,6 @@ namespace {
WindowProxy* createWindowProxyForFrame(v8::Isolate* isolate,
Frame& frame,
-
RefPtr<DOMWrapperWorld> world) {
if (frame.isLocalFrame()) {
return LocalWindowProxy::create(isolate, toLocalFrame(frame),
@@ -29,22 +28,6 @@ DEFINE_TRACE(WindowProxyManagerBase) {
visitor->trace(m_isolatedWorlds);
}
-WindowProxy* WindowProxyManagerBase::windowProxy(DOMWrapperWorld& world) {
- WindowProxy* windowProxy = nullptr;
- if (world.isMainWorld()) {
- windowProxy = m_windowProxy.get();
- } else {
- IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId());
- if (iter != m_isolatedWorlds.end()) {
- windowProxy = iter->value.get();
- } else {
- windowProxy = createWindowProxyForFrame(m_isolate, *m_frame, &world);
- m_isolatedWorlds.set(world.worldId(), windowProxy);
- }
- }
- return windowProxy;
-}
-
void WindowProxyManagerBase::clearForClose() {
m_windowProxy->clearForClose();
for (auto& entry : m_isolatedWorlds)
@@ -61,14 +44,16 @@ void WindowProxyManagerBase::releaseGlobals(
HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>& map) {
map.add(&m_windowProxy->world(), m_windowProxy->releaseGlobal());
for (auto& entry : m_isolatedWorlds)
- map.add(&entry.value->world(),
- windowProxy(entry.value->world())->releaseGlobal());
+ map.add(&entry.value->world(), entry.value->releaseGlobal());
}
void WindowProxyManagerBase::setGlobals(
const HashMap<DOMWrapperWorld*, v8::Local<v8::Object>>& map) {
+ // Note: it's important not to initialize the WindowProxy before SetGlobal()
+ // is called. Otherwise, the global proxy object the WindowProxy thinks it has
+ // and the global proxy object of any actual v8 contexts will not match!
for (auto& entry : map)
- windowProxy(*entry.key)->setGlobal(entry.value);
+ possiblyUninitializedWindowProxy(*entry.key)->setGlobal(entry.value);
}
WindowProxyManagerBase::WindowProxyManagerBase(Frame& frame)
@@ -78,17 +63,27 @@ WindowProxyManagerBase::WindowProxyManagerBase(Frame& frame)
frame,
&DOMWrapperWorld::mainWorld())) {}
-void LocalWindowProxyManager::updateSecurityOrigin(
- SecurityOrigin* securityOrigin) {
- static_cast<LocalWindowProxy*>(mainWorldProxy())
- ->updateSecurityOrigin(securityOrigin);
- for (auto& entry : isolatedWorlds()) {
- auto* isolatedWindowProxy =
- static_cast<LocalWindowProxy*>(entry.value.get());
- SecurityOrigin* isolatedSecurityOrigin =
- isolatedWindowProxy->world().isolatedWorldSecurityOrigin();
- isolatedWindowProxy->updateSecurityOrigin(isolatedSecurityOrigin);
+WindowProxy* WindowProxyManagerBase::windowProxy(DOMWrapperWorld& world) {
+ WindowProxy* windowProxy = possiblyUninitializedWindowProxy(world);
+ windowProxy->initializeIfNeeded();
+ return windowProxy;
+}
+
+WindowProxy* WindowProxyManagerBase::possiblyUninitializedWindowProxy(
+ DOMWrapperWorld& world) {
+ WindowProxy* windowProxy = nullptr;
+ if (world.isMainWorld()) {
+ windowProxy = m_windowProxy.get();
+ } else {
+ IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId());
+ if (iter != m_isolatedWorlds.end()) {
+ windowProxy = iter->value.get();
+ } else {
+ windowProxy = createWindowProxyForFrame(m_isolate, *m_frame, &world);
+ m_isolatedWorlds.set(world.worldId(), windowProxy);
+ }
}
+ return windowProxy;
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h ('k') | third_party/WebKit/Source/core/frame/DOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698