File: remote_input_method_win.h

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (100 lines) | stat: -rw-r--r-- 4,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright 2013 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 UI_BASE_IME_REMOTE_INPUT_METHOD_WIN_H_
#define UI_BASE_IME_REMOTE_INPUT_METHOD_WIN_H_

#include <Windows.h>

#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "ui/base/ui_base_export.h"
#include "ui/gfx/native_widget_types.h"

namespace ui {
namespace internal {
class InputMethodDelegate;
class RemoteInputMethodDelegateWin;
}  // namespace internal

class InputMethod;
struct CompositionText;

// RemoteInputMethodWin is a special implementation of ui::InputMethod that
// works as a proxy of an IME handler running in the metro_driver process.
// RemoteInputMethodWin works as follows.
// - Any action to RemoteInputMethodWin should be delegated to the
//   metro_driver process via RemoteInputMethodDelegateWin.
// - Data retrieval from RemoteInputMethodPrivateWin is implemented with
//   data cache. Whenever the IME state in the metro_driver process is changed,
//   RemoteWindowTreeHostWin, which receives IPCs from metro_driver process,
//   will call RemoteInputMethodPrivateWin::OnCandidatePopupChanged and/or
//   RemoteInputMethodPrivateWin::OnInputSourceChanged accordingly so that
//   the state cache should be updated.
// - Some IPC messages that represent actions to TextInputClient should be
//   delegated to RemoteInputMethodPrivateWin so that RemoteInputMethodWin can
//   work as a real proxy.

// Returns true if |widget| requires RemoteInputMethodWin.
bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget);

// Returns the public interface of RemoteInputMethodWin.
// Caveats: Currently only one instance of RemoteInputMethodWin is able to run
// at the same time.
UI_BASE_EXPORT scoped_ptr<InputMethod> CreateRemoteInputMethodWin(
    internal::InputMethodDelegate* delegate);

// Private interface of RemoteInputMethodWin.
class UI_BASE_EXPORT RemoteInputMethodPrivateWin {
 public:
  RemoteInputMethodPrivateWin();

  // Returns the private interface of RemoteInputMethodWin when and only when
  // |input_method| is instanciated via CreateRemoteInputMethodWin. Caller does
  // not take the ownership of the returned object.
  // As you might notice, this is yet another reinplementation of dynamic_cast
  // or IUnknown::QueryInterface.
  static RemoteInputMethodPrivateWin* Get(InputMethod* input_method);

  // Installs RemoteInputMethodDelegateWin delegate. Set NULL to |delegate| to
  // unregister.
  virtual void SetRemoteDelegate(
      internal::RemoteInputMethodDelegateWin* delegate) = 0;

  // Updates internal cache so that subsequent calls of
  // RemoteInputMethodWin::IsCandidatePopupOpen can return the correct value
  // based on remote IME activities in the metro_driver process.
  virtual void OnCandidatePopupChanged(bool visible) = 0;

  // Updates internal cache so that subsequent calls of
  // RemoteInputMethodWin::GetInputLocale can return the correct values based on
  // remote IME activities in the metro_driver process.
  virtual void OnInputSourceChanged(LANGID langid, bool is_ime) = 0;

  // Handles composition-update events occurred in the metro_driver process.
  // Caveats: This method is designed to be used only with
  // metro_driver::TextService. In other words, there is no garantee that this
  // method works a wrapper to call ui::TextInputClient::SetCompositionText.
  virtual void OnCompositionChanged(
      const CompositionText& composition_text) = 0;

  // Handles text-commit events occurred in the metro_driver process.
  // Caveats: This method is designed to be used only with
  // metro_driver::TextService. In other words, there is no garantee that this
  // method works a wrapper to call ui::TextInputClient::InsertText. In fact,
  // this method may call ui::TextInputClient::InsertChar when the text input
  // type of the focused text input client is TEXT_INPUT_TYPE_NONE.
  virtual void OnTextCommitted(const base::string16& text) = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodPrivateWin);
};

}  // namespace ui

#endif  // UI_BASE_IME_REMOTE_INPUT_METHOD_WIN_H_