Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2066)

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp

Issue 1811853002: [DevTools] Move evaluateOnCallFrame to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp
index e36ead08782b104735fb00a531a925a7ce2795e2..e45e7f013125e0043aab56733e6711989d352295 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptManager.cpp
@@ -185,4 +185,53 @@ v8::Local<v8::Object> InjectedScriptManager::createInjectedScript(const String16
return injectedScriptValue.As<v8::Object>();
}
+
+InjectedScriptManager::InjectScopeExtensionByName::InjectScopeExtensionByName(ErrorString* errorString, InjectedScript* injectedScript, bool injectToAll, const String16& name)
+ : m_isolate(injectedScript->isolate())
+ , m_symbol(V8Debugger::scopeExtensionSymbol(injectedScript->isolate()))
+ , m_context(injectedScript->context())
+ , m_globals(v8::Array::New(injectedScript->isolate()))
dgozman 2016/03/17 19:16:11 Let's not create array when we don't need it.
kozy 2016/03/17 20:48:56 Done.
+ , m_hasError(false)
+{
+ if (name.isEmpty())
+ return;
+
+ v8::Local<v8::Object> scopeExtension;
+ if (!injectedScript->scopeExtensionByName(errorString, name).ToLocal(&scopeExtension)) {
+ m_hasError = true;
+ return;
+ }
+
+ if (injectToAll) {
+ InjectedScriptManager::IdToInjectedScriptMap::iterator end = injectedScript->m_manager->m_idToInjectedScript.end();
+ for (InjectedScriptManager::IdToInjectedScriptMap::iterator it = injectedScript->m_manager->m_idToInjectedScript.begin(); it != end; ++it) {
+ if (it->second->canAccessInspectedWindow())
+ setOnGlobal(it->second->context()->Global(), scopeExtension);
+ }
+ } else {
+ setOnGlobal(m_context->Global(), scopeExtension);
+ }
+}
+
+InjectedScriptManager::InjectScopeExtensionByName::~InjectScopeExtensionByName()
+{
+ if (!m_globals->Length())
+ return;
+ v8::Local<v8::Symbol> scopeExtensionSymbolValue = V8Debugger::scopeExtensionSymbol(m_isolate);
+ for (size_t i = 0; i < m_globals->Length(); ++i) {
+ v8::Local<v8::Value> global;
+ bool success = m_globals->Get(m_context, i).ToLocal(&global);
dgozman 2016/03/17 19:16:11 Let's use vector.
kozy 2016/03/17 20:48:56 Done.
+ ASSERT_UNUSED(success, success);
+ global->ToObject(m_context).ToLocalChecked()->Delete(m_context, scopeExtensionSymbolValue);
+ }
+}
+
+void InjectedScriptManager::InjectScopeExtensionByName::setOnGlobal(v8::Local<v8::Object> global, v8::Local<v8::Object> scopeExtension)
+{
+ bool success = global->Set(m_context, m_symbol, scopeExtension).FromMaybe(false);
+ ASSERT_UNUSED(success, success);
+ success = m_globals->Set(m_context, m_globals->Length(), global).FromMaybe(false);
+ ASSERT_UNUSED(success, success);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698