| Index: views/ime/input_method.h
|
| diff --git a/views/ime/input_method.h b/views/ime/input_method.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3eb87cbcd6a1fc020e11af5e45f8366439a620cc
|
| --- /dev/null
|
| +++ b/views/ime/input_method.h
|
| @@ -0,0 +1,75 @@
|
| +// Copyright (c) 2011 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 VIEWS_IME_INPUT_METHOD_H_
|
| +#define VIEWS_IME_INPUT_METHOD_H_
|
| +#pragma once
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/i18n/rtl.h"
|
| +
|
| +namespace views {
|
| +
|
| +namespace internal {
|
| +class InputMethodDelegate;
|
| +} // namespace internal
|
| +
|
| +class KeyEvent;
|
| +class View;
|
| +class Widget;
|
| +
|
| +// An interface implemented by an object that encapsulates a native input method
|
| +// service provided by the underlying operation system.
|
| +class InputMethod {
|
| + public:
|
| + virtual ~InputMethod() {}
|
| +
|
| + // Sets the delegate used by this InputMethod instance. It should only be
|
| + // called by the internal NativeWidget or testing code.
|
| + virtual void set_delegate(internal::InputMethodDelegate* delegate) = 0;
|
| +
|
| + // Initialize the InputMethod object and attach it to the given |widget|.
|
| + // The |widget| must already be initialized.
|
| + virtual void Init(Widget* widget) = 0;
|
| +
|
| + // Dispatch a key event to the input method. The key event will be dispatched
|
| + // back to the caller via InputMethodDelegate::DispatchKeyEventPostIME(), once
|
| + // it's processed by the input method.
|
| + virtual void DispatchKeyEvent(const KeyEvent& key) = 0;
|
| +
|
| + // Called by the focused |view| whenever its text input type is changed.
|
| + virtual void OnTextInputTypeChanged(View* view) = 0;
|
| +
|
| + // Called by the focused |view| whenever its caret bounds is changed.
|
| + virtual void OnCaretBoundsChanged(View* view) = 0;
|
| +
|
| + // Called by the focused |view| to ask the input method cancel the ongoing
|
| + // composition session.
|
| + virtual void CancelComposition(View* view) = 0;
|
| +
|
| + // Returns the locale of current keyboard layout or input method, as a BCP-47
|
| + // tag, or an empty string if the input method cannot provide it.
|
| + virtual std::string GetInputLocale() = 0;
|
| +
|
| + // Returns the text direction of current keyboard layout or input method, or
|
| + // base::i18n::UNKNOWN_DIRECTION if the input method cannot provide it.
|
| + virtual base::i18n::TextDirection GetInputTextDirection() = 0;
|
| +
|
| + // Checks if the input method is active, i.e. if it's ready for processing
|
| + // keyboard event and generate composition or text result.
|
| + // If the input method is inactive, then it's not necessary to inform it the
|
| + // changes of caret bounds and text input type.
|
| + // Note: character results may still be generated and sent to the text input
|
| + // client by calling TextInputClient::InsertChar(), even if the input method
|
| + // is not active.
|
| + virtual bool IsActive() = 0;
|
| +
|
| + // TODO(suzhe): Support mouse/touch event.
|
| +};
|
| +
|
| +} // namespace views
|
| +
|
| +#endif // VIEWS_IME_INPUT_METHOD_H_
|
|
|