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 {
|
||||
|
||||
SpellCheckClient::SpellCheckClient(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> provider)
|
||||
v8::Handle<v8::Object> provider)
|
||||
: provider_(isolate, provider) {}
|
||||
|
||||
SpellCheckClient::~SpellCheckClient() {}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace api {
|
|||
|
||||
class SpellCheckClient : public blink::WebSpellCheckClient {
|
||||
public:
|
||||
SpellCheckClient(v8::Isolate* isolate, v8::Local<v8::Object> provider);
|
||||
SpellCheckClient(v8::Isolate* isolate, v8::Handle<v8::Object> provider);
|
||||
virtual ~SpellCheckClient();
|
||||
|
||||
private:
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "atom/renderer/api/atom_api_web_frame.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 "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
@ -56,6 +57,11 @@ void WebFrame::AttachGuest(int 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(
|
||||
v8::Isolate* isolate) {
|
||||
return mate::ObjectTemplateBuilder(isolate)
|
||||
|
@ -66,7 +72,8 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
|||
.SetMethod("getZoomFactor", &WebFrame::GetZoomFactor)
|
||||
.SetMethod("registerEmbedderCustomElement",
|
||||
&WebFrame::RegisterEmbedderCustomElement)
|
||||
.SetMethod("attachGuest", &WebFrame::AttachGuest);
|
||||
.SetMethod("attachGuest", &WebFrame::AttachGuest)
|
||||
.SetMethod("setSpellCheckProvider", &WebFrame::SetSpellCheckProvider);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
|
@ -18,6 +19,8 @@ namespace atom {
|
|||
|
||||
namespace api {
|
||||
|
||||
class SpellCheckClient;
|
||||
|
||||
class WebFrame : public mate::Wrappable {
|
||||
public:
|
||||
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);
|
||||
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:
|
||||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate);
|
||||
|
||||
scoped_ptr<SpellCheckClient> spell_check_client_;
|
||||
|
||||
blink::WebLocalFrame* web_frame_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebFrame);
|
||||
|
|
Loading…
Reference in a new issue