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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp

Issue 1617393002: [DevTools] Not use with statement for evaluated console command (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix $1-$4, $_ Created 4 years, 11 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/bindings/core/v8/custom/V8WindowCustom.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
index 0105ff9fbe188e1bcd527955c719b5d5c0758cac..df9d8f625eb7e1294805d886ccf9eb2a82c6805b 100644
--- a/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8WindowCustom.cpp
@@ -55,7 +55,9 @@
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLDocument.h"
+#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/ScriptCallStack.h"
+#include "core/inspector/v8/V8InjectedScriptHost.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
@@ -295,6 +297,31 @@ static bool installTestInterfaceIfNeeded(LocalFrame& frame, v8::Local<v8::String
return false;
}
+static bool installCommandLineAPIIfNeeded(v8::Local<v8::Name> name, const AtomicString& nameString, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ if (!InspectorInstrumentation::hasFrontends())
+ return false;
+
+ if (!V8InjectedScriptHost::isCommandLineAPIMethod(nameString))
+ return false;
+
+ v8::Isolate* isolate = info.GetIsolate();
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+
+ v8::Local<v8::Object> global = context->Global();
+ v8::Local<v8::Value> commandLineAPI;
+
+ if (v8Call(global->Get(context, V8InjectedScriptHost::commandLineAPISymbol(isolate)), commandLineAPI)) {
+ v8::Local<v8::Value> value;
+ if (commandLineAPI->IsObject() && v8Call(commandLineAPI->ToObject(isolate)->Get(context, name), value)) {
+ v8SetReturnValue(info, value);
+ return true;
+ }
+ }
+
+ return false;
+}
+
void V8Window::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
auto nameString = name.As<v8::String>();
@@ -325,6 +352,9 @@ void V8Window::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::Pro
if (installTestInterfaceIfNeeded(toLocalFrame(*frame), nameString, info))
return;
+ if (installCommandLineAPIIfNeeded(name, propName, info))
+ return;
+
// Search named items in the document.
Document* doc = toLocalFrame(frame)->document();
if (!doc || !doc->isHTMLDocument())

Powered by Google App Engine
This is Rietveld 408576698