| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 ++isolatedWorldCount; | 57 ++isolatedWorldCount; |
| 58 | 58 |
| 59 v8::HandleScope scope; | 59 v8::HandleScope scope; |
| 60 m_context = SharedPersistent<v8::Context>::create(proxy->createNewContext(v8
::Handle<v8::Object>(), extensionGroup)); | 60 m_context = SharedPersistent<v8::Context>::create(proxy->createNewContext(v8
::Handle<v8::Object>(), extensionGroup)); |
| 61 if (m_context->get().IsEmpty()) | 61 if (m_context->get().IsEmpty()) |
| 62 return; | 62 return; |
| 63 | 63 |
| 64 // Run code in the new context. | 64 // Run code in the new context. |
| 65 v8::Context::Scope context_scope(m_context->get()); | 65 v8::Context::Scope context_scope(m_context->get()); |
| 66 | 66 |
| 67 m_context->get()->Global()->SetHiddenValue(V8HiddenPropertyName::isolatedWor
ld(), v8::External::Wrap(this)); | 67 getGlobalObject(m_context->get())->SetPointerInInternalField(V8Custom::kDOMW
indowEnteredIsolatedWorldIndex, this); |
| 68 | 68 |
| 69 V8Proxy::installHiddenObjectPrototype(m_context->get()); | 69 V8Proxy::installHiddenObjectPrototype(m_context->get()); |
| 70 proxy->installDOMWindow(m_context->get(), proxy->frame()->domWindow()); | 70 proxy->installDOMWindow(m_context->get(), proxy->frame()->domWindow()); |
| 71 | 71 |
| 72 // Using the default security token means that the canAccess is always | 72 // Using the default security token means that the canAccess is always |
| 73 // called, which is slow. | 73 // called, which is slow. |
| 74 // FIXME: Use tokens where possible. This will mean keeping track of all | 74 // FIXME: Use tokens where possible. This will mean keeping track of all |
| 75 // created contexts so that they can all be updated when the | 75 // created contexts so that they can all be updated when the |
| 76 // document domain | 76 // document domain |
| 77 // changes. | 77 // changes. |
| 78 m_context->get()->UseDefaultSecurityToken(); | 78 m_context->get()->UseDefaultSecurityToken(); |
| 79 | 79 |
| 80 proxy->frame()->loader()->client()->didCreateIsolatedScriptContext(); | 80 proxy->frame()->loader()->client()->didCreateIsolatedScriptContext(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void V8IsolatedWorld::destroy() | 83 void V8IsolatedWorld::destroy() |
| 84 { | 84 { |
| 85 m_context->get().MakeWeak(this, &contextWeakReferenceCallback); | 85 m_context->get().MakeWeak(this, &contextWeakReferenceCallback); |
| 86 } | 86 } |
| 87 | 87 |
| 88 V8IsolatedWorld::~V8IsolatedWorld() | 88 V8IsolatedWorld::~V8IsolatedWorld() |
| 89 { | 89 { |
| 90 --isolatedWorldCount; | 90 --isolatedWorldCount; |
| 91 m_context->disposeHandle(); | 91 m_context->disposeHandle(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 V8IsolatedWorld* V8IsolatedWorld::getEnteredImpl() | |
| 95 { | |
| 96 if (!v8::Context::InContext()) | |
| 97 return 0; | |
| 98 v8::HandleScope scope; | |
| 99 | |
| 100 v8::Local<v8::Value> world = v8::Context::GetEntered()->Global()->GetHiddenV
alue(V8HiddenPropertyName::isolatedWorld()); | |
| 101 if (world.IsEmpty()) | |
| 102 return 0; | |
| 103 | |
| 104 return static_cast<V8IsolatedWorld*>(v8::External::Unwrap(world)); | |
| 105 } | |
| 106 | |
| 107 } // namespace WebCore | 94 } // namespace WebCore |
| OLD | NEW |