Handle default parameter of executeJavaScript in C++

This commit is contained in:
Cheng Zhao 2016-01-13 12:17:56 +08:00
parent 55dfddba77
commit 350c572a8c
3 changed files with 6 additions and 7 deletions

View file

@ -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

View file

@ -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<blink::WebScopedUserGesture> gesture(
by_user ? new blink::WebScopedUserGesture : nullptr);
has_user_gesture ? new blink::WebScopedUserGesture : nullptr);
web_frame_->executeScriptAndReturnValue(blink::WebScriptSource(code));
}

View file

@ -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(