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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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"
11 #include "chrome/common/spellcheck_common.h" 11 #include "chrome/common/spellcheck_common.h"
12 #include "chrome/common/spellcheck_messages.h" 12 #include "chrome/common/spellcheck_messages.h"
13 #include "chrome/common/spellcheck_result.h" 13 #include "chrome/common/spellcheck_result.h"
14 #include "chrome/renderer/spellchecker/spellcheck_language.h" 14 #include "chrome/renderer/spellchecker/spellcheck_language.h"
15 #include "chrome/renderer/spellchecker/spellcheck_provider.h" 15 #include "chrome/renderer/spellchecker/spellcheck_provider.h"
16 #include "content/public/renderer/render_thread.h" 16 #include "content/public/renderer/render_thread.h"
17 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
18 #include "content/public/renderer/render_view_visitor.h" 18 #include "content/public/renderer/render_view_visitor.h"
19 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" 19 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
20 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" 20 #include "third_party/WebKit/public/web/WebTextCheckingResult.h"
21 #include "third_party/WebKit/public/web/WebTextDecorationType.h" 21 #include "third_party/WebKit/public/web/WebTextDecorationType.h"
22 #include "third_party/WebKit/public/web/WebView.h" 22 #include "third_party/WebKit/public/web/WebView.h"
23 23
24 using WebKit::WebVector; 24 using blink::WebVector;
25 using WebKit::WebTextCheckingResult; 25 using blink::WebTextCheckingResult;
26 using WebKit::WebTextDecorationType; 26 using blink::WebTextDecorationType;
27 27
28 namespace { 28 namespace {
29 29
30 class UpdateSpellcheckEnabled : public content::RenderViewVisitor { 30 class UpdateSpellcheckEnabled : public content::RenderViewVisitor {
31 public: 31 public:
32 explicit UpdateSpellcheckEnabled(bool enabled) : enabled_(enabled) {} 32 explicit UpdateSpellcheckEnabled(bool enabled) : enabled_(enabled) {}
33 virtual bool Visit(content::RenderView* render_view) OVERRIDE; 33 virtual bool Visit(content::RenderView* render_view) OVERRIDE;
34 34
35 private: 35 private:
36 bool enabled_; // New spellcheck-enabled state. 36 bool enabled_; // New spellcheck-enabled state.
(...skipping 28 matching lines...) Expand all
65 markers_.push_back(markers[i]); 65 markers_.push_back(markers[i]);
66 // Visit all render views. 66 // Visit all render views.
67 return true; 67 return true;
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 class SpellCheck::SpellcheckRequest { 72 class SpellCheck::SpellcheckRequest {
73 public: 73 public:
74 SpellcheckRequest(const string16& text, 74 SpellcheckRequest(const string16& text,
75 WebKit::WebTextCheckingCompletion* completion) 75 blink::WebTextCheckingCompletion* completion)
76 : text_(text), completion_(completion) { 76 : text_(text), completion_(completion) {
77 DCHECK(completion); 77 DCHECK(completion);
78 } 78 }
79 ~SpellcheckRequest() {} 79 ~SpellcheckRequest() {}
80 80
81 string16 text() { return text_; } 81 string16 text() { return text_; }
82 WebKit::WebTextCheckingCompletion* completion() { return completion_; } 82 blink::WebTextCheckingCompletion* completion() { return completion_; }
83 83
84 private: 84 private:
85 string16 text_; // Text to be checked in this task. 85 string16 text_; // Text to be checked in this task.
86 86
87 // The interface to send the misspelled ranges to WebKit. 87 // The interface to send the misspelled ranges to WebKit.
88 WebKit::WebTextCheckingCompletion* completion_; 88 blink::WebTextCheckingCompletion* completion_;
89 89
90 DISALLOW_COPY_AND_ASSIGN(SpellcheckRequest); 90 DISALLOW_COPY_AND_ASSIGN(SpellcheckRequest);
91 }; 91 };
92 92
93 93
94 // Initializes SpellCheck object. 94 // Initializes SpellCheck object.
95 // spellcheck_enabled_ currently MUST be set to true, due to peculiarities of 95 // spellcheck_enabled_ currently MUST be set to true, due to peculiarities of
96 // the initialization sequence. 96 // the initialization sequence.
97 // Since it defaults to true, newly created SpellCheckProviders will enable 97 // Since it defaults to true, newly created SpellCheckProviders will enable
98 // spellchecking. After the first word is typed, the provider requests a check, 98 // spellchecking. After the first word is typed, the provider requests a check,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 &misspelling_length, 220 &misspelling_length,
221 NULL)) { 221 NULL)) {
222 results->assign(textcheck_results); 222 results->assign(textcheck_results);
223 return true; 223 return true;
224 } 224 }
225 225
226 if (!custom_dictionary_.SpellCheckWord( 226 if (!custom_dictionary_.SpellCheckWord(
227 text, misspelling_start + offset, misspelling_length)) { 227 text, misspelling_start + offset, misspelling_length)) {
228 string16 replacement; 228 string16 replacement;
229 textcheck_results.push_back(WebTextCheckingResult( 229 textcheck_results.push_back(WebTextCheckingResult(
230 WebKit::WebTextDecorationTypeSpelling, 230 blink::WebTextDecorationTypeSpelling,
231 misspelling_start + offset, 231 misspelling_start + offset,
232 misspelling_length, 232 misspelling_length,
233 replacement)); 233 replacement));
234 } 234 }
235 offset += misspelling_start + misspelling_length; 235 offset += misspelling_start + misspelling_length;
236 } 236 }
237 results->assign(textcheck_results); 237 results->assign(textcheck_results);
238 return false; 238 return false;
239 #else 239 #else
240 // This function is only invoked for spell checker functionality that runs 240 // This function is only invoked for spell checker functionality that runs
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 // Restore the swapped characters. 293 // Restore the swapped characters.
294 std::swap(misspelled_word[i], misspelled_word[i + 1]); 294 std::swap(misspelled_word[i], misspelled_word[i + 1]);
295 } 295 }
296 return autocorrect_word; 296 return autocorrect_word;
297 } 297 }
298 298
299 #if !defined(OS_MACOSX) // OSX uses its own spell checker 299 #if !defined(OS_MACOSX) // OSX uses its own spell checker
300 void SpellCheck::RequestTextChecking( 300 void SpellCheck::RequestTextChecking(
301 const string16& text, 301 const string16& text,
302 WebKit::WebTextCheckingCompletion* completion) { 302 blink::WebTextCheckingCompletion* completion) {
303 // Clean up the previous request before starting a new request. 303 // Clean up the previous request before starting a new request.
304 if (pending_request_param_.get()) 304 if (pending_request_param_.get())
305 pending_request_param_->completion()->didCancelCheckingText(); 305 pending_request_param_->completion()->didCancelCheckingText();
306 306
307 pending_request_param_.reset(new SpellcheckRequest( 307 pending_request_param_.reset(new SpellcheckRequest(
308 text, completion)); 308 text, completion));
309 // We will check this text after we finish loading the hunspell dictionary. 309 // We will check this text after we finish loading the hunspell dictionary.
310 if (InitializeIfNeeded()) 310 if (InitializeIfNeeded())
311 return; 311 return;
312 312
(...skipping 17 matching lines...) Expand all
330 } 330 }
331 #endif 331 #endif
332 332
333 #if !defined(OS_MACOSX) // Mac uses its native engine instead. 333 #if !defined(OS_MACOSX) // Mac uses its native engine instead.
334 void SpellCheck::PerformSpellCheck(SpellcheckRequest* param) { 334 void SpellCheck::PerformSpellCheck(SpellcheckRequest* param) {
335 DCHECK(param); 335 DCHECK(param);
336 336
337 if (!spellcheck_.IsEnabled()) { 337 if (!spellcheck_.IsEnabled()) {
338 param->completion()->didCancelCheckingText(); 338 param->completion()->didCancelCheckingText();
339 } else { 339 } else {
340 WebVector<WebKit::WebTextCheckingResult> results; 340 WebVector<blink::WebTextCheckingResult> results;
341 SpellCheckParagraph(param->text(), &results); 341 SpellCheckParagraph(param->text(), &results);
342 param->completion()->didFinishCheckingText(results); 342 param->completion()->didFinishCheckingText(results);
343 } 343 }
344 } 344 }
345 #endif 345 #endif
346 346
347 void SpellCheck::CreateTextCheckingResults( 347 void SpellCheck::CreateTextCheckingResults(
348 ResultFilter filter, 348 ResultFilter filter,
349 int line_offset, 349 int line_offset,
350 const string16& line_text, 350 const string16& line_text,
(...skipping 22 matching lines...) Expand all
373 list.push_back(WebTextCheckingResult( 373 list.push_back(WebTextCheckingResult(
374 static_cast<WebTextDecorationType>(decoration), 374 static_cast<WebTextDecorationType>(decoration),
375 word_location + line_offset, 375 word_location + line_offset,
376 word_length, 376 word_length,
377 spellcheck_results[i].replacement, 377 spellcheck_results[i].replacement,
378 spellcheck_results[i].hash)); 378 spellcheck_results[i].hash));
379 } 379 }
380 } 380 }
381 textcheck_results->assign(list); 381 textcheck_results->assign(list);
382 } 382 }
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck.h ('k') | chrome/renderer/spellchecker/spellcheck_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698