| 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" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 last_requested_text_check_string_ = text; | 89 last_requested_text_check_string_ = text; |
| 90 if (spell_check_.HasInCache(text)) | 90 if (spell_check_.HasInCache(text)) |
| 91 FinishLastTextCheck(); | 91 FinishLastTextCheck(); |
| 92 else | 92 else |
| 93 delegate_->PostDelayedTask( | 93 delegate_->PostDelayedTask( |
| 94 new WebCallbackTask(base::Bind(&SpellCheckClient::FinishLastTextCheck, | 94 new WebCallbackTask(base::Bind(&SpellCheckClient::FinishLastTextCheck, |
| 95 weak_factory_.GetWeakPtr())), | 95 weak_factory_.GetWeakPtr())), |
| 96 0); | 96 0); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void SpellCheckClient::cancelAllPendingRequests() { |
| 100 if (!last_requested_text_checking_completion_) |
| 101 return; |
| 102 last_requested_text_checking_completion_->didCancelCheckingText(); |
| 103 last_requested_text_checking_completion_ = nullptr; |
| 104 } |
| 105 |
| 99 void SpellCheckClient::FinishLastTextCheck() { | 106 void SpellCheckClient::FinishLastTextCheck() { |
| 100 if (!last_requested_text_checking_completion_) | 107 if (!last_requested_text_checking_completion_) |
| 101 return; | 108 return; |
| 102 std::vector<blink::WebTextCheckingResult> results; | 109 std::vector<blink::WebTextCheckingResult> results; |
| 103 int offset = 0; | 110 int offset = 0; |
| 104 base::string16 text = last_requested_text_check_string_; | 111 base::string16 text = last_requested_text_check_string_; |
| 105 if (!spell_check_.IsMultiWordMisspelling(blink::WebString(text), &results)) { | 112 if (!spell_check_.IsMultiWordMisspelling(blink::WebString(text), &results)) { |
| 106 while (text.length()) { | 113 while (text.length()) { |
| 107 int misspelled_position = 0; | 114 int misspelled_position = 0; |
| 108 int misspelled_length = 0; | 115 int misspelled_length = 0; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 126 &results); | 133 &results); |
| 127 } | 134 } |
| 128 last_requested_text_checking_completion_->didFinishCheckingText(results); | 135 last_requested_text_checking_completion_->didFinishCheckingText(results); |
| 129 last_requested_text_checking_completion_ = 0; | 136 last_requested_text_checking_completion_ = 0; |
| 130 | 137 |
| 131 if (test_runner_->shouldDumpSpellCheckCallbacks()) | 138 if (test_runner_->shouldDumpSpellCheckCallbacks()) |
| 132 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); | 139 delegate_->PrintMessage("SpellCheckEvent: FinishLastTextCheck\n"); |
| 133 } | 140 } |
| 134 | 141 |
| 135 } // namespace test_runner | 142 } // namespace test_runner |
| OLD | NEW |