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_messages.h" | 10 #include "chrome/common/spellcheck_messages.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 WebString::fromUTF8("ToggleSpellPanel")); | 293 WebString::fromUTF8("ToggleSpellPanel")); |
294 } | 294 } |
295 #endif | 295 #endif |
296 | 296 |
297 void SpellCheckProvider::EnableSpellcheck(bool enable) { | 297 void SpellCheckProvider::EnableSpellcheck(bool enable) { |
298 if (!render_view()->GetWebView()) | 298 if (!render_view()->GetWebView()) |
299 return; | 299 return; |
300 | 300 |
301 WebFrame* frame = render_view()->GetWebView()->focusedFrame(); | 301 WebFrame* frame = render_view()->GetWebView()->focusedFrame(); |
302 frame->enableContinuousSpellChecking(enable); | 302 frame->enableContinuousSpellChecking(enable); |
| 303 if (!enable) |
| 304 frame->removeSpellingMarkers(); |
303 } | 305 } |
304 | 306 |
305 bool SpellCheckProvider::SatisfyRequestFromCache( | 307 bool SpellCheckProvider::SatisfyRequestFromCache( |
306 const WebString& text, | 308 const WebString& text, |
307 WebTextCheckingCompletion* completion) { | 309 WebTextCheckingCompletion* completion) { |
308 size_t last_length = last_request_.length(); | 310 size_t last_length = last_request_.length(); |
309 | 311 |
310 // Send back the |last_results_| if the |last_request_| is a substring of | 312 // Send back the |last_results_| if the |last_request_| is a substring of |
311 // |text| and |text| does not have more words to check. Provider cannot cancel | 313 // |text| and |text| does not have more words to check. Provider cannot cancel |
312 // the spellcheck request here, because WebKit might have discarded the | 314 // the spellcheck request here, because WebKit might have discarded the |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 results[i].length = last_results_[i].length; | 350 results[i].length = last_results_[i].length; |
349 results[i].replacement = last_results_[i].replacement; | 351 results[i].replacement = last_results_[i].replacement; |
350 } | 352 } |
351 completion->didFinishCheckingText(results); | 353 completion->didFinishCheckingText(results); |
352 return true; | 354 return true; |
353 } | 355 } |
354 } | 356 } |
355 | 357 |
356 return false; | 358 return false; |
357 } | 359 } |
OLD | NEW |