Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: services/keyboard_native/view_observer_delegate.cc

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: format README and CHROMIUM.diff Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/keyboard_native/view_observer_delegate.h ('k') | services/prediction/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/keyboard_native/view_observer_delegate.cc
diff --git a/services/keyboard_native/view_observer_delegate.cc b/services/keyboard_native/view_observer_delegate.cc
index 99b677fdc099f69d91eb14cfab0e8a943d07818a..733443e26ad246b9512c4988c5117458943f79af 100644
--- a/services/keyboard_native/view_observer_delegate.cc
+++ b/services/keyboard_native/view_observer_delegate.cc
@@ -11,9 +11,11 @@
#include "mojo/gpu/gl_texture.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/connect.h"
+#include "mojo/services/prediction/public/interfaces/prediction.mojom.h"
#include "mojo/skia/ganesh_surface.h"
#include "services/keyboard_native/clip_animation.h"
#include "services/keyboard_native/keyboard_service_impl.h"
+#include "services/keyboard_native/predictor.h"
#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkTypeface.h"
@@ -36,6 +38,7 @@ mojo::Size ToSize(const mojo::Rect& rect) {
ViewObserverDelegate::ViewObserverDelegate()
: keyboard_service_impl_(nullptr),
+ predictor_(nullptr),
view_(nullptr),
id_namespace_(0u),
surface_id_(1u),
@@ -49,6 +52,8 @@ ViewObserverDelegate::ViewObserverDelegate()
base::Bind(&ViewObserverDelegate::OnText, weak_factory_.GetWeakPtr()));
key_layout_.SetDeleteCallback(
base::Bind(&ViewObserverDelegate::OnDelete, weak_factory_.GetWeakPtr()));
+ key_layout_.SetSuggestTextCallback(base::Bind(
+ &ViewObserverDelegate::OnSuggestText, weak_factory_.GetWeakPtr()));
submit_frame_callback_ = base::Bind(&ViewObserverDelegate::OnFrameComplete,
weak_factory_.GetWeakPtr());
}
@@ -92,6 +97,10 @@ void ViewObserverDelegate::OnViewCreated(mojo::View* view, mojo::Shell* shell) {
surface_->CreateSurface(surface_id_);
surface_->GetIdNamespace(base::Bind(&ViewObserverDelegate::SetIdNamespace,
base::Unretained(this)));
+ predictor_ = new Predictor(shell);
+ predictor_->SetUpdateCallback(base::Bind(
+ &ViewObserverDelegate::OnUpdateSuggestion, weak_factory_.GetWeakPtr()));
+ key_layout_.SetPredictor(predictor_);
IssueDraw();
}
@@ -103,6 +112,15 @@ void ViewObserverDelegate::OnDelete() {
keyboard_service_impl_->OnDelete();
}
+void ViewObserverDelegate::OnSuggestText(const std::string& text) {
+ std::string text_with_space = text + " ";
+ keyboard_service_impl_->OnKey(text_with_space.c_str());
+}
+
+void ViewObserverDelegate::OnUpdateSuggestion() {
+ IssueDraw();
+}
+
void ViewObserverDelegate::UpdateState(int32 pointer_id,
int action,
const gfx::PointF& touch_point) {
« no previous file with comments | « services/keyboard_native/view_observer_delegate.h ('k') | services/prediction/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698