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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/thread_task_runner_handle.h" |
13 #include "chrome/common/spellcheck_common.h" | 15 #include "chrome/common/spellcheck_common.h" |
14 #include "chrome/common/spellcheck_messages.h" | 16 #include "chrome/common/spellcheck_messages.h" |
15 #include "chrome/common/spellcheck_result.h" | 17 #include "chrome/common/spellcheck_result.h" |
16 #include "chrome/renderer/spellchecker/spellcheck_provider.h" | 18 #include "chrome/renderer/spellchecker/spellcheck_provider.h" |
17 #include "content/public/renderer/render_thread.h" | 19 #include "content/public/renderer/render_thread.h" |
18 #include "content/public/renderer/render_view.h" | 20 #include "content/public/renderer/render_view.h" |
19 #include "content/public/renderer/render_view_visitor.h" | 21 #include "content/public/renderer/render_view_visitor.h" |
20 #include "third_party/WebKit/public/platform/WebString.h" | 22 #include "third_party/WebKit/public/platform/WebString.h" |
21 #include "third_party/WebKit/public/platform/WebVector.h" | 23 #include "third_party/WebKit/public/platform/WebVector.h" |
22 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 24 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 350 |
349 bool SpellCheck::InitializeIfNeeded() { | 351 bool SpellCheck::InitializeIfNeeded() { |
350 return spellcheck_.InitializeIfNeeded(); | 352 return spellcheck_.InitializeIfNeeded(); |
351 } | 353 } |
352 | 354 |
353 #if !defined(OS_MACOSX) // OSX doesn't have |pending_request_param_| | 355 #if !defined(OS_MACOSX) // OSX doesn't have |pending_request_param_| |
354 void SpellCheck::PostDelayedSpellCheckTask(SpellcheckRequest* request) { | 356 void SpellCheck::PostDelayedSpellCheckTask(SpellcheckRequest* request) { |
355 if (!request) | 357 if (!request) |
356 return; | 358 return; |
357 | 359 |
358 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 360 base::ThreadTaskRunnerHandle::Get()->PostTask( |
359 base::Bind(&SpellCheck::PerformSpellCheck, | 361 FROM_HERE, base::Bind(&SpellCheck::PerformSpellCheck, AsWeakPtr(), |
360 AsWeakPtr(), | 362 base::Owned(request))); |
361 base::Owned(request))); | |
362 } | 363 } |
363 #endif | 364 #endif |
364 | 365 |
365 #if !defined(OS_MACOSX) // Mac uses its native engine instead. | 366 #if !defined(OS_MACOSX) // Mac uses its native engine instead. |
366 void SpellCheck::PerformSpellCheck(SpellcheckRequest* param) { | 367 void SpellCheck::PerformSpellCheck(SpellcheckRequest* param) { |
367 DCHECK(param); | 368 DCHECK(param); |
368 | 369 |
369 if (!spellcheck_.IsEnabled()) { | 370 if (!spellcheck_.IsEnabled()) { |
370 param->completion()->didCancelCheckingText(); | 371 param->completion()->didCancelCheckingText(); |
371 } else { | 372 } else { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 list.push_back(WebTextCheckingResult( | 406 list.push_back(WebTextCheckingResult( |
406 static_cast<WebTextDecorationType>(decoration), | 407 static_cast<WebTextDecorationType>(decoration), |
407 word_location + line_offset, | 408 word_location + line_offset, |
408 word_length, | 409 word_length, |
409 spellcheck_results[i].replacement, | 410 spellcheck_results[i].replacement, |
410 spellcheck_results[i].hash)); | 411 spellcheck_results[i].hash)); |
411 } | 412 } |
412 } | 413 } |
413 textcheck_results->assign(list); | 414 textcheck_results->assign(list); |
414 } | 415 } |
OLD | NEW |