| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_ | |
| 6 #define COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "components/test_runner/mock_spell_check.h" | |
| 13 #include "third_party/WebKit/public/platform/WebString.h" | |
| 14 #include "third_party/WebKit/public/platform/WebVector.h" | |
| 15 #include "third_party/WebKit/public/web/WebSpellCheckClient.h" | |
| 16 #include "v8/include/v8.h" | |
| 17 | |
| 18 namespace blink { | |
| 19 class WebTextCheckingCompletion; | |
| 20 } // namespace blink | |
| 21 | |
| 22 namespace test_runner { | |
| 23 | |
| 24 class TestRunner; | |
| 25 class WebTestDelegate; | |
| 26 | |
| 27 class SpellCheckClient : public blink::WebSpellCheckClient { | |
| 28 public: | |
| 29 explicit SpellCheckClient(TestRunner* test_runner); | |
| 30 virtual ~SpellCheckClient(); | |
| 31 | |
| 32 void SetDelegate(WebTestDelegate* delegate); | |
| 33 void SetEnabled(bool enabled); | |
| 34 | |
| 35 // Sets a callback that will be invoked after each request is revoled. | |
| 36 void SetSpellCheckResolvedCallback(v8::Local<v8::Function> callback); | |
| 37 | |
| 38 // Remove the above callback. Beware: don't call it inside the callback. | |
| 39 void RemoveSpellCheckResolvedCallback(); | |
| 40 | |
| 41 void Reset(); | |
| 42 | |
| 43 // blink::WebSpellCheckClient implementation. | |
| 44 void checkSpelling( | |
| 45 const blink::WebString& text, | |
| 46 int& offset, | |
| 47 int& length, | |
| 48 blink::WebVector<blink::WebString>* optional_suggestions) override; | |
| 49 void requestCheckingOfText( | |
| 50 const blink::WebString& text, | |
| 51 const blink::WebVector<uint32_t>& markers, | |
| 52 const blink::WebVector<unsigned>& marker_offsets, | |
| 53 blink::WebTextCheckingCompletion* completion) override; | |
| 54 void cancelAllPendingRequests() override; | |
| 55 | |
| 56 private: | |
| 57 void FinishLastTextCheck(); | |
| 58 | |
| 59 void RequestResolved(); | |
| 60 | |
| 61 // Do not perform any checking when |enabled_ == false|. | |
| 62 // Tests related to spell checking should enable it manually. | |
| 63 bool enabled_ = false; | |
| 64 | |
| 65 // The mock spellchecker used in checkSpelling(). | |
| 66 MockSpellCheck spell_check_; | |
| 67 | |
| 68 blink::WebString last_requested_text_check_string_; | |
| 69 blink::WebTextCheckingCompletion* last_requested_text_checking_completion_; | |
| 70 | |
| 71 v8::Persistent<v8::Function> resolved_callback_; | |
| 72 | |
| 73 TestRunner* test_runner_; | |
| 74 WebTestDelegate* delegate_; | |
| 75 | |
| 76 base::WeakPtrFactory<SpellCheckClient> weak_factory_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(SpellCheckClient); | |
| 79 }; | |
| 80 | |
| 81 } // namespace test_runner | |
| 82 | |
| 83 #endif // COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_ | |
| OLD | NEW |