diff --git a/atom/browser/api/lib/web-contents.js b/atom/browser/api/lib/web-contents.js index 4055901a3f1..a670850f537 100644 --- a/atom/browser/api/lib/web-contents.js +++ b/atom/browser/api/lib/web-contents.js @@ -100,10 +100,6 @@ wrapWebContents = function(webContents) { // webContents has been loaded. const executeJavaScript = webContents.executeJavaScript; webContents.executeJavaScript = function(code, hasUserGesture) { - // TODO(zcbenz): Use default parameter after Chrome 49. - if (hasUserGesture === undefined) - hasUserGesture = false; - if (this.getURL() && !this.isLoading()) return executeJavaScript.call(this, code, hasUserGesture); else diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index fe11253bb56..ca4732ff365 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -122,9 +122,12 @@ void WebFrame::InsertText(const std::string& text) { web_frame_->insertText(blink::WebString::fromUTF8(text)); } -void WebFrame::ExecuteJavaScript(const base::string16& code, bool by_user) { +void WebFrame::ExecuteJavaScript(const base::string16& code, + mate::Arguments* args) { + bool has_user_gesture = false; + args->GetNext(&has_user_gesture); scoped_ptr gesture( - by_user ? new blink::WebScopedUserGesture : nullptr); + has_user_gesture ? new blink::WebScopedUserGesture : nullptr); web_frame_->executeScriptAndReturnValue(blink::WebScriptSource(code)); } diff --git a/atom/renderer/api/atom_api_web_frame.h b/atom/renderer/api/atom_api_web_frame.h index 632f6a51739..d55b24fd25e 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -64,7 +64,7 @@ class WebFrame : public mate::Wrappable { void InsertText(const std::string& text); // Excecuting scripts. - void ExecuteJavaScript(const base::string16& code, bool by_user); + void ExecuteJavaScript(const base::string16& code, mate::Arguments* args); // mate::Wrappable: virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(