| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/spellchecker/spellchecker_session_bridge_android.h" | 5 #include "chrome/browser/spellchecker/spellchecker_session_bridge_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // recent request will run (the others get overwritten). | 54 // recent request will run (the others get overwritten). |
| 55 if (active_request_) { | 55 if (active_request_) { |
| 56 pending_request_.reset(new SpellingRequest(route_id, identifier, text)); | 56 pending_request_.reset(new SpellingRequest(route_id, identifier, text)); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 active_request_.reset(new SpellingRequest(route_id, identifier, text)); | 60 active_request_.reset(new SpellingRequest(route_id, identifier, text)); |
| 61 | 61 |
| 62 JNIEnv* env = base::android::AttachCurrentThread(); | 62 JNIEnv* env = base::android::AttachCurrentThread(); |
| 63 Java_SpellCheckerSessionBridge_requestTextCheck( | 63 Java_SpellCheckerSessionBridge_requestTextCheck( |
| 64 env, java_object_.obj(), | 64 env, java_object_, base::android::ConvertUTF16ToJavaString(env, text)); |
| 65 base::android::ConvertUTF16ToJavaString(env, text).obj()); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 void SpellCheckerSessionBridge::ProcessSpellCheckResults( | 67 void SpellCheckerSessionBridge::ProcessSpellCheckResults( |
| 69 JNIEnv* env, | 68 JNIEnv* env, |
| 70 const JavaParamRef<jobject>& jobj, | 69 const JavaParamRef<jobject>& jobj, |
| 71 const JavaParamRef<jintArray>& offset_array, | 70 const JavaParamRef<jintArray>& offset_array, |
| 72 const JavaParamRef<jintArray>& length_array) { | 71 const JavaParamRef<jintArray>& length_array) { |
| 73 std::vector<int> offsets; | 72 std::vector<int> offsets; |
| 74 std::vector<int> lengths; | 73 std::vector<int> lengths; |
| 75 | 74 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 88 if (sender != nullptr) { | 87 if (sender != nullptr) { |
| 89 sender->Send(new SpellCheckMsg_RespondTextCheck( | 88 sender->Send(new SpellCheckMsg_RespondTextCheck( |
| 90 active_request_->route_id, active_request_->identifier, | 89 active_request_->route_id, active_request_->identifier, |
| 91 active_request_->text, results)); | 90 active_request_->text, results)); |
| 92 } | 91 } |
| 93 | 92 |
| 94 active_request_ = std::move(pending_request_); | 93 active_request_ = std::move(pending_request_); |
| 95 if (active_request_) { | 94 if (active_request_) { |
| 96 JNIEnv* env = base::android::AttachCurrentThread(); | 95 JNIEnv* env = base::android::AttachCurrentThread(); |
| 97 Java_SpellCheckerSessionBridge_requestTextCheck( | 96 Java_SpellCheckerSessionBridge_requestTextCheck( |
| 98 env, java_object_.obj(), | 97 env, java_object_, |
| 99 base::android::ConvertUTF16ToJavaString(env, active_request_->text) | 98 base::android::ConvertUTF16ToJavaString(env, active_request_->text)); |
| 100 .obj()); | |
| 101 } | 99 } |
| 102 } | 100 } |
| 103 | 101 |
| 104 void SpellCheckerSessionBridge::DisconnectSession() { | 102 void SpellCheckerSessionBridge::DisconnectSession() { |
| 105 java_object_.Reset(); | 103 java_object_.Reset(); |
| 106 } | 104 } |
| 107 | 105 |
| 108 SpellCheckerSessionBridge::SpellingRequest::SpellingRequest( | 106 SpellCheckerSessionBridge::SpellingRequest::SpellingRequest( |
| 109 int route_id, | 107 int route_id, |
| 110 int identifier, | 108 int identifier, |
| 111 const base::string16& text) | 109 const base::string16& text) |
| 112 : route_id(route_id), identifier(identifier), text(text) {} | 110 : route_id(route_id), identifier(identifier), text(text) {} |
| 113 | 111 |
| 114 SpellCheckerSessionBridge::SpellingRequest::~SpellingRequest() {} | 112 SpellCheckerSessionBridge::SpellingRequest::~SpellingRequest() {} |
| OLD | NEW |