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

Side by Side Diff: sky/engine/bindings/core/v8/WindowProxy.cpp

Issue 863253002: Update from https://crrev.com/312600 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void WindowProxy::clearForNavigation() 103 void WindowProxy::clearForNavigation()
104 { 104 {
105 if (!isContextInitialized()) 105 if (!isContextInitialized())
106 return; 106 return;
107 107
108 ScriptState::Scope scope(m_scriptState.get()); 108 ScriptState::Scope scope(m_scriptState.get());
109 109
110 m_document.clear(); 110 m_document.clear();
111 111
112 // Clear the document wrapper cache before turning on access checks on
113 // the old LocalDOMWindow wrapper. This way, access to the document wrapper
114 // will be protected by the security checks on the LocalDOMWindow wrapper.
115 clearDocumentProperty();
116
117 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai n(m_global.newLocal(m_isolate), m_isolate); 112 v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChai n(m_global.newLocal(m_isolate), m_isolate);
118 ASSERT(!windowWrapper.IsEmpty()); 113 ASSERT(!windowWrapper.IsEmpty());
119 windowWrapper->TurnOnAccessCheck(); 114 windowWrapper->TurnOnAccessCheck();
120 disposeContext(DetachGlobal); 115 disposeContext(DetachGlobal);
121 } 116 }
122 117
123 // Create a new environment and setup the global object. 118 // Create a new environment and setup the global object.
124 // 119 //
125 // The global object corresponds to a LocalDOMWindow instance. However, to 120 // The global object corresponds to a LocalDOMWindow instance. However, to
126 // allow properties of the JS LocalDOMWindow instance to be shadowed, we 121 // allow properties of the JS LocalDOMWindow instance to be shadowed, we
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 276
282 void WindowProxy::updateDocumentProperty() 277 void WindowProxy::updateDocumentProperty()
283 { 278 {
284 ScriptState::Scope scope(m_scriptState.get()); 279 ScriptState::Scope scope(m_scriptState.get());
285 v8::Handle<v8::Context> context = m_scriptState->context(); 280 v8::Handle<v8::Context> context = m_scriptState->context();
286 v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document(), context->G lobal(), context->GetIsolate()); 281 v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document(), context->G lobal(), context->GetIsolate());
287 ASSERT(documentWrapper == m_document.newLocal(m_isolate) || m_document.isEmp ty()); 282 ASSERT(documentWrapper == m_document.newLocal(m_isolate) || m_document.isEmp ty());
288 if (m_document.isEmpty()) 283 if (m_document.isEmpty())
289 updateDocumentWrapper(v8::Handle<v8::Object>::Cast(documentWrapper)); 284 updateDocumentWrapper(v8::Handle<v8::Object>::Cast(documentWrapper));
290 285
291 // If instantiation of the document wrapper fails, clear the cache
292 // and let the LocalDOMWindow accessor handle access to the document.
293 if (documentWrapper.IsEmpty()) {
294 clearDocumentProperty();
295 return;
296 }
297 ASSERT(documentWrapper->IsObject()); 286 ASSERT(documentWrapper->IsObject());
298 context->Global()->ForceSet(v8AtomicString(m_isolate, "document"), documentW rapper, static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); 287 context->Global()->ForceSet(v8AtomicString(m_isolate, "document"), documentW rapper, static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
299 288
300 // We also stash a reference to the document on the inner global object so t hat 289 // We also stash a reference to the document on the inner global object so t hat
301 // LocalDOMWindow objects we obtain from JavaScript references are guarantee d to have 290 // LocalDOMWindow objects we obtain from JavaScript references are guarantee d to have
302 // live Document objects. 291 // live Document objects.
303 V8HiddenValue::setHiddenValue(m_isolate, toInnerGlobalObject(context), V8Hid denValue::document(m_isolate), documentWrapper); 292 V8HiddenValue::setHiddenValue(m_isolate, toInnerGlobalObject(context), V8Hid denValue::document(m_isolate), documentWrapper);
304 } 293 }
305 294
306 void WindowProxy::clearDocumentProperty()
307 {
308 ASSERT(isContextInitialized());
309 if (!m_world->isMainWorld())
310 return;
311 v8::HandleScope handleScope(m_isolate);
312 m_scriptState->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "d ocument"));
313 }
314
315 void WindowProxy::updateDocument() 295 void WindowProxy::updateDocument()
316 { 296 {
317 ASSERT(m_world->isMainWorld()); 297 ASSERT(m_world->isMainWorld());
318 if (!isGlobalInitialized()) 298 if (!isGlobalInitialized())
319 return; 299 return;
320 if (!isContextInitialized()) 300 if (!isContextInitialized())
321 return; 301 return;
322 updateDocumentProperty(); 302 updateDocumentProperty();
323 } 303 }
324 304
325 } // namespace blink 305 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698