Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/renderer/spellchecker/spellcheck.cc

Issue 1006953003: Revert "Remove spellcheck feedback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
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 {
49 public:
50 DocumentMarkersCollector() {}
51 ~DocumentMarkersCollector() override {}
52 const std::vector<uint32>& markers() const { return markers_; }
53 bool Visit(content::RenderView* render_view) override;
54
55 private:
56 std::vector<uint32> markers_;
57 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersCollector);
58 };
59
60 bool DocumentMarkersCollector::Visit(content::RenderView* render_view) {
61 if (!render_view || !render_view->GetWebView())
62 return true;
63 WebVector<uint32> markers;
64 render_view->GetWebView()->spellingMarkers(&markers);
65 for (size_t i = 0; i < markers.size(); ++i)
66 markers_.push_back(markers[i]);
67 // Visit all render views.
68 return true;
69 }
70
48 class DocumentMarkersRemover : public content::RenderViewVisitor { 71 class DocumentMarkersRemover : public content::RenderViewVisitor {
49 public: 72 public:
50 explicit DocumentMarkersRemover(const std::vector<std::string>& words); 73 explicit DocumentMarkersRemover(const std::vector<std::string>& words);
51 ~DocumentMarkersRemover() override {} 74 ~DocumentMarkersRemover() override {}
52 bool Visit(content::RenderView* render_view) override; 75 bool Visit(content::RenderView* render_view) override;
53 76
54 private: 77 private:
55 WebVector<WebString> words_; 78 WebVector<WebString> words_;
56 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersRemover); 79 DISALLOW_COPY_AND_ASSIGN(DocumentMarkersRemover);
57 }; 80 };
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 140
118 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { 141 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) {
119 bool handled = true; 142 bool handled = true;
120 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) 143 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message)
121 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit) 144 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInit)
122 IPC_MESSAGE_HANDLER(SpellCheckMsg_CustomDictionaryChanged, 145 IPC_MESSAGE_HANDLER(SpellCheckMsg_CustomDictionaryChanged,
123 OnCustomDictionaryChanged) 146 OnCustomDictionaryChanged)
124 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, 147 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect,
125 OnEnableAutoSpellCorrect) 148 OnEnableAutoSpellCorrect)
126 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableSpellCheck, OnEnableSpellCheck) 149 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableSpellCheck, OnEnableSpellCheck)
150 IPC_MESSAGE_HANDLER(SpellCheckMsg_RequestDocumentMarkers,
151 OnRequestDocumentMarkers)
127 IPC_MESSAGE_UNHANDLED(handled = false) 152 IPC_MESSAGE_UNHANDLED(handled = false)
128 IPC_END_MESSAGE_MAP() 153 IPC_END_MESSAGE_MAP()
129 154
130 return handled; 155 return handled;
131 } 156 }
132 157
133 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file, 158 void SpellCheck::OnInit(IPC::PlatformFileForTransit bdict_file,
134 const std::set<std::string>& custom_words, 159 const std::set<std::string>& custom_words,
135 const std::string& language, 160 const std::string& language,
136 bool auto_spell_correct) { 161 bool auto_spell_correct) {
(...skipping 18 matching lines...) Expand all
155 void SpellCheck::OnEnableAutoSpellCorrect(bool enable) { 180 void SpellCheck::OnEnableAutoSpellCorrect(bool enable) {
156 auto_spell_correct_turned_on_ = enable; 181 auto_spell_correct_turned_on_ = enable;
157 } 182 }
158 183
159 void SpellCheck::OnEnableSpellCheck(bool enable) { 184 void SpellCheck::OnEnableSpellCheck(bool enable) {
160 spellcheck_enabled_ = enable; 185 spellcheck_enabled_ = enable;
161 UpdateSpellcheckEnabled updater(enable); 186 UpdateSpellcheckEnabled updater(enable);
162 content::RenderView::ForEach(&updater); 187 content::RenderView::ForEach(&updater);
163 } 188 }
164 189
190 void SpellCheck::OnRequestDocumentMarkers() {
191 DocumentMarkersCollector collector;
192 content::RenderView::ForEach(&collector);
193 content::RenderThread::Get()->Send(
194 new SpellCheckHostMsg_RespondDocumentMarkers(collector.markers()));
195 }
196
165 // TODO(groby): Make sure we always have a spelling engine, even before Init() 197 // TODO(groby): Make sure we always have a spelling engine, even before Init()
166 // is called. 198 // is called.
167 void SpellCheck::Init(base::File file, 199 void SpellCheck::Init(base::File file,
168 const std::set<std::string>& custom_words, 200 const std::set<std::string>& custom_words,
169 const std::string& language) { 201 const std::string& language) {
170 spellcheck_.Init(file.Pass(), language); 202 spellcheck_.Init(file.Pass(), language);
171 custom_dictionary_.Init(custom_words); 203 custom_dictionary_.Init(custom_words);
172 } 204 }
173 205
174 bool SpellCheck::SpellCheckWord( 206 bool SpellCheck::SpellCheckWord(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 list.push_back(WebTextCheckingResult( 403 list.push_back(WebTextCheckingResult(
372 static_cast<WebTextDecorationType>(decoration), 404 static_cast<WebTextDecorationType>(decoration),
373 word_location + line_offset, 405 word_location + line_offset,
374 word_length, 406 word_length,
375 spellcheck_results[i].replacement, 407 spellcheck_results[i].replacement,
376 spellcheck_results[i].hash)); 408 spellcheck_results[i].hash));
377 } 409 }
378 } 410 }
379 textcheck_results->assign(list); 411 textcheck_results->assign(list);
380 } 412 }
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698