Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_ | |
| 6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_ | |
| 7 | |
| 8 #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!
| |
| 9 #include "base/android/jni_array.h" | |
| 10 #include "base/android/jni_string.h" | |
| 11 #include "base/android/scoped_java_ref.h" | |
| 12 #include "base/strings/string16.h" | |
| 13 | |
| 14 // Owned by the SpellCheckMessageFilterPlatform. This class is used to | |
| 15 // interface between the android message filter and the Java class of the | |
| 16 // same name. This class is sent text to be spellchecked from | |
| 17 // the message filter, then sends that text to the Java side via JNI to be | |
| 18 // spellchecked, and finally processes those results and sends them to the | |
| 19 // renderer. | |
| 20 class SpellCheckerSessionBridge { | |
| 21 public: | |
| 22 explicit SpellCheckerSessionBridge(int render_process_id); | |
| 23 ~SpellCheckerSessionBridge(); | |
| 24 static bool RegisterJNI(JNIEnv* env); | |
| 25 | |
| 26 // Receives text to be checked from the message filter and sends it to Java | |
| 27 // to be spellchecked. | |
| 28 void RequestTextCheck(int route_id, | |
| 29 int identifier, | |
| 30 const base::string16& text); | |
| 31 | |
| 32 // Receives information from Java side about the typos in a given string | |
| 33 // of text, processes these and sends them to the renderer. | |
| 34 void ProcessSpellCheckResults(JNIEnv* env, | |
| 35 jobject jobj, | |
| 36 jintArray offset_array, | |
| 37 jintArray length_array); | |
| 38 | |
| 39 private: | |
| 40 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
| |
| 41 SpellingRequest(int route_id, int identifier, const base::string16& text); | |
| 42 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.
| |
| 43 ~SpellingRequest() {} | |
| 44 | |
| 45 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.
| |
| 46 void set_identifier(int id) { identifier = id; } | |
| 47 void set_text(base::string16 new_text) { text = new_text; } | |
| 48 | |
| 49 int route_id; | |
| 50 int identifier; | |
| 51 base::string16 text; | |
| 52 }; | |
| 53 | |
| 54 int render_process_id_; | |
| 55 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
| |
| 56 bool is_pending_request_; | |
| 57 | |
| 58 SpellingRequest active_spelling_request_; | |
| 59 SpellingRequest pending_spelling_request_; | |
| 60 | |
| 61 base::android::ScopedJavaGlobalRef<jobject> java_object_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(SpellCheckerSessionBridge); | |
| 64 }; | |
| 65 | |
| 66 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECKER_SESSION_BRIDGE_ANDROID_H_ | |
| OLD | NEW |