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

Unified Diff: chrome/browser/spellchecker/spellchecker_session_bridge_android.h

Issue 1275813002: Implemented typo recognition in Chrome for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@4_remove_mac_redundancies
Patch Set: Changed pending requests to be handled in native, other comment addressing 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: chrome/browser/spellchecker/spellchecker_session_bridge_android.h
diff --git a/chrome/browser/spellchecker/spellchecker_session_bridge_android.h b/chrome/browser/spellchecker/spellchecker_session_bridge_android.h
new file mode 100644
index 0000000000000000000000000000000000000000..99f07a123ee894620339a61e09c1daabbb6007ef
--- /dev/null
+++ b/chrome/browser/spellchecker/spellchecker_session_bridge_android.h
@@ -0,0 +1,66 @@
+// 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 CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_
+#define CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_
+
+#include "base/android/jni_android.h"
newt (away) 2015/08/13 20:40:32 I still don't think these jni_*.h includes are nee
dylanking 2015/08/14 02:57:03 Ah, I see. Changed, thanks!
+#include "base/android/jni_array.h"
+#include "base/android/jni_string.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/strings/string16.h"
+
+// Owned by the SpellCheckMessageFilterPlatform. This class is used to
+// interface between the android message filter and the Java class of the
+// same name. This class is sent text to be spellchecked from
+// the message filter, then sends that text to the Java side via JNI to be
+// spellchecked, and finally processes those results and sends them to the
+// renderer.
+class SpellCheckerSessionBridge {
+ public:
+ explicit SpellCheckerSessionBridge(int render_process_id);
+ ~SpellCheckerSessionBridge();
+ static bool RegisterJNI(JNIEnv* env);
+
+ // Receives text to be checked from the message filter and sends it to Java
+ // to be spellchecked.
+ void RequestTextCheck(int route_id,
+ int identifier,
+ const base::string16& text);
+
+ // Receives information from Java side about the typos in a given string
+ // of text, processes these and sends them to the renderer.
+ void ProcessSpellCheckResults(JNIEnv* env,
+ jobject jobj,
+ jintArray offset_array,
+ jintArray length_array);
+
+ private:
+ struct SpellingRequest {
newt (away) 2015/08/13 20:40:32 Since this class is used only internally, it'd be
dylanking 2015/08/14 02:57:03 I believe I need to define it here since SpellChec
+ SpellingRequest(int route_id, int identifier, const base::string16& text);
+ SpellingRequest() {}
newt (away) 2015/08/13 20:40:32 probably don't need this method either (once you s
dylanking 2015/08/14 02:57:03 Gotcha.
+ ~SpellingRequest() {}
+
+ void set_route_id(int r_id) { route_id = r_id; }
newt (away) 2015/08/13 20:40:31 I'd probably just remove these methods. Since this
dylanking 2015/08/14 02:57:03 Right, meant to delete those earlier. Fixed.
+ void set_identifier(int id) { identifier = id; }
+ void set_text(base::string16 new_text) { text = new_text; }
+
+ int route_id;
+ int identifier;
+ base::string16 text;
+ };
+
+ int render_process_id_;
+ bool is_active_request_;
newt (away) 2015/08/13 20:40:32 Instead of using a bool to remember whether active
dylanking 2015/08/14 02:57:03 rouslan@ has advised me to use composed objects ra
please use gerrit instead 2015/08/14 17:06:23 I think this is a good use case for scoped pointer
+ bool is_pending_request_;
+
+ SpellingRequest active_spelling_request_;
+ SpellingRequest pending_spelling_request_;
+
+ base::android::ScopedJavaGlobalRef<jobject> java_object_;
+
+ DISALLOW_COPY_AND_ASSIGN(SpellCheckerSessionBridge);
+};
+
+#endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_

Powered by Google App Engine
This is Rietveld 408576698