Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 1 | // Copyright 2018 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 "components/spellcheck/browser/spell_check_host_impl.h" |
| 6 | |
Guillaume Jenkins | 03764e1b | 2020-01-17 21:47:59 | [diff] [blame] | 7 | #include "build/build_config.h" |
| 8 | #include "components/spellcheck/spellcheck_buildflags.h" |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 9 | #include "content/public/browser/browser_thread.h" |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 10 | |
| 11 | SpellCheckHostImpl::SpellCheckHostImpl() = default; |
| 12 | SpellCheckHostImpl::~SpellCheckHostImpl() = default; |
| 13 | |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 14 | void SpellCheckHostImpl::RequestDictionary() { |
| 15 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 16 | |
Xiaocheng Hu | 73091994 | 2018-02-20 21:04:48 | [diff] [blame] | 17 | // This API requires Chrome-only features. |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 18 | return; |
| 19 | } |
| 20 | |
| 21 | void SpellCheckHostImpl::NotifyChecked(const base::string16& word, |
| 22 | bool misspelled) { |
| 23 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 24 | |
Xiaocheng Hu | 73091994 | 2018-02-20 21:04:48 | [diff] [blame] | 25 | // This API requires Chrome-only features. |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 26 | return; |
| 27 | } |
| 28 | |
Siye Liu | de74ce30 | 2019-06-20 20:44:43 | [diff] [blame] | 29 | #if BUILDFLAG(USE_RENDERER_SPELLCHECKER) |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 30 | void SpellCheckHostImpl::CallSpellingService( |
| 31 | const base::string16& text, |
| 32 | CallSpellingServiceCallback callback) { |
| 33 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 34 | |
| 35 | if (text.empty()) |
Guillaume Jenkins | 2c1717a8 | 2019-12-05 21:20:16 | [diff] [blame] | 36 | mojo::ReportBadMessage("Requested spelling service with empty text"); |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 37 | |
Xiaocheng Hu | 73091994 | 2018-02-20 21:04:48 | [diff] [blame] | 38 | // This API requires Chrome-only features. |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 39 | std::move(callback).Run(false, std::vector<SpellCheckResult>()); |
| 40 | } |
Siye Liu | de74ce30 | 2019-06-20 20:44:43 | [diff] [blame] | 41 | #endif // BUILDFLAG(USE_RENDERER_SPELLCHECKER) |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 42 | |
Evan Stade | 38ec3da | 2019-12-02 19:02:59 | [diff] [blame] | 43 | #if BUILDFLAG(USE_BROWSER_SPELLCHECKER) && !BUILDFLAG(ENABLE_SPELLING_SERVICE) |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 44 | void SpellCheckHostImpl::RequestTextCheck(const base::string16& text, |
| 45 | int route_id, |
| 46 | RequestTextCheckCallback callback) { |
| 47 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 48 | |
| 49 | if (text.empty()) |
Guillaume Jenkins | 2c1717a8 | 2019-12-05 21:20:16 | [diff] [blame] | 50 | mojo::ReportBadMessage("Requested text check with empty text"); |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 51 | |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 52 | session_bridge_.RequestTextCheck(text, std::move(callback)); |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 53 | } |
| 54 | |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 55 | void SpellCheckHostImpl::CheckSpelling(const base::string16& word, |
| 56 | int route_id, |
| 57 | CheckSpellingCallback callback) { |
| 58 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
Evan Stade | 38ec3da | 2019-12-02 19:02:59 | [diff] [blame] | 59 | NOTREACHED(); |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 60 | std::move(callback).Run(false); |
| 61 | } |
| 62 | |
| 63 | void SpellCheckHostImpl::FillSuggestionList( |
| 64 | const base::string16& word, |
| 65 | FillSuggestionListCallback callback) { |
| 66 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
Evan Stade | 38ec3da | 2019-12-02 19:02:59 | [diff] [blame] | 67 | NOTREACHED(); |
| 68 | std::move(callback).Run({}); |
Xiaocheng Hu | d9085ee | 2018-02-16 22:32:30 | [diff] [blame] | 69 | } |
Evan Stade | 38ec3da | 2019-12-02 19:02:59 | [diff] [blame] | 70 | #endif // BUILDFLAG(USE_BROWSER_SPELLCHECKER) && |
| 71 | // !BUILDFLAG(ENABLE_SPELLING_SERVICE) |
Xiaocheng Hu | 551a8c1 | 2019-03-05 22:29:39 | [diff] [blame] | 72 | |
Guillaume Jenkins | 2c1717a8 | 2019-12-05 21:20:16 | [diff] [blame] | 73 | #if BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) |
| 74 | void SpellCheckHostImpl::GetPerLanguageSuggestions( |
| 75 | const base::string16& word, |
| 76 | GetPerLanguageSuggestionsCallback callback) { |
| 77 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 78 | |
| 79 | // This API requires Chrome-only features. |
| 80 | std::move(callback).Run(std::vector<std::vector<base::string16>>()); |
| 81 | } |
| 82 | #endif // BUILDFLAG(USE_WIN_HYBRID_SPELLCHECKER) |
| 83 | |
Xiaocheng Hu | 551a8c1 | 2019-03-05 22:29:39 | [diff] [blame] | 84 | #if defined(OS_ANDROID) |
| 85 | void SpellCheckHostImpl::DisconnectSessionBridge() { |
| 86 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 87 | session_bridge_.DisconnectSession(); |
| 88 | } |
| 89 | #endif |