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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp

Issue 2439013002: Implement cross-origin attributes using access check interceptors. (Closed)
Patch Set: Address feedback and fix cross-origin location set Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // The embedder could run arbitrary code in response to the 108 // The embedder could run arbitrary code in response to the
109 // willReleaseScriptContext callback, so all disposing should happen after 109 // willReleaseScriptContext callback, so all disposing should happen after
110 // it returns. 110 // it returns.
111 frame->loader().client()->willReleaseScriptContext(context, 111 frame->loader().client()->willReleaseScriptContext(context,
112 m_world->worldId()); 112 m_world->worldId());
113 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get()); 113 MainThreadDebugger::instance()->contextWillBeDestroyed(m_scriptState.get());
114 } 114 }
115 115
116 m_document.clear(); 116 m_document.clear();
117 117
118 if (behavior == DetachGlobal) 118 if (behavior == DetachGlobal) {
119 // Clean up state on the global proxy, which will be reused.
120 // TODO(dcheng): Check if this is needed.
121 V8DOMWrapper::clearNativeInfo(m_isolate, context->Global());
122 DCHECK(m_globalProxy == m_scriptState->context()->Global());
123 m_globalProxy.get().SetWrapperClassId(0);
119 m_scriptState->detachGlobalObject(); 124 m_scriptState->detachGlobalObject();
125 }
120 126
121 m_scriptState->disposePerContextData(); 127 m_scriptState->disposePerContextData();
122 128
123 // It's likely that disposing the context has created a lot of 129 // It's likely that disposing the context has created a lot of
124 // garbage. Notify V8 about this so it'll have a chance of cleaning 130 // garbage. Notify V8 about this so it'll have a chance of cleaning
125 // it up when idle. 131 // it up when idle.
126 V8GCForContextDispose::instance().notifyContextDisposed( 132 V8GCForContextDispose::instance().notifyContextDisposed(
127 m_frame->isMainFrame()); 133 m_frame->isMainFrame());
128 } 134 }
129 135
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // object is created together with a new v8::Context, but the global proxy 365 // object is created together with a new v8::Context, but the global proxy
360 // object doesn't change. 366 // object doesn't change.
361 // [3] WindowProperties is a named properties object of Window interface. 367 // [3] WindowProperties is a named properties object of Window interface.
362 368
363 DOMWindow* window = m_frame->domWindow(); 369 DOMWindow* window = m_frame->domWindow();
364 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); 370 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo();
365 371
366 v8::Local<v8::Context> context = m_scriptState->context(); 372 v8::Local<v8::Context> context = m_scriptState->context();
367 // The global proxy object. Note this is not the global object. 373 // The global proxy object. Note this is not the global object.
368 v8::Local<v8::Object> globalProxy = context->Global(); 374 v8::Local<v8::Object> globalProxy = context->Global();
375 V8DOMWrapper::setNativeInfo(m_isolate, globalProxy, wrapperTypeInfo, window);
376 // Mark the handle to be traced by Oilpan, since the global proxy has a
377 // reference to the DOMWindow.
378 DCHECK(m_globalProxy == globalProxy);
379 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId);
369 // The global object, aka window wrapper object. 380 // The global object, aka window wrapper object.
370 v8::Local<v8::Object> windowWrapper = 381 v8::Local<v8::Object> windowWrapper =
371 globalProxy->GetPrototype().As<v8::Object>(); 382 globalProxy->GetPrototype().As<v8::Object>();
372 windowWrapper = V8DOMWrapper::associateObjectWithWrapper( 383 windowWrapper = V8DOMWrapper::associateObjectWithWrapper(
373 m_isolate, window, wrapperTypeInfo, windowWrapper); 384 m_isolate, window, wrapperTypeInfo, windowWrapper);
374 // The prototype object of Window interface. 385 // The prototype object of Window interface.
375 v8::Local<v8::Object> windowPrototype = 386 v8::Local<v8::Object> windowPrototype =
376 windowWrapper->GetPrototype().As<v8::Object>(); 387 windowWrapper->GetPrototype().As<v8::Object>();
377 RELEASE_ASSERT(!windowPrototype.IsEmpty()); 388 RELEASE_ASSERT(!windowPrototype.IsEmpty());
378 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, 389 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 v8String(m_isolate, name)); 588 v8String(m_isolate, name));
578 } 589 }
579 590
580 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { 591 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) {
581 if (!isContextInitialized()) 592 if (!isContextInitialized())
582 return; 593 return;
583 setSecurityToken(origin); 594 setSecurityToken(origin);
584 } 595 }
585 596
586 } // namespace blink 597 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698