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

Side by Side Diff: chrome/browser/spellchecker/spellchecker_session_bridge_android.cc

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: Removed unused variables from past implementation approach 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 unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/spellchecker/spellchecker_session_bridge_android.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h"
please use gerrit instead 2015/08/11 16:43:46 Chromium style is to not repeat header's includes
dylanking 2015/08/12 01:29:55 Shouldn't have let that slip through. Thanks.
10 #include "chrome/common/spellcheck_messages.h"
11 #include "chrome/common/spellcheck_result.h"
12 #include "content/public/browser/render_process_host.h"
13 #include "jni/SpellCheckerSessionBridge_jni.h"
14
15 SpellCheckerSessionBridge::SpellCheckerSessionBridge(int render_process_id)
16 : render_process_id_(render_process_id) {
please use gerrit instead 2015/08/11 16:43:46 Will this work? SpellCheckerSessionBridge::SpellC
dylanking 2015/08/12 01:29:55 Yes! Reset() was the only assignment operator I kn
17 JNIEnv* env = base::android::AttachCurrentThread();
18 java_object_.Reset(Java_SpellCheckerSessionBridge_create(
19 env, reinterpret_cast<intptr_t>(this)));
20 }
21
22 void SpellCheckerSessionBridge::RequestTextCheck(int route_id,
23 int identifier,
24 const base::string16& text) {
25 route_id_ = route_id;
26 identifier_ = identifier;
27
28 JNIEnv* env = base::android::AttachCurrentThread();
29 Java_SpellCheckerSessionBridge_checkSpelling(
30 env, java_object_.obj(),
31 base::android::ConvertUTF16ToJavaString(env, text).obj());
32 }
33
34 // static
35 bool SpellCheckerSessionBridge::RegisterSpellCheckerSessionBridge(JNIEnv* env) {
36 return RegisterNativesImpl(env);
37 }
38
39 void SpellCheckerSessionBridge::GetSpellcheckInfo(JNIEnv* env,
40 jobject jobj,
41 jstring text,
42 jintArray offsetArray,
43 jintArray lengthArray) {
44 std::vector<int> offsets;
45 std::vector<int> lengths;
46 std::vector<SpellCheckResult> local_results;
please use gerrit instead 2015/08/11 16:43:47 Define local_results right before you use it (abov
please use gerrit instead 2015/08/11 16:43:47 Just "results". It's simpler.
dylanking 2015/08/12 01:29:55 http://nuserve.co.uk/blog/wp-content/uploads/2013/
47
48 base::android::JavaIntArrayToIntVector(env, offsetArray, &offsets);
49 base::android::JavaIntArrayToIntVector(env, lengthArray, &lengths);
50
51 for (unsigned int j = 0; j < offsets.size(); j++) {
52 local_results.push_back(
53 SpellCheckResult(SpellCheckResult::SPELLING, offsets[j], lengths[j]));
54 }
55
56 content::RenderProcessHost* sender =
57 content::RenderProcessHost::FromID(render_process_id_);
58
59 if (sender) {
60 sender->Send(new SpellCheckMsg_RespondTextCheck(
61 route_id_, identifier_,
62 base::android::ConvertJavaStringToUTF16(env, text), local_results));
63 }
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698