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

Side by Side Diff: components/test_runner/spell_check_client.h

Issue 2587823003: Allow test runner to run a callback when finishing a spellcheck request (Closed)
Patch Set: fix typo... Created 4 years 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
« no previous file with comments | « no previous file | components/test_runner/spell_check_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_ 5 #ifndef COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
6 #define COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_ 6 #define COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "components/test_runner/mock_spell_check.h" 12 #include "components/test_runner/mock_spell_check.h"
13 #include "third_party/WebKit/public/platform/WebString.h" 13 #include "third_party/WebKit/public/platform/WebString.h"
14 #include "third_party/WebKit/public/platform/WebVector.h" 14 #include "third_party/WebKit/public/platform/WebVector.h"
15 #include "third_party/WebKit/public/web/WebSpellCheckClient.h" 15 #include "third_party/WebKit/public/web/WebSpellCheckClient.h"
16 #include "v8/include/v8.h"
16 17
17 namespace blink { 18 namespace blink {
18 class WebTextCheckingCompletion; 19 class WebTextCheckingCompletion;
19 } // namespace blink 20 } // namespace blink
20 21
21 namespace test_runner { 22 namespace test_runner {
22 23
23 class TestRunner; 24 class TestRunner;
24 class WebTestDelegate; 25 class WebTestDelegate;
25 26
26 class SpellCheckClient : public blink::WebSpellCheckClient { 27 class SpellCheckClient : public blink::WebSpellCheckClient {
27 public: 28 public:
28 explicit SpellCheckClient(TestRunner* test_runner); 29 explicit SpellCheckClient(TestRunner* test_runner);
29 virtual ~SpellCheckClient(); 30 virtual ~SpellCheckClient();
30 31
31 void SetDelegate(WebTestDelegate* delegate); 32 void SetDelegate(WebTestDelegate* delegate);
32 void SetEnabled(bool enabled); 33 void SetEnabled(bool enabled);
33 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
34 // blink::WebSpellCheckClient implementation. 43 // blink::WebSpellCheckClient implementation.
35 void spellCheck( 44 void spellCheck(
36 const blink::WebString& text, 45 const blink::WebString& text,
37 int& offset, 46 int& offset,
38 int& length, 47 int& length,
39 blink::WebVector<blink::WebString>* optional_suggestions) override; 48 blink::WebVector<blink::WebString>* optional_suggestions) override;
40 void requestCheckingOfText( 49 void requestCheckingOfText(
41 const blink::WebString& text, 50 const blink::WebString& text,
42 const blink::WebVector<uint32_t>& markers, 51 const blink::WebVector<uint32_t>& markers,
43 const blink::WebVector<unsigned>& marker_offsets, 52 const blink::WebVector<unsigned>& marker_offsets,
44 blink::WebTextCheckingCompletion* completion) override; 53 blink::WebTextCheckingCompletion* completion) override;
45 void cancelAllPendingRequests() override; 54 void cancelAllPendingRequests() override;
46 55
47 private: 56 private:
48 void FinishLastTextCheck(); 57 void FinishLastTextCheck();
49 58
59 void RequestResolved();
60
50 // Do not perform any checking when |enabled_ == false|. 61 // Do not perform any checking when |enabled_ == false|.
51 // Tests related to spell checking should enable it manually. 62 // Tests related to spell checking should enable it manually.
52 bool enabled_ = false; 63 bool enabled_ = false;
53 64
54 // The mock spellchecker used in spellCheck(). 65 // The mock spellchecker used in spellCheck().
55 MockSpellCheck spell_check_; 66 MockSpellCheck spell_check_;
56 67
57 blink::WebString last_requested_text_check_string_; 68 blink::WebString last_requested_text_check_string_;
58 blink::WebTextCheckingCompletion* last_requested_text_checking_completion_; 69 blink::WebTextCheckingCompletion* last_requested_text_checking_completion_;
59 70
71 v8::Persistent<v8::Function> resolved_callback_;
72
60 TestRunner* test_runner_; 73 TestRunner* test_runner_;
61 WebTestDelegate* delegate_; 74 WebTestDelegate* delegate_;
62 75
63 base::WeakPtrFactory<SpellCheckClient> weak_factory_; 76 base::WeakPtrFactory<SpellCheckClient> weak_factory_;
64 77
65 DISALLOW_COPY_AND_ASSIGN(SpellCheckClient); 78 DISALLOW_COPY_AND_ASSIGN(SpellCheckClient);
66 }; 79 };
67 80
68 } // namespace test_runner 81 } // namespace test_runner
69 82
70 #endif // COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_ 83 #endif // COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | components/test_runner/spell_check_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698