Add webFrame.insertText API

This commit is contained in:
Cheng Zhao 2016-01-13 11:21:16 +08:00
parent d9d821cea5
commit 5567baf335
3 changed files with 15 additions and 1 deletions

View file

@ -116,6 +116,10 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme) {
privileged_scheme);
}
void WebFrame::InsertText(const std::string& text) {
web_frame_->insertText(blink::WebString::fromUTF8(text));
}
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
@ -136,7 +140,8 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
.SetMethod("registerURLSchemeAsBypassingCSP",
&WebFrame::RegisterURLSchemeAsBypassingCSP)
.SetMethod("registerURLSchemeAsPrivileged",
&WebFrame::RegisterURLSchemeAsPrivileged);
&WebFrame::RegisterURLSchemeAsPrivileged)
.SetMethod("insertText", &WebFrame::InsertText);
}
// static

View file

@ -60,6 +60,9 @@ class WebFrame : public mate::Wrappable {
void RegisterURLSchemeAsBypassingCSP(const std::string& scheme);
void RegisterURLSchemeAsPrivileged(const std::string& scheme);
// Editing.
void InsertText(const std::string& text);
// mate::Wrappable:
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate);

View file

@ -90,4 +90,10 @@ Content Security Policy.
Registers the `scheme` as secure, bypasses content security policy for resources,
allows registering ServiceWorker and supports fetch API.
### `webFrame.insertText(text)`
* `text` String
* Inserts `text` to the focused element.
[spellchecker]: https://github.com/atom/node-spellchecker