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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; | 178 v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number:
:New(context->GetIsolate(), id) }; |
179 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); | 179 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM
icrotasks); |
180 v8::Local<v8::Value> injectedScriptValue; | 180 v8::Local<v8::Value> injectedScriptValue; |
181 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL
ocal(&injectedScriptValue)) | 181 if (!function->Call(context, windowGlobal, WTF_ARRAY_LENGTH(info), info).ToL
ocal(&injectedScriptValue)) |
182 return v8::Local<v8::Object>(); | 182 return v8::Local<v8::Object>(); |
183 if (!injectedScriptValue->IsObject()) | 183 if (!injectedScriptValue->IsObject()) |
184 return v8::Local<v8::Object>(); | 184 return v8::Local<v8::Object>(); |
185 return injectedScriptValue.As<v8::Object>(); | 185 return injectedScriptValue.As<v8::Object>(); |
186 } | 186 } |
187 | 187 |
| 188 |
| 189 InjectedScriptManager::ScopedGlobalObjectExtension::ScopedGlobalObjectExtension(
InjectedScript* current, InjectedScriptManager* manager, v8::MaybeLocal<v8::Obje
ct> extension) |
| 190 : m_context(current->context()) |
| 191 { |
| 192 v8::Local<v8::Object> extensionObject; |
| 193 if (!extension.ToLocal(&extensionObject)) |
| 194 return; |
| 195 |
| 196 m_symbol = V8Debugger::scopeExtensionSymbol(current->isolate()); |
| 197 if (!manager) { |
| 198 setOnGlobal(current->context()->Global(), extensionObject); |
| 199 } else { |
| 200 InjectedScriptManager::IdToInjectedScriptMap::iterator end = manager->m_
idToInjectedScript.end(); |
| 201 for (InjectedScriptManager::IdToInjectedScriptMap::iterator it = manager
->m_idToInjectedScript.begin(); it != end; ++it) { |
| 202 if (it->second->canAccessInspectedWindow()) |
| 203 setOnGlobal(it->second->context()->Global(), extensionObject); |
| 204 } |
| 205 } |
| 206 } |
| 207 |
| 208 InjectedScriptManager::ScopedGlobalObjectExtension::~ScopedGlobalObjectExtension
() |
| 209 { |
| 210 for (size_t i = 0; i < m_globals.size(); ++i) |
| 211 m_globals[i]->ToObject(m_context).ToLocalChecked()->Delete(m_context, m_
symbol); |
| 212 } |
| 213 |
| 214 void InjectedScriptManager::ScopedGlobalObjectExtension::setOnGlobal(v8::Local<v
8::Object> global, v8::Local<v8::Object> extension) |
| 215 { |
| 216 if (global->Set(m_context, m_symbol, extension).FromMaybe(false)) |
| 217 m_globals.append(global); |
| 218 } |
| 219 |
188 } // namespace blink | 220 } // namespace blink |
OLD | NEW |