Add webFrame.setSpellCheckClient API
This commit is contained in:
parent
896077222d
commit
f1fbc5c701
4 changed files with 19 additions and 3 deletions
|
@ -9,7 +9,7 @@ namespace atom {
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
SpellCheckClient::SpellCheckClient(v8::Isolate* isolate,
|
SpellCheckClient::SpellCheckClient(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> provider)
|
v8::Handle<v8::Object> provider)
|
||||||
: provider_(isolate, provider) {}
|
: provider_(isolate, provider) {}
|
||||||
|
|
||||||
SpellCheckClient::~SpellCheckClient() {}
|
SpellCheckClient::~SpellCheckClient() {}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace api {
|
||||||
|
|
||||||
class SpellCheckClient : public blink::WebSpellCheckClient {
|
class SpellCheckClient : public blink::WebSpellCheckClient {
|
||||||
public:
|
public:
|
||||||
SpellCheckClient(v8::Isolate* isolate, v8::Local<v8::Object> provider);
|
SpellCheckClient(v8::Isolate* isolate, v8::Handle<v8::Object> provider);
|
||||||
virtual ~SpellCheckClient();
|
virtual ~SpellCheckClient();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "atom/renderer/api/atom_api_web_frame.h"
|
#include "atom/renderer/api/atom_api_web_frame.h"
|
||||||
|
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
|
#include "atom/renderer/api/atom_api_spell_check_client.h"
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
|
@ -56,6 +57,11 @@ void WebFrame::AttachGuest(int id) {
|
||||||
content::RenderFrame::FromWebFrame(web_frame_)->AttachGuest(id);
|
content::RenderFrame::FromWebFrame(web_frame_)->AttachGuest(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebFrame::SetSpellCheckProvider(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::Object> provider) {
|
||||||
|
spell_check_client_.reset(new SpellCheckClient(isolate, provider));
|
||||||
|
}
|
||||||
|
|
||||||
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
||||||
v8::Isolate* isolate) {
|
v8::Isolate* isolate) {
|
||||||
return mate::ObjectTemplateBuilder(isolate)
|
return mate::ObjectTemplateBuilder(isolate)
|
||||||
|
@ -66,7 +72,8 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
||||||
.SetMethod("getZoomFactor", &WebFrame::GetZoomFactor)
|
.SetMethod("getZoomFactor", &WebFrame::GetZoomFactor)
|
||||||
.SetMethod("registerEmbedderCustomElement",
|
.SetMethod("registerEmbedderCustomElement",
|
||||||
&WebFrame::RegisterEmbedderCustomElement)
|
&WebFrame::RegisterEmbedderCustomElement)
|
||||||
.SetMethod("attachGuest", &WebFrame::AttachGuest);
|
.SetMethod("attachGuest", &WebFrame::AttachGuest)
|
||||||
|
.SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "native_mate/wrappable.h"
|
#include "native_mate/wrappable.h"
|
||||||
|
|
||||||
|
@ -18,6 +19,8 @@ namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
|
class SpellCheckClient;
|
||||||
|
|
||||||
class WebFrame : public mate::Wrappable {
|
class WebFrame : public mate::Wrappable {
|
||||||
public:
|
public:
|
||||||
static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
|
static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
|
||||||
|
@ -37,10 +40,16 @@ class WebFrame : public mate::Wrappable {
|
||||||
const base::string16& name, v8::Handle<v8::Object> options);
|
const base::string16& name, v8::Handle<v8::Object> options);
|
||||||
void AttachGuest(int element_instance_id);
|
void AttachGuest(int element_instance_id);
|
||||||
|
|
||||||
|
// Set the provider that will be used by SpellCheckClient for spell check.
|
||||||
|
void SetSpellCheckProvider(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::Object> provider);
|
||||||
|
|
||||||
// mate::Wrappable:
|
// mate::Wrappable:
|
||||||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||||
v8::Isolate* isolate);
|
v8::Isolate* isolate);
|
||||||
|
|
||||||
|
scoped_ptr<SpellCheckClient> spell_check_client_;
|
||||||
|
|
||||||
blink::WebLocalFrame* web_frame_;
|
blink::WebLocalFrame* web_frame_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebFrame);
|
DISALLOW_COPY_AND_ASSIGN(WebFrame);
|
||||||
|
|
Loading…
Reference in a new issue