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 CONTENT_SHELL_RENDERER_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
6#define CONTENT_SHELL_RENDERER_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
7
8#include "base/basictypes.h"
9#include "content/shell/renderer/test_runner/mock_spell_check.h"
10#include "content/shell/renderer/test_runner/web_task.h"
11#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
12
13namespace content {
14
15class WebTestDelegate;
16class WebTestProxyBase;
17
18class SpellCheckClient : public blink::WebSpellCheckClient {
19 public:
20  explicit SpellCheckClient(WebTestProxyBase* web_test_proxy);
21  virtual ~SpellCheckClient();
22
23  void SetDelegate(WebTestDelegate* delegate);
24
25  WebTaskList* mutable_task_list() { return &task_list_; }
26  MockSpellCheck* MockSpellCheckWord() { return &spell_check_; }
27
28  // blink::WebSpellCheckClient implementation.
29  virtual void spellCheck(
30      const blink::WebString& text,
31      int& offset,
32      int& length,
33      blink::WebVector<blink::WebString>* optional_suggestions);
34  virtual void checkTextOfParagraph(
35      const blink::WebString& text,
36      blink::WebTextCheckingTypeMask mask,
37      blink::WebVector<blink::WebTextCheckingResult>* web_results);
38  virtual void requestCheckingOfText(
39      const blink::WebString& text,
40      const blink::WebVector<uint32_t>& markers,
41      const blink::WebVector<unsigned>& marker_offsets,
42      blink::WebTextCheckingCompletion* completion);
43  virtual blink::WebString autoCorrectWord(const blink::WebString& word);
44
45 private:
46  void FinishLastTextCheck();
47
48  // The mock spellchecker used in spellCheck().
49  MockSpellCheck spell_check_;
50
51  blink::WebString last_requested_text_check_string_;
52  blink::WebTextCheckingCompletion* last_requested_text_checking_completion_;
53
54  WebTaskList task_list_;
55
56  WebTestDelegate* delegate_;
57
58  WebTestProxyBase* web_test_proxy_;
59
60  DISALLOW_COPY_AND_ASSIGN(SpellCheckClient);
61};
62
63}  // namespace content
64
65#endif  // CONTENT_SHELL_RENDERER_TEST_RUNNER_SPELL_CHECK_CLIENT_H_
66