| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
| 4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; | 174 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; |
| 175 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); | 175 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); |
| 176 v8::Local<v8::Value> injectedScriptValue; | 176 v8::Local<v8::Value> injectedScriptValue; |
| 177 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL
ocal(&injectedScriptValue)) | 177 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL
ocal(&injectedScriptValue)) |
| 178 return v8::Local<v8::Object>(); | 178 return v8::Local<v8::Object>(); |
| 179 if (!injectedScriptValue->IsObject()) | 179 if (!injectedScriptValue->IsObject()) |
| 180 return v8::Local<v8::Object>(); | 180 return v8::Local<v8::Object>(); |
| 181 return injectedScriptValue.As<v8::Object>(); | 181 return injectedScriptValue.As<v8::Object>(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 | |
| 185 InjectedScriptManager::ScopedGlobalObjectExtension::ScopedGlobalObjectExtension(
InjectedScript* current, InjectedScriptManager* manager, v8::MaybeLocal<v8::Obje
ct> extension) | |
| 186 : m_context(current->context()) | |
| 187 { | |
| 188 v8::Local<v8::Object> extensionObject; | |
| 189 if (!extension.ToLocal(&extensionObject)) | |
| 190 return; | |
| 191 | |
| 192 m_symbol = V8Debugger::scopeExtensionSymbol(current->isolate()); | |
| 193 if (!manager) { | |
| 194 setOnGlobal(current->context()->Global(), extensionObject); | |
| 195 } else { | |
| 196 InjectedScriptManager::IdToInjectedScriptMap::iterator end = manager->m_
idToInjectedScript.end(); | |
| 197 for (InjectedScriptManager::IdToInjectedScriptMap::iterator it = manager
->m_idToInjectedScript.begin(); it != end; ++it) { | |
| 198 if (it->second->canAccessInspectedWindow()) | |
| 199 setOnGlobal(it->second->context()->Global(), extensionObject); | |
| 200 } | |
| 201 } | |
| 202 } | |
| 203 | |
| 204 InjectedScriptManager::ScopedGlobalObjectExtension::~ScopedGlobalObjectExtension
() | |
| 205 { | |
| 206 for (size_t i = 0; i < m_globals.size(); ++i) | |
| 207 m_globals[i]->ToObject(m_context).ToLocalChecked()->Delete(m_context, m_
symbol); | |
| 208 } | |
| 209 | |
| 210 void InjectedScriptManager::ScopedGlobalObjectExtension::setOnGlobal(v8::Local<v
8::Object> global, v8::Local<v8::Object> extension) | |
| 211 { | |
| 212 if (global->Set(m_context, m_symbol, extension).FromMaybe(false)) | |
| 213 m_globals.append(global); | |
| 214 } | |
| 215 | |
| 216 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |