| OLD | NEW |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #include "wtf/text/CString.h" | 60 #include "wtf/text/CString.h" |
| 61 #include <algorithm> | 61 #include <algorithm> |
| 62 #include <utility> | 62 #include <utility> |
| 63 #include <v8-debug.h> | 63 #include <v8-debug.h> |
| 64 #include <v8.h> | 64 #include <v8.h> |
| 65 | 65 |
| 66 namespace WebCore { | 66 namespace WebCore { |
| 67 | 67 |
| 68 static bool contextBeingInitialized = false; | 68 static bool contextBeingInitialized = false; |
| 69 | 69 |
| 70 bool V8WindowShell::contextIsBeingInitialized() |
| 71 { |
| 72 return contextBeingInitialized; |
| 73 } |
| 74 |
| 70 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum
ent) | 75 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum
ent) |
| 71 { | 76 { |
| 72 ASSERT(V8Document::toNative(wrapper) == document); | 77 ASSERT(V8Document::toNative(wrapper) == document); |
| 73 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O
bject>::Cast(wrapper->GetPrototype())) == document)); | 78 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O
bject>::Cast(wrapper->GetPrototype())) == document)); |
| 74 } | 79 } |
| 75 | 80 |
| 76 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex
t, int debugId) | 81 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex
t, int debugId) |
| 77 { | 82 { |
| 78 V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugI
d); | 83 V8PerContextDebugData::setContextDebugData(targetContext, "injected", debugI
d); |
| 79 } | 84 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // the frame. However, a new inner window is created for the new page. | 186 // the frame. However, a new inner window is created for the new page. |
| 182 // If there are JS code holds a closure to the old inner window, | 187 // If there are JS code holds a closure to the old inner window, |
| 183 // it won't be able to reach the outer window via its global object. | 188 // it won't be able to reach the outer window via its global object. |
| 184 bool V8WindowShell::initializeIfNeeded() | 189 bool V8WindowShell::initializeIfNeeded() |
| 185 { | 190 { |
| 186 if (m_contextHolder) | 191 if (m_contextHolder) |
| 187 return true; | 192 return true; |
| 188 | 193 |
| 189 ASSERT(!contextBeingInitialized); | 194 ASSERT(!contextBeingInitialized); |
| 190 contextBeingInitialized = true; | 195 contextBeingInitialized = true; |
| 196 DOMWrapperWorld::setWorldOfInitializingWindow(m_world.get()); |
| 191 bool result = initialize(); | 197 bool result = initialize(); |
| 192 contextBeingInitialized = false; | 198 contextBeingInitialized = false; |
| 199 DOMWrapperWorld::setWorldOfInitializingWindow(0); |
| 193 return result; | 200 return result; |
| 194 } | 201 } |
| 195 | 202 |
| 196 bool V8WindowShell::initialize() | 203 bool V8WindowShell::initialize() |
| 197 { | 204 { |
| 198 TRACE_EVENT0("v8", "V8WindowShell::initialize"); | 205 TRACE_EVENT0("v8", "V8WindowShell::initialize"); |
| 199 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "InitializeWindow"); | 206 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "InitializeWindow"); |
| 200 | 207 |
| 201 v8::HandleScope handleScope(m_isolate); | 208 v8::HandleScope handleScope(m_isolate); |
| 202 | 209 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 512 |
| 506 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin) | 513 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin) |
| 507 { | 514 { |
| 508 ASSERT(m_world->isMainWorld()); | 515 ASSERT(m_world->isMainWorld()); |
| 509 if (!m_contextHolder) | 516 if (!m_contextHolder) |
| 510 return; | 517 return; |
| 511 v8::HandleScope handleScope(m_isolate); | 518 v8::HandleScope handleScope(m_isolate); |
| 512 setSecurityToken(origin); | 519 setSecurityToken(origin); |
| 513 } | 520 } |
| 514 | 521 |
| 515 bool V8WindowShell::contextHasCorrectPrototype(v8::Handle<v8::Context> context) | |
| 516 { | |
| 517 if (!isMainThread()) | |
| 518 return true; | |
| 519 // We're initializing the context, so it is not yet in a status where we can | |
| 520 // validate the context. | |
| 521 if (contextBeingInitialized) | |
| 522 return true; | |
| 523 return !!toDOMWindow(context); | |
| 524 } | |
| 525 | |
| 526 } // WebCore | 522 } // WebCore |
| OLD | NEW |