| 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_provider.h" | 5 #include "chrome/renderer/spellchecker/spellcheck_provider.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/spellcheck_marker.h" | 10 #include "chrome/common/spellcheck_marker.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const base::string16& text, | 58 const base::string16& text, |
| 59 WebTextCheckingCompletion* completion, | 59 WebTextCheckingCompletion* completion, |
| 60 const std::vector<SpellCheckMarker>& markers) { | 60 const std::vector<SpellCheckMarker>& markers) { |
| 61 // Ignore invalid requests. | 61 // Ignore invalid requests. |
| 62 if (text.empty() || !HasWordCharacters(text, 0)) { | 62 if (text.empty() || !HasWordCharacters(text, 0)) { |
| 63 completion->didCancelCheckingText(); | 63 completion->didCancelCheckingText(); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Try to satisfy check from cache. | 67 // Try to satisfy check from cache. |
| 68 if (SatisfyRequestFromCache(text, completion)) | 68 if (SatisfyRequestFromCache(text, completion)){ |
| 69 LOG(ERROR) << "DYLANKING Cache Hit"; |
| 69 return; | 70 return; |
| 71 } |
| 70 | 72 |
| 71 // Send this text to a browser. A browser checks the user profile and send | 73 // Send this text to a browser. A browser checks the user profile and send |
| 72 // this text to the Spelling service only if a user enables this feature. | 74 // this text to the Spelling service only if a user enables this feature. |
| 73 last_request_.clear(); | 75 last_request_.clear(); |
| 74 last_results_.assign(blink::WebVector<blink::WebTextCheckingResult>()); | 76 last_results_.assign(blink::WebVector<blink::WebTextCheckingResult>()); |
| 75 | 77 |
| 76 #if defined(USE_BROWSER_SPELLCHECKER) | 78 #if defined(USE_BROWSER_SPELLCHECKER) |
| 77 // Text check (unified request for grammar and spell check) is only | 79 // Text check (unified request for grammar and spell check) is only |
| 78 // available for browser process, so we ask the system spellchecker | 80 // available for browser process, so we ask the system spellchecker |
| 79 // over IPC or return an empty result if the checker is not | 81 // over IPC or return an empty result if the checker is not |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 265 } |
| 264 | 266 |
| 265 void SpellCheckProvider::OnRespondTextCheck( | 267 void SpellCheckProvider::OnRespondTextCheck( |
| 266 int identifier, | 268 int identifier, |
| 267 const base::string16& line, | 269 const base::string16& line, |
| 268 const std::vector<SpellCheckResult>& results) { | 270 const std::vector<SpellCheckResult>& results) { |
| 269 // TODO(groby): Unify with SpellCheckProvider::OnRespondSpellingService | 271 // TODO(groby): Unify with SpellCheckProvider::OnRespondSpellingService |
| 270 DCHECK(spellcheck_); | 272 DCHECK(spellcheck_); |
| 271 WebTextCheckingCompletion* completion = | 273 WebTextCheckingCompletion* completion = |
| 272 text_check_completions_.Lookup(identifier); | 274 text_check_completions_.Lookup(identifier); |
| 273 if (!completion) | 275 if (!completion){ |
| 276 LOG(ERROR) << "DYLANKING In OnRespondTextCheck Early Return"; |
| 274 return; | 277 return; |
| 278 } |
| 275 text_check_completions_.Remove(identifier); | 279 text_check_completions_.Remove(identifier); |
| 276 blink::WebVector<blink::WebTextCheckingResult> textcheck_results; | 280 blink::WebVector<blink::WebTextCheckingResult> textcheck_results; |
| 281 LOG(ERROR) << "DYLANKING In OnRespondTextCheck, Calling CreateTextCheckingResu
lts"; |
| 277 spellcheck_->CreateTextCheckingResults(SpellCheck::DO_NOT_MODIFY, | 282 spellcheck_->CreateTextCheckingResults(SpellCheck::DO_NOT_MODIFY, |
| 278 0, | 283 0, |
| 279 line, | 284 line, |
| 280 results, | 285 results, |
| 281 &textcheck_results); | 286 &textcheck_results); |
| 282 completion->didFinishCheckingText(textcheck_results); | 287 completion->didFinishCheckingText(textcheck_results); |
| 283 | 288 |
| 284 // TODO(groby): Add request caching once OSX reports back original request. | 289 // TODO(groby): Add request caching once OSX reports back original request. |
| 285 // (cf. SpellCheckProvider::OnRespondSpellingService) | 290 // (cf. SpellCheckProvider::OnRespondSpellingService) |
| 286 // Cache the request and the converted results. | 291 // Cache the request and the converted results. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 results[i].length = last_results_[i].length; | 358 results[i].length = last_results_[i].length; |
| 354 results[i].replacement = last_results_[i].replacement; | 359 results[i].replacement = last_results_[i].replacement; |
| 355 } | 360 } |
| 356 completion->didFinishCheckingText(results); | 361 completion->didFinishCheckingText(results); |
| 357 return true; | 362 return true; |
| 358 } | 363 } |
| 359 } | 364 } |
| 360 | 365 |
| 361 return false; | 366 return false; |
| 362 } | 367 } |
| OLD | NEW |