1 // Copyright 2013 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 UI_BASE_IME_DUMMY_TEXT_INPUT_CLIENT_H_ 6 #define UI_BASE_IME_DUMMY_TEXT_INPUT_CLIENT_H_ 7 8 #include <stddef.h> 9 #include <stdint.h> 10 11 #include "base/macros.h" 12 #include "build/build_config.h" 13 #include "ui/base/ime/text_input_client.h" 14 15 namespace ui { 16 17 // Dummy implementation of TextInputClient. All functions do nothing. 18 class DummyTextInputClient : public TextInputClient { 19 public: 20 DummyTextInputClient(); 21 explicit DummyTextInputClient(TextInputType text_input_type); 22 DummyTextInputClient(TextInputType text_input_type, 23 TextInputMode text_input_mode); 24 ~DummyTextInputClient() override; 25 26 // Overriden from TextInputClient. 27 void SetCompositionText(const CompositionText& composition) override; 28 uint32_t ConfirmCompositionText(bool keep_selection) override; 29 void ClearCompositionText() override; 30 void InsertText(const base::string16& text) override; 31 void InsertChar(const KeyEvent& event) override; 32 TextInputType GetTextInputType() const override; 33 TextInputMode GetTextInputMode() const override; 34 base::i18n::TextDirection GetTextDirection() const override; 35 int GetTextInputFlags() const override; 36 bool CanComposeInline() const override; 37 gfx::Rect GetCaretBounds() const override; 38 bool GetCompositionCharacterBounds(uint32_t index, 39 gfx::Rect* rect) const override; 40 bool HasCompositionText() const override; 41 ui::TextInputClient::FocusReason GetFocusReason() const override; 42 bool GetTextRange(gfx::Range* range) const override; 43 bool GetCompositionTextRange(gfx::Range* range) const override; 44 bool GetEditableSelectionRange(gfx::Range* range) const override; 45 bool SetEditableSelectionRange(const gfx::Range& range) override; 46 bool DeleteRange(const gfx::Range& range) override; 47 bool GetTextFromRange(const gfx::Range& range, 48 base::string16* text) const override; 49 void OnInputMethodChanged() override; 50 bool ChangeTextDirectionAndLayoutAlignment( 51 base::i18n::TextDirection direction) override; 52 void ExtendSelectionAndDelete(size_t before, size_t after) override; 53 void EnsureCaretNotInRect(const gfx::Rect& rect) override; 54 bool IsTextEditCommandEnabled(TextEditCommand command) const override; 55 void SetTextEditCommandForNextKeyEvent(TextEditCommand command) override; 56 ukm::SourceId GetClientSourceForMetrics() const override; 57 bool ShouldDoLearning() override; 58 59 #if defined(OS_WIN) || defined(OS_CHROMEOS) 60 bool SetCompositionFromExistingText( 61 const gfx::Range& range, 62 const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) override; 63 #endif 64 65 #if defined(OS_CHROMEOS) 66 gfx::Range GetAutocorrectRange() const override; 67 gfx::Rect GetAutocorrectCharacterBounds() const override; 68 bool SetAutocorrectRange(const base::string16& autocorrect_text, 69 const gfx::Range& range) override; 70 void ClearAutocorrectRange() override; 71 #endif 72 73 #if defined(OS_WIN) 74 void GetActiveTextInputControlLayoutBounds( 75 base::Optional<gfx::Rect>* control_bounds, 76 base::Optional<gfx::Rect>* selection_bounds) override; 77 void SetActiveCompositionForAccessibility( 78 const gfx::Range& range, 79 const base::string16& active_composition_text, 80 bool is_composition_committed) override; 81 #endif 82 insert_char_count()83 int insert_char_count() const { return insert_char_count_; } last_insert_char()84 base::char16 last_insert_char() const { return last_insert_char_; } insert_text_history()85 const std::vector<base::string16>& insert_text_history() const { 86 return insert_text_history_; 87 } composition_history()88 const std::vector<CompositionText>& composition_history() const { 89 return composition_history_; 90 } selection_history()91 const std::vector<gfx::Range>& selection_history() const { 92 return selection_history_; 93 } 94 95 TextInputType text_input_type_; 96 TextInputMode text_input_mode_; 97 98 DISALLOW_COPY_AND_ASSIGN(DummyTextInputClient); 99 100 private: 101 int insert_char_count_; 102 base::char16 last_insert_char_; 103 std::vector<base::string16> insert_text_history_; 104 std::vector<CompositionText> composition_history_; 105 std::vector<gfx::Range> selection_history_; 106 gfx::Range autocorrect_range_; 107 }; 108 109 } // namespace ui 110 111 #endif // UI_BASE_IME_DUMMY_TEXT_INPUT_CLIENT_H_ 112