Support for providing IMEContext with Ozone.

This patch adds support for Ozone implementations to provide
an IME context implementation.By default we use FakeInputMethodContext.

BUG=None

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241442 0039d316-1c4b-4281-b951-d872f2087c98
parent 45c71343
...@@ -99,13 +99,13 @@ ...@@ -99,13 +99,13 @@
'input_method_tsf.h', 'input_method_tsf.h',
], ],
}], }],
['use_aura==0 or desktop_linux==0', { ['use_aura==0 or (desktop_linux==0 and use_ozone==0)', {
'sources!': [ 'sources!': [
'input_method_auralinux.cc', 'input_method_auralinux.cc',
'input_method_auralinux.h', 'input_method_auralinux.h',
], ],
}], }],
['use_aura==0 or desktop_linux==0', { ['use_aura==0 or (desktop_linux==0 and use_ozone==0)', {
'sources!': [ 'sources!': [
'linux/fake_input_method_context.cc', 'linux/fake_input_method_context.cc',
'linux/fake_input_method_context.h', 'linux/fake_input_method_context.h',
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "ui/base/ime/input_method_imm32.h" #include "ui/base/ime/input_method_imm32.h"
#include "ui/base/ime/input_method_tsf.h" #include "ui/base/ime/input_method_tsf.h"
#include "ui/base/ime/remote_input_method_win.h" #include "ui/base/ime/remote_input_method_win.h"
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
#include "ui/base/ime/input_method_auralinux.h" #include "ui/base/ime/input_method_auralinux.h"
#else #else
#include "ui/base/ime/input_method_minimal.h" #include "ui/base/ime/input_method_minimal.h"
...@@ -72,7 +72,7 @@ scoped_ptr<InputMethod> DefaultInputMethodFactory::CreateInputMethod( ...@@ -72,7 +72,7 @@ scoped_ptr<InputMethod> DefaultInputMethodFactory::CreateInputMethod(
if (IsRemoteInputMethodWinRequired(widget)) if (IsRemoteInputMethodWinRequired(widget))
return CreateRemoteInputMethodWin(delegate); return CreateRemoteInputMethodWin(delegate);
return scoped_ptr<InputMethod>(new InputMethodIMM32(delegate, widget)); return scoped_ptr<InputMethod>(new InputMethodIMM32(delegate, widget));
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
return scoped_ptr<InputMethod>(new InputMethodAuraLinux(delegate)); return scoped_ptr<InputMethod>(new InputMethodAuraLinux(delegate));
#else #else
return scoped_ptr<InputMethod>(new InputMethodMinimal(delegate)); return scoped_ptr<InputMethod>(new InputMethodMinimal(delegate));
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "ui/base/ime/chromeos/ibus_bridge.h" #include "ui/base/ime/chromeos/ibus_bridge.h"
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
#include "ui/base/ime/input_method_auralinux.h" #include "ui/base/ime/input_method_auralinux.h"
#include "ui/base/ime/linux/fake_input_method_context_factory.h" #include "ui/base/ime/linux/fake_input_method_context_factory.h"
#elif defined(OS_WIN) #elif defined(OS_WIN)
...@@ -24,7 +24,7 @@ namespace { ...@@ -24,7 +24,7 @@ namespace {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
bool dbus_thread_manager_was_initialized = false; bool dbus_thread_manager_was_initialized = false;
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory;
#endif #endif
...@@ -35,7 +35,7 @@ namespace ui { ...@@ -35,7 +35,7 @@ namespace ui {
void InitializeInputMethod() { void InitializeInputMethod() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
chromeos::IBusBridge::Initialize(); chromeos::IBusBridge::Initialize();
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
InputMethodAuraLinux::Initialize(); InputMethodAuraLinux::Initialize();
#elif defined(OS_WIN) #elif defined(OS_WIN)
if (base::win::IsTSFAwareRequired()) if (base::win::IsTSFAwareRequired())
...@@ -64,7 +64,7 @@ void InitializeInputMethodForTesting() { ...@@ -64,7 +64,7 @@ void InitializeInputMethodForTesting() {
chromeos::DBusThreadManager::InitializeWithStub(); chromeos::DBusThreadManager::InitializeWithStub();
dbus_thread_manager_was_initialized = true; dbus_thread_manager_was_initialized = true;
} }
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
if (!g_linux_input_method_context_factory) if (!g_linux_input_method_context_factory)
g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); g_linux_input_method_context_factory = new FakeInputMethodContextFactory();
const LinuxInputMethodContextFactory* factory = const LinuxInputMethodContextFactory* factory =
...@@ -94,7 +94,7 @@ void ShutdownInputMethodForTesting() { ...@@ -94,7 +94,7 @@ void ShutdownInputMethodForTesting() {
chromeos::DBusThreadManager::Shutdown(); chromeos::DBusThreadManager::Shutdown();
dbus_thread_manager_was_initialized = false; dbus_thread_manager_was_initialized = false;
} }
#elif defined(USE_AURA) && defined(USE_X11) #elif defined(USE_AURA) && defined(OS_LINUX)
const LinuxInputMethodContextFactory* factory = const LinuxInputMethodContextFactory* factory =
LinuxInputMethodContextFactory::instance(); LinuxInputMethodContextFactory::instance();
CHECK(!factory || factory == g_linux_input_method_context_factory) CHECK(!factory || factory == g_linux_input_method_context_factory)
......
include_rules = [
"+ui/base/ime",
]
// 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.
#include "ui/ozone/ime/fake_input_method_context_ozone.h"
namespace ui {
FakeInputMethodContextOzone::FakeInputMethodContextOzone() {
}
FakeInputMethodContextOzone::~FakeInputMethodContextOzone() {
}
bool FakeInputMethodContextOzone::DispatchKeyEvent(
const ui::KeyEvent& /* key_event */) {
return false;
}
void FakeInputMethodContextOzone::Reset() {
}
base::i18n::TextDirection FakeInputMethodContextOzone::GetInputTextDirection()
const {
return base::i18n::UNKNOWN_DIRECTION;
}
void FakeInputMethodContextOzone::OnTextInputTypeChanged(
ui::TextInputType /* text_input_type */) {
}
void FakeInputMethodContextOzone::OnCaretBoundsChanged(
const gfx::Rect& /* caret_bounds */) {
}
} // namespace ui
// 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_OZONE_IME_FAKE_INPUT_METHOD_CONTEXT_OZONE_H_
#define UI_OZONE_IME_FAKE_INPUT_METHOD_CONTEXT_OZONE_H_
#include "ui/base/ime/linux/linux_input_method_context.h"
namespace ui {
// A fake implementation of LinuxInputMethodContext, which does nothing.
class FakeInputMethodContextOzone :
public LinuxInputMethodContext {
public:
FakeInputMethodContextOzone();
virtual ~FakeInputMethodContextOzone();
// Overriden from ui::LinuxInputMethodContext
virtual bool DispatchKeyEvent(const ui::KeyEvent& key_event) OVERRIDE;
virtual void Reset() OVERRIDE;
virtual base::i18n::TextDirection GetInputTextDirection() const OVERRIDE;
virtual void OnTextInputTypeChanged(ui::TextInputType text_input_type)
OVERRIDE;
virtual void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(FakeInputMethodContextOzone);
};
} // namespace ui
#endif // UI_OZONE_IME_FAKE_INPUT_METHOD_CONTEXT_OZONE_H_
// 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.
#include "ui/ozone/ime/input_method_context_factory_ozone.h"
#include "ui/ozone/ime/fake_input_method_context_ozone.h"
namespace ui {
InputMethodContextFactoryOzone::InputMethodContextFactoryOzone() {
}
InputMethodContextFactoryOzone::~InputMethodContextFactoryOzone() {
}
scoped_ptr<LinuxInputMethodContext>
InputMethodContextFactoryOzone::CreateInputMethodContext(
LinuxInputMethodContextDelegate* /*delegate*/) const {
return scoped_ptr<LinuxInputMethodContext>(new FakeInputMethodContextOzone());
}
} // namespace ui
// 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_OZONE_IME_INPUT_METHOD_CONTEXT_FACTORY_OZONE_H_
#define UI_OZONE_IME_INPUT_METHOD_CONTEXT_FACTORY_OZONE_H_
#include "ui/base/ime/linux/linux_input_method_context_factory.h"
#include "ui/ozone/ozone_export.h"
namespace ui {
// TODO(kalyan): Move this class to ui/ime, once ui/base/ime is moved to ui/ime.
// An interface that lets different Ozone platforms override the
// CreateInputMethodContext function declared here to return native input method
// contexts.
class OZONE_EXPORT InputMethodContextFactoryOzone :
public LinuxInputMethodContextFactory {
public:
InputMethodContextFactoryOzone();
virtual ~InputMethodContextFactoryOzone();
// By default this returns a minimal input method context.
virtual scoped_ptr<LinuxInputMethodContext> CreateInputMethodContext(
LinuxInputMethodContextDelegate* delegate) const OVERRIDE;
};
} // namespace ui
#endif // UI_OZONE_IME_INPUT_METHOD_CONTEXT_FACTORY_OZONE_H_
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
}, },
'sources': [ 'sources': [
'<(platform_list_file)', '<(platform_list_file)',
'ime/fake_input_method_context_ozone.cc',
'ime/fake_input_method_context_ozone.h',
'ime/input_method_context_factory_ozone.cc',
'ime/input_method_context_factory_ozone.h',
'ozone_platform.cc', 'ozone_platform.cc',
'ozone_platform.h', 'ozone_platform.h',
'ozone_switches.cc', 'ozone_switches.cc',
......
...@@ -54,6 +54,8 @@ void OzonePlatform::Initialize() { ...@@ -54,6 +54,8 @@ void OzonePlatform::Initialize() {
// Inject ozone interfaces. // Inject ozone interfaces.
gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone()); gfx::SurfaceFactoryOzone::SetInstance(instance_->GetSurfaceFactoryOzone());
ui::EventFactoryOzone::SetInstance(instance_->GetEventFactoryOzone()); ui::EventFactoryOzone::SetInstance(instance_->GetEventFactoryOzone());
ui::InputMethodContextFactoryOzone::SetInstance(
instance_->GetInputMethodContextFactoryOzone());
} }
// static // static
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "ui/events/ozone/event_factory_ozone.h" #include "ui/events/ozone/event_factory_ozone.h"
#include "ui/gfx/ozone/surface_factory_ozone.h" #include "ui/gfx/ozone/surface_factory_ozone.h"
#include "ui/ozone/ime/input_method_context_factory_ozone.h"
#include "ui/ozone/ozone_export.h" #include "ui/ozone/ozone_export.h"
namespace ui { namespace ui {
...@@ -40,6 +41,8 @@ class OZONE_EXPORT OzonePlatform { ...@@ -40,6 +41,8 @@ class OZONE_EXPORT OzonePlatform {
// inject these objects themselves. Ownership is retained by OzonePlatform. // inject these objects themselves. Ownership is retained by OzonePlatform.
virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0; virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() = 0;
virtual ui::EventFactoryOzone* GetEventFactoryOzone() = 0; virtual ui::EventFactoryOzone* GetEventFactoryOzone() = 0;
virtual ui::InputMethodContextFactoryOzone*
GetInputMethodContextFactoryOzone() = 0;
private: private:
static OzonePlatform* instance_; static OzonePlatform* instance_;
......
...@@ -20,6 +20,11 @@ ui::EventFactoryOzone* OzonePlatformDri::GetEventFactoryOzone() { ...@@ -20,6 +20,11 @@ ui::EventFactoryOzone* OzonePlatformDri::GetEventFactoryOzone() {
return &event_factory_ozone_; return &event_factory_ozone_;
} }
ui::InputMethodContextFactoryOzone*
OzonePlatformDri::GetInputMethodContextFactoryOzone() {
return &input_method_context_factory_ozone_;
}
OzonePlatform* CreateOzonePlatformDri() { return new OzonePlatformDri; } OzonePlatform* CreateOzonePlatformDri() { return new OzonePlatformDri; }
} // namespace ui } // namespace ui
...@@ -22,10 +22,14 @@ class OzonePlatformDri : public OzonePlatform { ...@@ -22,10 +22,14 @@ class OzonePlatformDri : public OzonePlatform {
virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE; virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE;
virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE; virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE;
virtual ui::InputMethodContextFactoryOzone*
GetInputMethodContextFactoryOzone() OVERRIDE;
private: private:
gfx::DriSurfaceFactory surface_factory_ozone_; gfx::DriSurfaceFactory surface_factory_ozone_;
ui::EventFactoryEvdev event_factory_ozone_; ui::EventFactoryEvdev event_factory_ozone_;
// This creates a minimal input context.
ui::InputMethodContextFactoryOzone input_method_context_factory_ozone_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri); DISALLOW_COPY_AND_ASSIGN(OzonePlatformDri);
}; };
......
...@@ -24,6 +24,11 @@ ui::EventFactoryOzone* OzonePlatformTest::GetEventFactoryOzone() { ...@@ -24,6 +24,11 @@ ui::EventFactoryOzone* OzonePlatformTest::GetEventFactoryOzone() {
return &event_factory_ozone_; return &event_factory_ozone_;
} }
ui::InputMethodContextFactoryOzone*
OzonePlatformTest::GetInputMethodContextFactoryOzone() {
return &input_method_context_factory_ozone_;
}
OzonePlatform* CreateOzonePlatformTest() { OzonePlatform* CreateOzonePlatformTest() {
CommandLine* cmd = CommandLine::ForCurrentProcess(); CommandLine* cmd = CommandLine::ForCurrentProcess();
base::FilePath location = base::FilePath("/dev/null"); base::FilePath location = base::FilePath("/dev/null");
......
...@@ -22,10 +22,13 @@ class OzonePlatformTest : public OzonePlatform { ...@@ -22,10 +22,13 @@ class OzonePlatformTest : public OzonePlatform {
virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE; virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE;
virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE; virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE;
virtual ui::InputMethodContextFactoryOzone*
GetInputMethodContextFactoryOzone() OVERRIDE;
private: private:
gfx::FileSurfaceFactory surface_factory_ozone_; gfx::FileSurfaceFactory surface_factory_ozone_;
ui::EventFactoryEvdev event_factory_ozone_; ui::EventFactoryEvdev event_factory_ozone_;
ui::InputMethodContextFactoryOzone input_method_context_factory_ozone_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest);
}; };
......
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