Commit b2124e11 authored by nona@chromium.org's avatar nona@chromium.org

Add private API to notify end of initialization.

To be able to use input method just after log-in, we should notify the end of
ime initialization to input method engine, otherwise onActivate event will be
missed.

The right way to fix this issue is migrating packaged app and working with lazy 
background page, but it requires much effort both for chrome and extension side
so and hard to merge to M28. So please let me add this temporary hack.

BUG=242864
TEST=Manually checked on link

Review URL: https://chromiumcodereview.appspot.com/15912004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202842 0039d316-1c4b-4281-b951-d872f2087c98
parent 2ddff0b2
......@@ -7,6 +7,7 @@
#include "base/lazy_instance.h"
#include "base/values.h"
#include "chrome/browser/chromeos/extensions/input_method_event_router.h"
#include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/extension_function_registry.h"
#include "chrome/browser/extensions/extension_system.h"
......@@ -42,6 +43,25 @@ bool GetInputMethodFunction::RunImpl() {
#endif
}
StartImeFunction::StartImeFunction() {
}
StartImeFunction::~StartImeFunction() {
}
bool StartImeFunction::RunImpl() {
#if !defined(OS_CHROMEOS)
NOTREACHED();
return false;
#else
chromeos::InputMethodEngine* engine =
InputImeEventRouter::GetInstance()->GetActiveEngine(extension_id());
if (engine)
engine->StartIme();
return true;
#endif
}
InputMethodAPI::InputMethodAPI(Profile* profile)
: profile_(profile) {
ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
......@@ -49,6 +69,7 @@ InputMethodAPI::InputMethodAPI(Profile* profile)
ExtensionFunctionRegistry* registry =
ExtensionFunctionRegistry::GetInstance();
registry->RegisterFunction<GetInputMethodFunction>();
registry->RegisterFunction<StartImeFunction>();
}
InputMethodAPI::~InputMethodAPI() {
......
......@@ -31,6 +31,22 @@ class GetInputMethodFunction : public SyncExtensionFunction {
DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.get", INPUTMETHODPRIVATE_GET)
};
// Notify the initialization is done to input method engine.
// TODO(nona): remove this function.
class StartImeFunction : public SyncExtensionFunction {
public:
StartImeFunction();
protected:
virtual ~StartImeFunction();
virtual bool RunImpl() OVERRIDE;
private:
DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.startIme",
INPUTMETHODPRIVATE_STARTIME)
};
class InputMethodAPI : public ProfileKeyedAPI,
public extensions::EventRouter::Observer {
public:
......
......@@ -153,6 +153,11 @@ class InputMethodEngine {
virtual ~InputMethodEngine() {}
// Called when the input metho initialization is done.
// This function is called from private API.
// TODO(nona): Remove this function.
virtual void StartIme() = 0;
// Set the current composition and associated properties.
virtual bool SetComposition(int context_id,
const char* text,
......
......@@ -118,6 +118,13 @@ void InputMethodEngineIBus::Initialize(
RegisterComponent();
}
void InputMethodEngineIBus::StartIme() {
input_method::InputMethodManager* manager =
input_method::InputMethodManager::Get();
if (manager && ibus_id_ == manager->GetCurrentInputMethod().id())
Enable();
}
bool InputMethodEngineIBus::SetComposition(
int context_id,
const char* text,
......
......@@ -43,6 +43,7 @@ class InputMethodEngineIBus : public InputMethodEngine,
std::string* error);
// InputMethodEngine overrides.
virtual void StartIme() OVERRIDE;
virtual bool SetComposition(int context_id,
const char* text,
int selection_start,
......
......@@ -536,6 +536,7 @@ enum HistogramValue {
FILESYSTEM_ISRESTORABLE,
FILESYSTEM_RESTOREENTRY,
RUNTIME_SETUNINSTALLURL,
INPUTMETHODPRIVATE_STARTIME,
ENUM_BOUNDARY // Last entry: Add new entries above.
};
......
......@@ -262,7 +262,8 @@
"gnedhmakppccajfpfiihfcdlnpgomkcf", // Citrix Receiver Beta
"fjcibdnjlbfnbfdjneajpipnlcppleek", // Citrix Receiver Dev
"pnhechapfaindjhompbnflcldabbghjo", // HTerm
"okddffdblfhhnmhodogpojmfkjmhinfp" // HTerm dev
"okddffdblfhhnmhodogpojmfkjmhinfp", // HTerm dev
"fpfbhcjppmaeaijcidgiibchfbnhbelj" // Google Japanese Input
]
},
"location": [
......
......@@ -28,6 +28,11 @@
]
}
]
}, {
"name": "startIme",
"type": "function",
"description": "Notify to input method engine to be ready to accept events.",
"parameters" : []
}
],
"events": [
......
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