Chromium Code Reviews| Index: chrome/renderer/spellchecker/spellcheck_provider.cc |
| diff --git a/chrome/renderer/spellchecker/spellcheck_provider.cc b/chrome/renderer/spellchecker/spellcheck_provider.cc |
| index 07b86d9d4a5fc68572862cf9d6f37aafa123a9e2..7247bdd6f8bb7476d7228aabc7d219375f4e26f2 100644 |
| --- a/chrome/renderer/spellchecker/spellcheck_provider.cc |
| +++ b/chrome/renderer/spellchecker/spellcheck_provider.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/command_line.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/spellcheck_messages.h" |
| +#include "chrome/common/spellcheck_result.h" |
| #include "chrome/renderer/chrome_content_renderer_client.h" |
| #include "chrome/renderer/spellchecker/spellcheck.h" |
| #include "content/public/renderer/render_view.h" |
| @@ -21,8 +22,48 @@ using WebKit::WebFrame; |
| using WebKit::WebString; |
| using WebKit::WebTextCheckingCompletion; |
| using WebKit::WebTextCheckingResult; |
| +using WebKit::WebTextCheckingType; |
| using WebKit::WebVector; |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeSpelling) == |
| + int(SpellCheckResult::Spelling), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeGrammar) == |
| + int(SpellCheckResult::Grammar), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeLink) == |
| + int(SpellCheckResult::Link), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeQuote) == |
| + int(SpellCheckResult::Quote), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeDash) == |
| + int(SpellCheckResult::Dash), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeReplacement) == |
| + int(SpellCheckResult::Replacement), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeCorrection) == |
| + int(SpellCheckResult::Correction), mismatching_enums); |
| +COMPILE_ASSERT(int(WebKit::WebTextCheckingTypeShowCorrectionPanel) == |
| + int(SpellCheckResult::ShowCorrectionPanel), mismatching_enums); |
| + |
| +void ToWebResultList( |
|
Hironori Bono
2012/02/16 04:22:45
nit: need 'namespace {' above this function to pre
|
| + const std::vector<SpellCheckResult>& results, |
| + WebVector<WebTextCheckingResult>* web_results) { |
| + WebVector<WebTextCheckingResult> list(results.size()); |
| + for (size_t i = 0; i < results.size(); ++i) { |
| + list[i] = WebTextCheckingResult( |
| + static_cast<WebTextCheckingType>(results[i].type()), |
| + results[i].location(), |
| + results[i].length(), |
| + results[i].replacement()); |
| + } |
| + |
| + list.swap(*web_results); |
| +} |
| + |
| +WebVector<WebTextCheckingResult> ToWebResultList( |
| + const std::vector<SpellCheckResult>& results) { |
| + WebVector<WebTextCheckingResult> web_results; |
| + ToWebResultList(results, &web_results); |
| + return web_results; |
| +} |
|
Hironori Bono
2012/02/16 04:22:45
nit: need '} // namespace' here.
|
| + |
| SpellCheckProvider::SpellCheckProvider( |
| content::RenderView* render_view, |
| chrome::ChromeContentRendererClient* renderer_client) |
| @@ -157,12 +198,12 @@ void SpellCheckProvider::checkTextOfParagraph( |
| if (!chrome_content_renderer_client_) |
| return; |
| - std::vector<WebKit::WebTextCheckingResult> tmp_results; |
| + std::vector<SpellCheckResult> tmp_results; |
| chrome_content_renderer_client_->spellcheck()->SpellCheckParagraph( |
| string16(text), |
| document_tag_, |
| &tmp_results); |
| - *results = tmp_results; |
| + ToWebResultList(tmp_results, results); |
| #endif |
| } |
| @@ -214,13 +255,13 @@ void SpellCheckProvider::OnAdvanceToNextMisspelling() { |
| void SpellCheckProvider::OnRespondSpellingService( |
| int identifier, |
| int tag, |
| - const std::vector<WebTextCheckingResult>& results) { |
| + const std::vector<SpellCheckResult>& results) { |
| WebTextCheckingCompletion* completion = |
| text_check_completions_.Lookup(identifier); |
| if (!completion) |
| return; |
| text_check_completions_.Remove(identifier); |
| - completion->didFinishCheckingText(results); |
| + completion->didFinishCheckingText(ToWebResultList(results)); |
| } |
| #endif |
| @@ -228,13 +269,13 @@ void SpellCheckProvider::OnRespondSpellingService( |
| void SpellCheckProvider::OnRespondTextCheck( |
| int identifier, |
| int tag, |
| - const std::vector<WebTextCheckingResult>& results) { |
| + const std::vector<SpellCheckResult>& results) { |
| WebTextCheckingCompletion* completion = |
| text_check_completions_.Lookup(identifier); |
| if (!completion) |
| return; |
| text_check_completions_.Remove(identifier); |
| - completion->didFinishCheckingText(results); |
| + completion->didFinishCheckingText(ToWebResultList(results)); |
| } |
| #endif |