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

Unified Diff: services/keyboard_native/predictor.h

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
Index: services/keyboard_native/predictor.h
diff --git a/services/keyboard_native/predictor.h b/services/keyboard_native/predictor.h
new file mode 100644
index 0000000000000000000000000000000000000000..51b84e0a86ddef00f22109e1260d15d796d9c9ae
--- /dev/null
+++ b/services/keyboard_native/predictor.h
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_KEYBOARD_NATIVE_PREDICTOR_H_
+#define SERVICES_KEYBOARD_NATIVE_PREDICTOR_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "mojo/public/cpp/application/connect.h"
+#include "mojo/public/interfaces/application/shell.mojom.h"
+#include "mojo/services/prediction/public/interfaces/prediction.mojom.h"
+#include "services/keyboard_native/key_layout.h"
+
+namespace keyboard {
+
+class Predictor {
+ public:
+ Predictor(mojo::Shell* shell);
+ ~Predictor();
+
+ void SetSuggestionKeys(std::vector<KeyLayout::Key*> suggestion_keys);
+
+ void SetUpdateCallback(base::Callback<void()> on_update_callback);
+
+ void StoreCurWord(std::string new_word);
+
+ int ChooseSuggestedWord(std::string suggested);
+
+ void DeleteCharInCurWord();
+
+ private:
+ void ShowEmptySuggestion();
+
+ void GetSuggestion();
+
+ void GetPredictionListAndEnd(const mojo::Array<mojo::String>& input_list);
+
+ prediction::PredictionServicePtr prediction_service_impl_;
+ std::vector<KeyLayout::Key*> suggestion_keys_;
+ std::string current_word_;
+ std::vector<std::string> previous_words_;
+ base::Callback<void()> on_update_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(Predictor);
+};
+
+} // namespace keyboard
+
+#endif // SERVICES_KEYBOARD_NATIVE_PREDICTOR_H_

Powered by Google App Engine
This is Rietveld 408576698