From f1fbc5c701b7e00f76a1b7bd137e14905ca81194 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 18 Dec 2014 13:54:01 -0800 Subject: [PATCH] Add webFrame.setSpellCheckClient API --- atom/renderer/api/atom_api_spell_check_client.cc | 2 +- atom/renderer/api/atom_api_spell_check_client.h | 2 +- atom/renderer/api/atom_api_web_frame.cc | 9 ++++++++- atom/renderer/api/atom_api_web_frame.h | 9 +++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/atom/renderer/api/atom_api_spell_check_client.cc b/atom/renderer/api/atom_api_spell_check_client.cc index ad43ee916588..aa069523ccf5 100644 --- a/atom/renderer/api/atom_api_spell_check_client.cc +++ b/atom/renderer/api/atom_api_spell_check_client.cc @@ -9,7 +9,7 @@ namespace atom { namespace api { SpellCheckClient::SpellCheckClient(v8::Isolate* isolate, - v8::Local provider) + v8::Handle provider) : provider_(isolate, provider) {} SpellCheckClient::~SpellCheckClient() {} diff --git a/atom/renderer/api/atom_api_spell_check_client.h b/atom/renderer/api/atom_api_spell_check_client.h index 759baafd4b66..d662f79ce703 100644 --- a/atom/renderer/api/atom_api_spell_check_client.h +++ b/atom/renderer/api/atom_api_spell_check_client.h @@ -14,7 +14,7 @@ namespace api { class SpellCheckClient : public blink::WebSpellCheckClient { public: - SpellCheckClient(v8::Isolate* isolate, v8::Local provider); + SpellCheckClient(v8::Isolate* isolate, v8::Handle provider); virtual ~SpellCheckClient(); private: diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index 9fc9008ea3c5..36f13c7976e3 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -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 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 diff --git a/atom/renderer/api/atom_api_web_frame.h b/atom/renderer/api/atom_api_web_frame.h index 132199e3fe7e..077aa64e3b1f 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -7,6 +7,7 @@ #include +#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 Create(v8::Isolate* isolate); @@ -37,10 +40,16 @@ class WebFrame : public mate::Wrappable { const base::string16& name, v8::Handle 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 provider); + // mate::Wrappable: virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder( v8::Isolate* isolate); + scoped_ptr spell_check_client_; + blink::WebLocalFrame* web_frame_; DISALLOW_COPY_AND_ASSIGN(WebFrame);