MacViews: Implement a ui::InputMethod for Mac

Add InputMethodMac class and update InputMethodFactory to create it.
It doesn't do anything for now. We plan to bridge NSTextInputClient calls
directly to the focused ui::TextInputClient object.

BUG=374077

Review URL: https://codereview.chromium.org/312523003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274636 0039d316-1c4b-4281-b951-d872f2087c98
parent f0d94437
......@@ -42,6 +42,8 @@
'input_method_factory.h',
'input_method_initializer.cc',
'input_method_initializer.h',
'input_method_mac.h',
'input_method_mac.mm',
'input_method_minimal.cc',
'input_method_minimal.h',
'input_method_observer.h',
......
......@@ -12,6 +12,8 @@
#include "base/win/metro.h"
#include "ui/base/ime/input_method_win.h"
#include "ui/base/ime/remote_input_method_win.h"
#elif defined(OS_MACOSX)
#include "ui/base/ime/input_method_mac.h"
#elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "ui/base/ime/input_method_auralinux.h"
#else
......@@ -43,6 +45,8 @@ scoped_ptr<InputMethod> CreateInputMethod(
if (IsRemoteInputMethodWinRequired(widget))
return CreateRemoteInputMethodWin(delegate);
return scoped_ptr<InputMethod>(new InputMethodWin(delegate, widget));
#elif defined(OS_MACOSX)
return scoped_ptr<InputMethod>(new InputMethodMac(delegate));
#elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
return scoped_ptr<InputMethod>(new InputMethodAuraLinux(delegate));
#else
......
// Copyright 2014 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_INPUT_METHOD_MAC_H_
#define UI_BASE_IME_INPUT_METHOD_MAC_H_
#include "ui/base/ime/input_method_base.h"
namespace ui {
// A ui::InputMethod implementation for Mac.
// On the Mac, key events don't pass through InputMethod.
// Instead, NSTextInputClient calls are bridged to the currently focused
// ui::TextInputClient object.
class UI_BASE_EXPORT InputMethodMac : public InputMethodBase {
public:
explicit InputMethodMac(internal::InputMethodDelegate* delegate);
virtual ~InputMethodMac();
// Overriden from InputMethod.
virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
NativeEventResult* result) OVERRIDE;
virtual bool DispatchKeyEvent(const ui::KeyEvent& event) OVERRIDE;
virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
virtual void OnInputLocaleChanged() OVERRIDE;
virtual std::string GetInputLocale() OVERRIDE;
virtual bool IsActive() OVERRIDE;
virtual bool IsCandidatePopupOpen() const OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(InputMethodMac);
};
} // namespace ui
#endif // UI_BASE_IME_INPUT_METHOD_MAC_H_
// Copyright 2014 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.
#include "ui/base/ime/input_method_mac.h"
namespace ui {
InputMethodMac::InputMethodMac(internal::InputMethodDelegate* delegate) {
SetDelegate(delegate);
}
InputMethodMac::~InputMethodMac() {
}
bool InputMethodMac::OnUntranslatedIMEMessage(const base::NativeEvent& event,
NativeEventResult* result) {
return false;
}
bool InputMethodMac::DispatchKeyEvent(const ui::KeyEvent& event) {
// IME processing on the Mac does not go through this path.
NOTREACHED();
return false;
}
void InputMethodMac::OnCaretBoundsChanged(const TextInputClient* client) {
}
void InputMethodMac::CancelComposition(const TextInputClient* client) {
}
void InputMethodMac::OnInputLocaleChanged() {
}
std::string InputMethodMac::GetInputLocale() {
return "";
}
bool InputMethodMac::IsActive() {
return true;
}
bool InputMethodMac::IsCandidatePopupOpen() const {
// There seems to be no way to tell if a candidate window is open.
return false;
}
} // namespace ui
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment