| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/test_runner/spell_check_client.h" | 5 #include "components/test_runner/spell_check_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/test_runner/mock_grammar_check.h" | 13 #include "components/test_runner/mock_grammar_check.h" |
| 14 #include "components/test_runner/test_runner.h" | 14 #include "components/test_runner/test_runner.h" |
| 15 #include "components/test_runner/web_task.h" | |
| 16 #include "components/test_runner/web_test_delegate.h" | 15 #include "components/test_runner/web_test_delegate.h" |
| 17 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" | 16 #include "third_party/WebKit/public/web/WebTextCheckingCompletion.h" |
| 18 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" | 17 #include "third_party/WebKit/public/web/WebTextCheckingResult.h" |
| 19 | 18 |
| 20 namespace test_runner { | 19 namespace test_runner { |
| 21 | 20 |
| 22 SpellCheckClient::SpellCheckClient(TestRunner* test_runner) | 21 SpellCheckClient::SpellCheckClient(TestRunner* test_runner) |
| 23 : last_requested_text_checking_completion_(nullptr), | 22 : last_requested_text_checking_completion_(nullptr), |
| 24 test_runner_(test_runner), | 23 test_runner_(test_runner), |
| 25 weak_factory_(this) { | 24 weak_factory_(this) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 65 |
| 67 if (last_requested_text_checking_completion_) | 66 if (last_requested_text_checking_completion_) |
| 68 last_requested_text_checking_completion_->didCancelCheckingText(); | 67 last_requested_text_checking_completion_->didCancelCheckingText(); |
| 69 | 68 |
| 70 last_requested_text_checking_completion_ = completion; | 69 last_requested_text_checking_completion_ = completion; |
| 71 last_requested_text_check_string_ = text; | 70 last_requested_text_check_string_ = text; |
| 72 if (spell_check_.HasInCache(text)) | 71 if (spell_check_.HasInCache(text)) |
| 73 FinishLastTextCheck(); | 72 FinishLastTextCheck(); |
| 74 else | 73 else |
| 75 delegate_->PostDelayedTask( | 74 delegate_->PostDelayedTask( |
| 76 new WebCallbackTask(base::Bind(&SpellCheckClient::FinishLastTextCheck, | 75 base::Bind(&SpellCheckClient::FinishLastTextCheck, |
| 77 weak_factory_.GetWeakPtr())), | 76 weak_factory_.GetWeakPtr()), |
| 78 0); | 77 0); |
| 79 } | 78 } |
| 80 | 79 |
| 81 void SpellCheckClient::cancelAllPendingRequests() { | 80 void SpellCheckClient::cancelAllPendingRequests() { |
| 82 if (!last_requested_text_checking_completion_) | 81 if (!last_requested_text_checking_completion_) |
| 83 return; | 82 return; |
| 84 last_requested_text_checking_completion_->didCancelCheckingText(); | 83 last_requested_text_checking_completion_->didCancelCheckingText(); |
| 85 last_requested_text_checking_completion_ = nullptr; | 84 last_requested_text_checking_completion_ = nullptr; |
| 86 } | 85 } |
| 87 | 86 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 115 &results); | 114 &results); |
| 116 } | 115 } |
| 117 last_requested_text_checking_completion_->didFinishCheckingText(results); | 116 last_requested_text_checking_completion_->didFinishCheckingText(results); |
| 118 last_requested_text_checking_completion_ = 0; | 117 last_requested_text_checking_completion_ = 0; |
| 119 | 118 |
| 120 if (test_runner_->shouldDumpSpellCheckCallbacks()) | 119 if (test_runner_->shouldDumpSpellCheckCallbacks()) |
| 121 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); | 120 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); |
| 122 } | 121 } |
| 123 | 122 |
| 124 } // namespace test_runner | 123 } // namespace test_runner |
| OLD | NEW |