OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/spellchecker/spellcheck.h" | 5 #include "components/spellcheck/renderer/spellcheck.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/common/channel_info.h" | 21 #include "chrome/common/channel_info.h" |
22 #include "chrome/common/chrome_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "chrome/common/spellcheck_common.h" | 23 //#include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/spellcheck_messages.h" | 24 #include "components/spellcheck/common/spellcheck_common.h" |
25 #include "chrome/common/spellcheck_result.h" | 25 #include "components/spellcheck/common/spellcheck_messages.h" |
26 #include "chrome/renderer/spellchecker/spellcheck_language.h" | 26 #include "components/spellcheck/common/spellcheck_result.h" |
27 #include "chrome/renderer/spellchecker/spellcheck_provider.h" | 27 #include "components/spellcheck/renderer/spellcheck_language.h" |
| 28 #include "components/spellcheck/renderer/spellcheck_provider.h" |
28 #include "content/public/renderer/render_thread.h" | 29 #include "content/public/renderer/render_thread.h" |
29 #include "content/public/renderer/render_view.h" | 30 #include "content/public/renderer/render_view.h" |
30 #include "content/public/renderer/render_view_visitor.h" | 31 #include "content/public/renderer/render_view_visitor.h" |
31 #include "ipc/ipc_platform_file.h" | 32 #include "ipc/ipc_platform_file.h" |
32 #include "third_party/WebKit/public/platform/WebString.h" | 33 #include "third_party/WebKit/public/platform/WebString.h" |
33 #include "third_party/WebKit/public/platform/WebVector.h" | 34 #include "third_party/WebKit/public/platform/WebVector.h" |
34 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 35 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
35 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 36 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
36 #include "third_party/WebKit/public/web/WebTextDecorationType.h" | 37 #include "third_party/WebKit/public/web/WebTextDecorationType.h" |
37 #include "third_party/WebKit/public/web/WebView.h" | 38 #include "third_party/WebKit/public/web/WebView.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 193 |
193 if (suggestions_list[language].size() <= index) | 194 if (suggestions_list[language].size() <= index) |
194 continue; | 195 continue; |
195 | 196 |
196 const base::string16& suggestion = suggestions_list[language][index]; | 197 const base::string16& suggestion = suggestions_list[language][index]; |
197 // Only add the suggestion if it's unique. | 198 // Only add the suggestion if it's unique. |
198 if (!ContainsValue(*optional_suggestions, suggestion)) { | 199 if (!ContainsValue(*optional_suggestions, suggestion)) { |
199 optional_suggestions->push_back(suggestion); | 200 optional_suggestions->push_back(suggestion); |
200 } | 201 } |
201 if (optional_suggestions->size() >= | 202 if (optional_suggestions->size() >= |
202 chrome::spellcheck_common::kMaxSuggestions) { | 203 spellcheck_common::kMaxSuggestions) { |
203 break; | 204 break; |
204 } | 205 } |
205 } | 206 } |
206 } | 207 } |
207 | 208 |
208 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { | 209 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { |
209 bool handled = true; | 210 bool handled = true; |
210 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) | 211 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) |
211 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) | 212 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) |
212 IPC_MESSAGE_HANDLER(SpellCheckMsg_CustomDictionaryChanged, | 213 IPC_MESSAGE_HANDLER(SpellCheckMsg_CustomDictionaryChanged, |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 540 |
540 bool SpellCheck::IsSpellcheckEnabled() { | 541 bool SpellCheck::IsSpellcheckEnabled() { |
541 #if defined(OS_ANDROID) | 542 #if defined(OS_ANDROID) |
542 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 543 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
543 switches::kEnableAndroidSpellChecker)) { | 544 switches::kEnableAndroidSpellChecker)) { |
544 return false; | 545 return false; |
545 } | 546 } |
546 #endif | 547 #endif |
547 return spellcheck_enabled_; | 548 return spellcheck_enabled_; |
548 } | 549 } |
OLD | NEW |