| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright (c) 2012 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_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |  | 
| 6 #define UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |  | 
| 7 |  | 
| 8 #include <string> |  | 
| 9 |  | 
| 10 #include "base/basictypes.h" |  | 
| 11 #include "base/compiler_specific.h" |  | 
| 12 #include "ui/base/ime/text_input_client.h" |  | 
| 13 #include "ui/gfx/geometry/rect.h" |  | 
| 14 #include "ui/views/ime/input_method_base.h" |  | 
| 15 |  | 
| 16 namespace ui { |  | 
| 17 class InputMethod; |  | 
| 18 }  // namespace ui |  | 
| 19 |  | 
| 20 namespace views { |  | 
| 21 |  | 
| 22 class View; |  | 
| 23 |  | 
| 24 // A "bridge" InputMethod implementation for views top-level widgets, which just |  | 
| 25 // sends/receives IME related events to/from a system-wide ui::InputMethod |  | 
| 26 // object. |  | 
| 27 class InputMethodBridge : public InputMethodBase, |  | 
| 28                           public ui::TextInputClient { |  | 
| 29  public: |  | 
| 30   // |shared_input_method| indicates if |host| is shared among other top level |  | 
| 31   // widgets. |  | 
| 32   InputMethodBridge(internal::InputMethodDelegate* delegate, |  | 
| 33                     ui::InputMethod* host, |  | 
| 34                     bool shared_input_method); |  | 
| 35   ~InputMethodBridge() override; |  | 
| 36 |  | 
| 37   // Overridden from InputMethod: |  | 
| 38   void OnFocus() override; |  | 
| 39   void OnBlur() override; |  | 
| 40   bool OnUntranslatedIMEMessage(const base::NativeEvent& event, |  | 
| 41                                 NativeEventResult* result) override; |  | 
| 42   void DispatchKeyEvent(const ui::KeyEvent& key) override; |  | 
| 43   void OnTextInputTypeChanged(View* view) override; |  | 
| 44   void OnCaretBoundsChanged(View* view) override; |  | 
| 45   void CancelComposition(View* view) override; |  | 
| 46   void OnInputLocaleChanged() override; |  | 
| 47   std::string GetInputLocale() override; |  | 
| 48   bool IsActive() override; |  | 
| 49   bool IsCandidatePopupOpen() const override; |  | 
| 50   void ShowImeIfNeeded() override; |  | 
| 51 |  | 
| 52   // Overridden from TextInputClient: |  | 
| 53   void SetCompositionText(const ui::CompositionText& composition) override; |  | 
| 54   void ConfirmCompositionText() override; |  | 
| 55   void ClearCompositionText() override; |  | 
| 56   void InsertText(const base::string16& text) override; |  | 
| 57   void InsertChar(base::char16 ch, int flags) override; |  | 
| 58   gfx::NativeWindow GetAttachedWindow() const override; |  | 
| 59   ui::TextInputType GetTextInputType() const override; |  | 
| 60   ui::TextInputMode GetTextInputMode() const override; |  | 
| 61   int GetTextInputFlags() const override; |  | 
| 62   bool CanComposeInline() const override; |  | 
| 63   gfx::Rect GetCaretBounds() const override; |  | 
| 64   bool GetCompositionCharacterBounds(uint32 index, |  | 
| 65                                      gfx::Rect* rect) const override; |  | 
| 66   bool HasCompositionText() const override; |  | 
| 67   bool GetTextRange(gfx::Range* range) const override; |  | 
| 68   bool GetCompositionTextRange(gfx::Range* range) const override; |  | 
| 69   bool GetSelectionRange(gfx::Range* range) const override; |  | 
| 70   bool SetSelectionRange(const gfx::Range& range) override; |  | 
| 71   bool DeleteRange(const gfx::Range& range) override; |  | 
| 72   bool GetTextFromRange(const gfx::Range& range, |  | 
| 73                         base::string16* text) const override; |  | 
| 74   void OnInputMethodChanged() override; |  | 
| 75   bool ChangeTextDirectionAndLayoutAlignment( |  | 
| 76       base::i18n::TextDirection direction) override; |  | 
| 77   void ExtendSelectionAndDelete(size_t before, size_t after) override; |  | 
| 78   void EnsureCaretInRect(const gfx::Rect& rect) override; |  | 
| 79   bool IsEditCommandEnabled(int command_id) override; |  | 
| 80   void SetEditCommandForNextKeyEvent(int command_id) override; |  | 
| 81 |  | 
| 82   // Overridden from FocusChangeListener. |  | 
| 83   void OnWillChangeFocus(View* focused_before, View* focused) override; |  | 
| 84   void OnDidChangeFocus(View* focused_before, View* focused) override; |  | 
| 85 |  | 
| 86   ui::InputMethod* GetHostInputMethod() const; |  | 
| 87 |  | 
| 88  private: |  | 
| 89   class HostObserver; |  | 
| 90 |  | 
| 91   void UpdateViewFocusState(); |  | 
| 92 |  | 
| 93   ui::InputMethod* host_; |  | 
| 94 |  | 
| 95   // An observer observing the host input method for cases that the host input |  | 
| 96   // method is destroyed before this bridge input method. |  | 
| 97   scoped_ptr<HostObserver> host_observer_; |  | 
| 98 |  | 
| 99   const bool shared_input_method_; |  | 
| 100 |  | 
| 101   DISALLOW_COPY_AND_ASSIGN(InputMethodBridge); |  | 
| 102 }; |  | 
| 103 |  | 
| 104 }  // namespace views |  | 
| 105 |  | 
| 106 #endif  // UI_VIEWS_IME_INPUT_METHOD_BRIDGE_H_ |  | 
| OLD | NEW | 
|---|