| 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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <algorithm> | 10 #include <algorithm> |
| 8 | 11 |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/bind.h" | 12 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "base/location.h" | 14 #include "base/location.h" |
| 13 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" |
| 14 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 15 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 19 #include "build/build_config.h" |
| 16 #include "chrome/common/channel_info.h" | 20 #include "chrome/common/channel_info.h" |
| 17 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/spellcheck_common.h" | 22 #include "chrome/common/spellcheck_common.h" |
| 19 #include "chrome/common/spellcheck_messages.h" | 23 #include "chrome/common/spellcheck_messages.h" |
| 20 #include "chrome/common/spellcheck_result.h" | 24 #include "chrome/common/spellcheck_result.h" |
| 21 #include "chrome/renderer/spellchecker/spellcheck_language.h" | 25 #include "chrome/renderer/spellchecker/spellcheck_language.h" |
| 22 #include "chrome/renderer/spellchecker/spellcheck_provider.h" | 26 #include "chrome/renderer/spellchecker/spellcheck_provider.h" |
| 23 #include "content/public/renderer/render_thread.h" | 27 #include "content/public/renderer/render_thread.h" |
| 24 #include "content/public/renderer/render_view.h" | 28 #include "content/public/renderer/render_view.h" |
| 25 #include "content/public/renderer/render_view_visitor.h" | 29 #include "content/public/renderer/render_view_visitor.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view); | 58 SpellCheckProvider* provider = SpellCheckProvider::Get(render_view); |
| 55 DCHECK(provider); | 59 DCHECK(provider); |
| 56 provider->EnableSpellcheck(enabled_); | 60 provider->EnableSpellcheck(enabled_); |
| 57 return true; | 61 return true; |
| 58 } | 62 } |
| 59 | 63 |
| 60 class DocumentMarkersCollector : public content::RenderViewVisitor { | 64 class DocumentMarkersCollector : public content::RenderViewVisitor { |
| 61 public: | 65 public: |
| 62 DocumentMarkersCollector() {} | 66 DocumentMarkersCollector() {} |
| 63 ~DocumentMarkersCollector() override {} | 67 ~DocumentMarkersCollector() override {} |
| 64 const std::vector<uint32>& markers() const { return markers_; } | 68 const std::vector<uint32_t>& markers() const { return markers_; } |
| 65 bool Visit(content::RenderView* render_view) override; | 69 bool Visit(content::RenderView* render_view) override; |
| 66 | 70 |
| 67 private: | 71 private: |
| 68 std::vector<uint32> markers_; | 72 std::vector<uint32_t> markers_; |
| 69 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersCollector); | 73 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersCollector); |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 bool DocumentMarkersCollector::Visit(content::RenderView* render_view) { | 76 bool DocumentMarkersCollector::Visit(content::RenderView* render_view) { |
| 73 if (!render_view || !render_view->GetWebView()) | 77 if (!render_view || !render_view->GetWebView()) |
| 74 return true; | 78 return true; |
| 75 WebVector<uint32> markers; | 79 WebVector<uint32_t> markers; |
| 76 render_view->GetWebView()->spellingMarkers(&markers); | 80 render_view->GetWebView()->spellingMarkers(&markers); |
| 77 for (size_t i = 0; i < markers.size(); ++i) | 81 for (size_t i = 0; i < markers.size(); ++i) |
| 78 markers_.push_back(markers[i]); | 82 markers_.push_back(markers[i]); |
| 79 // Visit all render views. | 83 // Visit all render views. |
| 80 return true; | 84 return true; |
| 81 } | 85 } |
| 82 | 86 |
| 83 class DocumentMarkersRemover : public content::RenderViewVisitor { | 87 class DocumentMarkersRemover : public content::RenderViewVisitor { |
| 84 public: | 88 public: |
| 85 explicit DocumentMarkersRemover(const std::set<std::string>& words); | 89 explicit DocumentMarkersRemover(const std::set<std::string>& words); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 539 |
| 536 bool SpellCheck::IsSpellcheckEnabled() { | 540 bool SpellCheck::IsSpellcheckEnabled() { |
| 537 #if defined(OS_ANDROID) | 541 #if defined(OS_ANDROID) |
| 538 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 542 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 539 switches::kEnableAndroidSpellChecker)) { | 543 switches::kEnableAndroidSpellChecker)) { |
| 540 return false; | 544 return false; |
| 541 } | 545 } |
| 542 #endif | 546 #endif |
| 543 return spellcheck_enabled_; | 547 return spellcheck_enabled_; |
| 544 } | 548 } |
| OLD | NEW |