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/spellcheck_platform.h" | 5 #include "chrome/browser/spellchecker/spellcheck_platform.h" |
6 | 6 |
| 7 //#include "base/android/jni_android.h" |
| 8 //#include "base/android/jni_array.h" |
| 9 //#include "base/android/jni_string.h" |
7 #include "base/callback.h" | 10 #include "base/callback.h" |
8 #include "base/command_line.h" | 11 #include "base/command_line.h" |
9 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/spellcheck_result.h" |
| 14 //#include "jni/SpellCheckerSessionBridge_jni.h" |
| 15 |
| 16 namespace { |
| 17 //std::vector<int> offsets; |
| 18 //std::vector<int> lengths; |
| 19 //base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| 20 //base::Callback<void(const std::vector<SpellCheckResult>&)> callback_; |
| 21 } // namespace |
10 | 22 |
11 namespace spellcheck_platform { | 23 namespace spellcheck_platform { |
12 | 24 |
13 void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages) { | 25 void GetAvailableLanguages(std::vector<std::string>* spellcheck_languages) { |
14 } | 26 } |
15 | 27 |
16 bool SpellCheckerAvailable() { | 28 bool SpellCheckerAvailable() { |
17 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 29 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
18 switches::kEnableAndroidSpellChecker); | 30 switches::kEnableAndroidSpellChecker); |
19 } | 31 } |
20 | 32 |
21 bool SpellCheckerProvidesPanel() { | 33 bool SpellCheckerProvidesPanel() { |
22 return false; | 34 return false; |
23 } | 35 } |
24 | 36 |
25 bool SpellingPanelVisible() { | 37 bool SpellingPanelVisible() { |
26 return false; | 38 return false; |
27 } | 39 } |
28 | 40 |
29 void ShowSpellingPanel(bool show) { | 41 void ShowSpellingPanel(bool show) { |
30 } | 42 } |
31 | 43 |
32 void UpdateSpellingPanelWithMisspelledWord(const base::string16& word) { | 44 void UpdateSpellingPanelWithMisspelledWord(const base::string16& word) { |
33 } | 45 } |
34 | 46 |
35 bool PlatformSupportsLanguage(const std::string& current_language) { | 47 bool PlatformSupportsLanguage(const std::string& current_language) { |
36 return true; | 48 return true; |
37 } | 49 } |
38 | 50 |
39 void SetLanguage(const std::string& lang_to_set) { | 51 void SetLanguage(const std::string& lang_to_set) { |
40 } | 52 } |
41 | 53 |
42 bool CheckSpelling(const base::string16& word_to_check, int tag) { | 54 bool CheckSpelling(const base::string16& word_to_check, int tag) { |
43 return true; | 55 return true; |
44 } | 56 } |
45 | 57 |
46 void FillSuggestionList(const base::string16& wrong_word, | 58 void FillSuggestionList(const base::string16& wrong_word, |
47 std::vector<base::string16>* optional_suggestions) { | 59 std::vector<base::string16>* optional_suggestions) { |
48 } | 60 } |
49 | 61 |
50 void AddWord(const base::string16& word) { | 62 void AddWord(const base::string16& word) { |
51 } | 63 } |
52 | 64 |
53 void RemoveWord(const base::string16& word) { | 65 void RemoveWord(const base::string16& word) { |
54 } | 66 } |
55 | 67 |
56 int GetDocumentTag() { | 68 int GetDocumentTag() { |
57 return 1; | 69 return 1; |
58 } | 70 } |
59 | 71 |
60 void IgnoreWord(const base::string16& word) { | 72 void IgnoreWord(const base::string16& word) { |
61 } | 73 } |
62 | 74 |
63 void CloseDocumentWithTag(int tag) { | 75 void CloseDocumentWithTag(int tag) { |
64 } | 76 } |
65 | 77 |
66 void RequestTextCheck(int document_tag, | 78 void RequestTextCheck(int document_tag, |
67 const base::string16& text, | 79 const base::string16& text, |
68 TextCheckCompleteCallback callback) { | 80 TextCheckCompleteCallback callback) { |
69 | 81 //JNIEnv* env = base::android::AttachCurrentThread(); |
| 82 //callback_ = callback; |
| 83 LOG(ERROR) << "DYLANKING RequestTextCheck on " << text; |
| 84 //Java_SpellCheckerSessionBridge_checkSpelling(env, java_object_.obj(), |
| 85 //base::android::ConvertUTF16ToJavaString(env, text).obj()); |
70 } | 86 } |
71 | 87 |
| 88 /* |
| 89 void InitializeJNIBridge() { |
| 90 JNIEnv* env = base::android::AttachCurrentThread(); |
| 91 java_object_.Reset( |
| 92 Java_SpellCheckerSessionBridge_create(env)); |
| 93 } |
| 94 |
| 95 //static |
| 96 bool RegisterSpellcheckPlatformAndroid(JNIEnv* env) { |
| 97 return RegisterNativesImpl(env); |
| 98 } |
| 99 |
| 100 //static |
| 101 void GetSpellcheckInfo(JNIEnv* env, jobject jobj, jobjectArray suggestionsArray, |
| 102 jintArray offsetArray, jintArray lengthArray){ |
| 103 |
| 104 LOG(ERROR) << "DYLANKING In Native GetSpellcheckInfo"; |
| 105 std::vector<SpellCheckResult> check_results; |
| 106 std::vector<base::string16> optional_suggestions; |
| 107 base::android::AppendJavaStringArrayToStringVector(env, suggestionsArray, &opt
ional_suggestions); |
| 108 |
| 109 for(unsigned int i = 0; i < optional_suggestions.size(); i++){ |
| 110 LOG(ERROR) << "DYLANKING " << optional_suggestions[i]; |
| 111 } |
| 112 |
| 113 base::android::JavaIntArrayToIntVector(env, offsetArray, &offsets); |
| 114 base::android::JavaIntArrayToIntVector(env, lengthArray, &lengths); |
| 115 |
| 116 for(unsigned int j = 0; j < offsets.size(); j++){ |
| 117 LOG(ERROR) << "DYLANKING offset: " << offsets[j] << " length: " << lengths[j
]; |
| 118 check_results.push_back(SpellCheckResult(SpellCheckResult::SPELLING,offsets[
j],lengths[j])); |
| 119 } |
| 120 |
| 121 callback_.Run(check_results); |
| 122 } |
| 123 */ |
| 124 |
72 } // namespace spellcheck_platform | 125 } // namespace spellcheck_platform |
OLD | NEW |