diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-04 16:02:57 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-04 16:02:57 +0000 |
commit | 623cf237bdec149da1c23514c09a397d995cbe38 (patch) | |
tree | 68aaac787b50d33471a001cc7994d3dc74d3d30e | |
parent | dc36b97432b6e465c7f1885625347c3854cfeb64 (diff) | |
download | chromium_src-623cf237bdec149da1c23514c09a397d995cbe38.zip chromium_src-623cf237bdec149da1c23514c09a397d995cbe38.tar.gz chromium_src-623cf237bdec149da1c23514c09a397d995cbe38.tar.bz2 |
Merge 202842 "Add private API to notify end of initialization."
> 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
TBR=nona@chromium.org
Review URL: https://codereview.chromium.org/16356008
git-svn-id: svn://svn.chromium.org/chrome/branches/1500/src@203973 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 58 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/extensions/input_method_api.cc b/chrome/browser/chromeos/extensions/input_method_api.cc index 58f4243..a8bc194 100644 --- a/chrome/browser/chromeos/extensions/input_method_api.cc +++ b/chrome/browser/chromeos/extensions/input_method_api.cc @@ -8,11 +8,11 @@ #include "base/values.h" #include "chrome/browser/chromeos/extensions/input_method_event_router.h" #include "chrome/browser/chromeos/input_method/input_method_configuration.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" #include "chrome/browser/profiles/profile.h" -#include "chromeos/ime/input_method_manager.h" namespace { @@ -43,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( @@ -50,6 +69,7 @@ InputMethodAPI::InputMethodAPI(Profile* profile) ExtensionFunctionRegistry* registry = ExtensionFunctionRegistry::GetInstance(); registry->RegisterFunction<GetInputMethodFunction>(); + registry->RegisterFunction<StartImeFunction>(); } InputMethodAPI::~InputMethodAPI() { diff --git a/chrome/browser/chromeos/extensions/input_method_api.h b/chrome/browser/chromeos/extensions/input_method_api.h index 15fd92e..d0a78a0 100644 --- a/chrome/browser/chromeos/extensions/input_method_api.h +++ b/chrome/browser/chromeos/extensions/input_method_api.h @@ -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: diff --git a/chrome/browser/chromeos/input_method/input_method_engine.h b/chrome/browser/chromeos/input_method/input_method_engine.h index e9cd25c..ab7ccb5 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine.h +++ b/chrome/browser/chromeos/input_method/input_method_engine.h @@ -147,6 +147,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, diff --git a/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc b/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc index fafe49f..028a57d 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc +++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.cc @@ -117,6 +117,13 @@ void InputMethodEngineIBus::Initialize( RegisterComponent(); } +void InputMethodEngineIBus::StartIme() { + input_method::InputMethodManager* manager = + input_method::GetInputMethodManager(); + if (manager && ibus_id_ == manager->GetCurrentInputMethod().id()) + Enable(); +} + bool InputMethodEngineIBus::SetComposition( int context_id, const char* text, diff --git a/chrome/browser/chromeos/input_method/input_method_engine_ibus.h b/chrome/browser/chromeos/input_method/input_method_engine_ibus.h index 1711460..d3b2b86 100644 --- a/chrome/browser/chromeos/input_method/input_method_engine_ibus.h +++ b/chrome/browser/chromeos/input_method/input_method_engine_ibus.h @@ -42,6 +42,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, diff --git a/chrome/browser/extensions/extension_function_histogram_value.h b/chrome/browser/extensions/extension_function_histogram_value.h index 61eb3ad..f1c7ad9 100644 --- a/chrome/browser/extensions/extension_function_histogram_value.h +++ b/chrome/browser/extensions/extension_function_histogram_value.h @@ -526,6 +526,7 @@ enum HistogramValue { SOCKET_MULTICAST_SET_LOOPBACK_MODE, SOCKET_MULTICAST_GET_JOINED_GROUPS, EXPERIMENTAL_ACCESSIBILITY_SETNATIVEACCESSIBILITYENABLED, + INPUTMETHODPRIVATE_STARTIME, ENUM_BOUNDARY // Last entry: Add new entries above. }; diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json index 6931efa..d29116b 100644 --- a/chrome/common/extensions/api/_permission_features.json +++ b/chrome/common/extensions/api/_permission_features.json @@ -239,7 +239,8 @@ "gnedhmakppccajfpfiihfcdlnpgomkcf", // Citrix Receiver Beta "fjcibdnjlbfnbfdjneajpipnlcppleek", // Citrix Receiver Dev "pnhechapfaindjhompbnflcldabbghjo", // HTerm - "okddffdblfhhnmhodogpojmfkjmhinfp" // HTerm dev + "okddffdblfhhnmhodogpojmfkjmhinfp", // HTerm dev + "fpfbhcjppmaeaijcidgiibchfbnhbelj" // Google Japanese Input ] }, "location": [ diff --git a/chrome/common/extensions/api/input_method_private.json b/chrome/common/extensions/api/input_method_private.json index 6c44192..d49c099 100644 --- a/chrome/common/extensions/api/input_method_private.json +++ b/chrome/common/extensions/api/input_method_private.json @@ -28,6 +28,11 @@ ] } ] + }, { + "name": "startIme", + "type": "function", + "description": "Notify to input method engine to be ready to accept events.", + "parameters" : [] } ], "events": [ |