| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 context->SetErrorMessageForCodeGenerationFromStrings( | 110 context->SetErrorMessageForCodeGenerationFromStrings( |
| 111 v8String(isolate(), csp->evalDisabledErrorMessage())); | 111 v8String(isolate(), csp->evalDisabledErrorMessage())); |
| 112 } else { | 112 } else { |
| 113 updateActivityLogger(); | 113 updateActivityLogger(); |
| 114 origin = m_world->isolatedWorldSecurityOrigin(); | 114 origin = m_world->isolatedWorldSecurityOrigin(); |
| 115 setSecurityToken(origin); | 115 setSecurityToken(origin); |
| 116 } | 116 } |
| 117 | 117 |
| 118 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame(), | 118 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame(), |
| 119 origin); | 119 origin); |
| 120 frame()->loader().client()->didCreateScriptContext( | 120 frame()->loader().client()->didCreateScriptContext(context, |
| 121 context, m_world->extensionGroup(), m_world->worldId()); | 121 m_world->worldId()); |
| 122 // If conditional features for window have been queued before the V8 context | 122 // If conditional features for window have been queued before the V8 context |
| 123 // was ready, then inject them into the context now | 123 // was ready, then inject them into the context now |
| 124 if (m_world->isMainWorld()) { | 124 if (m_world->isMainWorld()) { |
| 125 installPendingConditionalFeaturesOnWindow(m_scriptState.get()); | 125 installPendingConditionalFeaturesOnWindow(m_scriptState.get()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 if (m_world->isMainWorld()) | 128 if (m_world->isMainWorld()) |
| 129 frame()->loader().dispatchDidClearWindowObjectInMainWorld(); | 129 frame()->loader().dispatchDidClearWindowObjectInMainWorld(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void LocalWindowProxy::createContext() { | 132 void LocalWindowProxy::createContext() { |
| 133 // Create a new v8::Context with the window object as the global object | 133 // Create a new v8::Context with the window object as the global object |
| 134 // (aka the inner global). Reuse the global proxy object (aka the outer | 134 // (aka the inner global). Reuse the global proxy object (aka the outer |
| 135 // global) if it already exists. See the comments in | 135 // global) if it already exists. See the comments in |
| 136 // setupWindowPrototypeChain for the structure of the prototype chain of | 136 // setupWindowPrototypeChain for the structure of the prototype chain of |
| 137 // the global object. | 137 // the global object. |
| 138 v8::Local<v8::ObjectTemplate> globalTemplate = | 138 v8::Local<v8::ObjectTemplate> globalTemplate = |
| 139 V8Window::domTemplate(isolate(), *m_world)->InstanceTemplate(); | 139 V8Window::domTemplate(isolate(), *m_world)->InstanceTemplate(); |
| 140 CHECK(!globalTemplate.IsEmpty()); | 140 CHECK(!globalTemplate.IsEmpty()); |
| 141 | 141 |
| 142 // FIXME: It's not clear what the right thing to do for remote frames is. | |
| 143 // The extensions registered don't generally seem to make sense for remote | |
| 144 // frames, so skip it for now. | |
| 145 Vector<const char*> extensionNames; | 142 Vector<const char*> extensionNames; |
| 146 // Dynamically tell v8 about our extensions now. | 143 // Dynamically tell v8 about our extensions now. |
| 147 const V8Extensions& extensions = ScriptController::registeredExtensions(); | 144 if (frame()->loader().client()->allowScriptExtensions()) { |
| 148 extensionNames.reserveInitialCapacity(extensions.size()); | 145 const V8Extensions& extensions = ScriptController::registeredExtensions(); |
| 149 int extensionGroup = m_world->extensionGroup(); | 146 extensionNames.reserveInitialCapacity(extensions.size()); |
| 150 int worldId = m_world->worldId(); | 147 for (const auto* extension : extensions) |
| 151 for (const auto* extension : extensions) { | 148 extensionNames.push_back(extension->name()); |
| 152 if (!frame()->loader().client()->allowScriptExtension( | |
| 153 extension->name(), extensionGroup, worldId)) | |
| 154 continue; | |
| 155 | |
| 156 extensionNames.push_back(extension->name()); | |
| 157 } | 149 } |
| 158 v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), | 150 v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), |
| 159 extensionNames.data()); | 151 extensionNames.data()); |
| 160 | 152 |
| 161 v8::Local<v8::Context> context; | 153 v8::Local<v8::Context> context; |
| 162 { | 154 { |
| 163 V8PerIsolateData::UseCounterDisabledScope useCounterDisabled( | 155 V8PerIsolateData::UseCounterDisabledScope useCounterDisabled( |
| 164 V8PerIsolateData::from(isolate())); | 156 V8PerIsolateData::from(isolate())); |
| 165 context = | 157 context = |
| 166 v8::Context::New(isolate(), &extensionConfiguration, globalTemplate, | 158 v8::Context::New(isolate(), &extensionConfiguration, globalTemplate, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 353 |
| 362 setSecurityToken(origin); | 354 setSecurityToken(origin); |
| 363 } | 355 } |
| 364 | 356 |
| 365 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, | 357 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, |
| 366 LocalFrame& frame, | 358 LocalFrame& frame, |
| 367 RefPtr<DOMWrapperWorld> world) | 359 RefPtr<DOMWrapperWorld> world) |
| 368 : WindowProxy(isolate, frame, std::move(world)) {} | 360 : WindowProxy(isolate, frame, std::move(world)) {} |
| 369 | 361 |
| 370 } // namespace blink | 362 } // namespace blink |
| OLD | NEW |