summaryrefslogtreecommitdiffstats
path: root/components/test_runner/spell_check_client.h
blob: d96afce4d3e2dd607a24dc7c80265972df18f346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
#define COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_

#include "base/basictypes.h"
#include "components/test_runner/mock_spell_check.h"
#include "components/test_runner/web_task.h"
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"

namespace test_runner {

class WebTestDelegate;
class WebTestProxyBase;

class SpellCheckClient : public blink::WebSpellCheckClient {
 public:
  explicit SpellCheckClient(WebTestProxyBase* web_test_proxy);
  virtual ~SpellCheckClient();

  void SetDelegate(WebTestDelegate* delegate);

  WebTaskList* mutable_task_list() { return &task_list_; }
  MockSpellCheck* MockSpellCheckWord() { return &spell_check_; }

  // blink::WebSpellCheckClient implementation.
  virtual void spellCheck(
      const blink::WebString& text,
      int& offset,
      int& length,
      blink::WebVector<blink::WebString>* optional_suggestions);
  virtual void checkTextOfParagraph(
      const blink::WebString& text,
      blink::WebTextCheckingTypeMask mask,
      blink::WebVector<blink::WebTextCheckingResult>* web_results);
  virtual void requestCheckingOfText(
      const blink::WebString& text,
      const blink::WebVector<uint32_t>& markers,
      const blink::WebVector<unsigned>& marker_offsets,
      blink::WebTextCheckingCompletion* completion);
  virtual blink::WebString autoCorrectWord(const blink::WebString& word);

 private:
  void FinishLastTextCheck();

  // The mock spellchecker used in spellCheck().
  MockSpellCheck spell_check_;

  blink::WebString last_requested_text_check_string_;
  blink::WebTextCheckingCompletion* last_requested_text_checking_completion_;

  WebTaskList task_list_;

  WebTestDelegate* delegate_;

  WebTestProxyBase* web_test_proxy_;

  DISALLOW_COPY_AND_ASSIGN(SpellCheckClient);
};

}  // namespace test_runner

#endif  // COMPONENTS_TEST_RUNNER_SPELL_CHECK_CLIENT_H_