| 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 "chrome/renderer/spellchecker/spellcheck.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using blink::WebVector; | 24 using blink::WebVector; |
| 25 using blink::WebString; | 25 using blink::WebString; |
| 26 using blink::WebTextCheckingResult; | 26 using blink::WebTextCheckingResult; |
| 27 using blink::WebTextDecorationType; | 27 using blink::WebTextDecorationType; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 class UpdateSpellcheckEnabled : public content::RenderViewVisitor { | 31 class UpdateSpellcheckEnabled : public content::RenderViewVisitor { |
| 32 public: | 32 public: |
| 33 explicit UpdateSpellcheckEnabled(bool enabled) : enabled_(enabled) {} | 33 explicit UpdateSpellcheckEnabled(bool enabled) : enabled_(enabled) {} |
| 34 virtual bool Visit(content::RenderView* render_view) OVERRIDE; | 34 virtual bool Visit(content::RenderView* render_view) override; |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 bool enabled_; // New spellcheck-enabled state. | 37 bool enabled_; // New spellcheck-enabled state. |
| 38 DISALLOW_COPY_AND_ASSIGN(UpdateSpellcheckEnabled); | 38 DISALLOW_COPY_AND_ASSIGN(UpdateSpellcheckEnabled); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 bool UpdateSpellcheckEnabled::Visit(content::RenderView* render_view) { | 41 bool UpdateSpellcheckEnabled::Visit(content::RenderView* render_view) { |
| 42 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view); | 42 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view); |
| 43 DCHECK(provider); | 43 DCHECK(provider); |
| 44 provider->EnableSpellcheck(enabled_); | 44 provider->EnableSpellcheck(enabled_); |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 | 47 |
| 48 class DocumentMarkersCollector : public content::RenderViewVisitor { | 48 class DocumentMarkersCollector : public content::RenderViewVisitor { |
| 49 public: | 49 public: |
| 50 DocumentMarkersCollector() {} | 50 DocumentMarkersCollector() {} |
| 51 virtual ~DocumentMarkersCollector() {} | 51 virtual ~DocumentMarkersCollector() {} |
| 52 const std::vector<uint32>& markers() const { return markers_; } | 52 const std::vector<uint32>& markers() const { return markers_; } |
| 53 virtual bool Visit(content::RenderView* render_view) OVERRIDE; | 53 virtual bool Visit(content::RenderView* render_view) override; |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 std::vector<uint32> markers_; | 56 std::vector<uint32> markers_; |
| 57 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersCollector); | 57 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersCollector); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 bool DocumentMarkersCollector::Visit(content::RenderView* render_view) { | 60 bool DocumentMarkersCollector::Visit(content::RenderView* render_view) { |
| 61 if (!render_view || !render_view->GetWebView()) | 61 if (!render_view || !render_view->GetWebView()) |
| 62 return true; | 62 return true; |
| 63 WebVector<uint32> markers; | 63 WebVector<uint32> markers; |
| 64 render_view->GetWebView()->spellingMarkers(&markers); | 64 render_view->GetWebView()->spellingMarkers(&markers); |
| 65 for (size_t i = 0; i < markers.size(); ++i) | 65 for (size_t i = 0; i < markers.size(); ++i) |
| 66 markers_.push_back(markers[i]); | 66 markers_.push_back(markers[i]); |
| 67 // Visit all render views. | 67 // Visit all render views. |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 | 70 |
| 71 class DocumentMarkersRemover : public content::RenderViewVisitor { | 71 class DocumentMarkersRemover : public content::RenderViewVisitor { |
| 72 public: | 72 public: |
| 73 explicit DocumentMarkersRemover(const std::vector<std::string>& words); | 73 explicit DocumentMarkersRemover(const std::vector<std::string>& words); |
| 74 virtual ~DocumentMarkersRemover() OVERRIDE {} | 74 virtual ~DocumentMarkersRemover() override {} |
| 75 virtual bool Visit(content::RenderView* render_view) OVERRIDE; | 75 virtual bool Visit(content::RenderView* render_view) override; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 WebVector<WebString> words_; | 78 WebVector<WebString> words_; |
| 79 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersRemover); | 79 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersRemover); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 DocumentMarkersRemover::DocumentMarkersRemover( | 82 DocumentMarkersRemover::DocumentMarkersRemover( |
| 83 const std::vector<std::string>& words) | 83 const std::vector<std::string>& words) |
| 84 : words_(words.size()) { | 84 : words_(words.size()) { |
| 85 for (size_t i = 0; i < words.size(); ++i) | 85 for (size_t i = 0; i < words.size(); ++i) |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 list.push_back(WebTextCheckingResult( | 403 list.push_back(WebTextCheckingResult( |
| 404 static_cast<WebTextDecorationType>(decoration), | 404 static_cast<WebTextDecorationType>(decoration), |
| 405 word_location + line_offset, | 405 word_location + line_offset, |
| 406 word_length, | 406 word_length, |
| 407 spellcheck_results[i].replacement, | 407 spellcheck_results[i].replacement, |
| 408 spellcheck_results[i].hash)); | 408 spellcheck_results[i].hash)); |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 textcheck_results->assign(list); | 411 textcheck_results->assign(list); |
| 412 } | 412 } |
| OLD | NEW |