1 // Copyright 2020 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_SUGGESTER_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_SUGGESTER_H_
7 
8 #include <string>
9 
10 #include "chrome/browser/chromeos/input_method/input_method_engine.h"
11 #include "chrome/browser/chromeos/input_method/input_method_engine_base.h"
12 #include "chrome/browser/chromeos/input_method/suggestion_enums.h"
13 
14 namespace chromeos {
15 
16 // A generic agent to suggest when the user types, and adopt or dismiss the
17 // suggestion according to the user action.
18 class Suggester {
19  public:
~Suggester()20   virtual ~Suggester() {}
21 
22   // Called when a text field gains focus, and suggester starts working.
23   virtual void OnFocus(int context_id) = 0;
24 
25   // Called when a text field loses focus, and suggester stops working.
26   virtual void OnBlur() = 0;
27 
28   // Called when suggestion is being shown.
29   // Returns SuggestionStatus as suggester handles the event.
30   virtual SuggestionStatus HandleKeyEvent(
31       const InputMethodEngineBase::KeyboardEvent& event) = 0;
32 
33   // Check if suggestion should be displayed according to the surrounding text
34   // information.
35   virtual bool Suggest(const base::string16& text) = 0;
36 
37   // Accepts the suggestion at a given index, index can be made default if
38   // unnecessary. Returns true if suggestion is accepted successfully.
39   virtual bool AcceptSuggestion(size_t index) = 0;
40 
41   virtual void DismissSuggestion() = 0;
42 
43   // Return the propose assistive action type.
44   virtual AssistiveType GetProposeActionType() = 0;
45 };
46 
47 }  // namespace chromeos
48 
49 #endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_SUGGESTER_H_
50