Handle default parameter of executeJavaScript in C++
This commit is contained in:
parent
55dfddba77
commit
350c572a8c
3 changed files with 6 additions and 7 deletions
|
@ -100,10 +100,6 @@ wrapWebContents = function(webContents) {
|
||||||
// webContents has been loaded.
|
// webContents has been loaded.
|
||||||
const executeJavaScript = webContents.executeJavaScript;
|
const executeJavaScript = webContents.executeJavaScript;
|
||||||
webContents.executeJavaScript = function(code, hasUserGesture) {
|
webContents.executeJavaScript = function(code, hasUserGesture) {
|
||||||
// TODO(zcbenz): Use default parameter after Chrome 49.
|
|
||||||
if (hasUserGesture === undefined)
|
|
||||||
hasUserGesture = false;
|
|
||||||
|
|
||||||
if (this.getURL() && !this.isLoading())
|
if (this.getURL() && !this.isLoading())
|
||||||
return executeJavaScript.call(this, code, hasUserGesture);
|
return executeJavaScript.call(this, code, hasUserGesture);
|
||||||
else
|
else
|
||||||
|
|
|
@ -122,9 +122,12 @@ void WebFrame::InsertText(const std::string& text) {
|
||||||
web_frame_->insertText(blink::WebString::fromUTF8(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<blink::WebScopedUserGesture> gesture(
|
scoped_ptr<blink::WebScopedUserGesture> gesture(
|
||||||
by_user ? new blink::WebScopedUserGesture : nullptr);
|
has_user_gesture ? new blink::WebScopedUserGesture : nullptr);
|
||||||
web_frame_->executeScriptAndReturnValue(blink::WebScriptSource(code));
|
web_frame_->executeScriptAndReturnValue(blink::WebScriptSource(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class WebFrame : public mate::Wrappable {
|
||||||
void InsertText(const std::string& text);
|
void InsertText(const std::string& text);
|
||||||
|
|
||||||
// Excecuting scripts.
|
// Excecuting scripts.
|
||||||
void ExecuteJavaScript(const base::string16& code, bool by_user);
|
void ExecuteJavaScript(const base::string16& code, mate::Arguments* args);
|
||||||
|
|
||||||
// mate::Wrappable:
|
// mate::Wrappable:
|
||||||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||||
|
|
Loading…
Reference in a new issue