Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: ui/base/ime/win/tsf_input_scope.cc

Issue 21157006: change tsf_input_scopes::SetInputScopeForTsfUnawareWindow to SetInputScopesForTsfUnawareWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename args Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/base/ime/win/tsf_input_scope.h ('K') | « ui/base/ime/win/tsf_input_scope.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/ime/win/tsf_input_scope.cc
diff --git a/ui/base/ime/win/tsf_input_scope.cc b/ui/base/ime/win/tsf_input_scope.cc
index dac701b0a8b85e41694515b1a90ec0affc81653f..fb6bbdd9b03001fff43a382c80977924972d9f29 100644
--- a/ui/base/ime/win/tsf_input_scope.cc
+++ b/ui/base/ime/win/tsf_input_scope.cc
@@ -87,16 +87,13 @@ class TSFInputScope : public ITfInputScope {
DISALLOW_COPY_AND_ASSIGN(TSFInputScope);
};
-typedef HRESULT (WINAPI *SetInputScopeFunc)(HWND window_handle,
- InputScope input_scope);
-
-SetInputScopeFunc g_set_input_scope = NULL;
-bool g_get_proc_done = false;
-
-SetInputScopeFunc GetSetInputScope() {
+template <typename Proc>
+Proc GetTSFProcedure(const char* procedure_name) {
+ static Proc procedure = NULL;
+ static bool get_proc_done = false;
// Thread safety is not required.
Seigo Nonaka 2013/07/31 13:23:09 Sorry this is not introduced by this CL but please
yoichio 2013/08/01 10:29:22 Done.
Seigo Nonaka 2013/08/01 17:07:59 Sorry for confusing you. I'd not like to say makin
- if (!g_get_proc_done) {
- g_get_proc_done = true;
+ if (!get_proc_done) {
+ get_proc_done = true;
// For stability reasons, we do not support Windows XP.
if (base::win::GetVersion() < base::win::VERSION_VISTA)
@@ -107,13 +104,16 @@ SetInputScopeFunc GetSetInputScope() {
&module)) {
return NULL;
}
- g_set_input_scope = reinterpret_cast<SetInputScopeFunc>(
- GetProcAddress(module, "SetInputScope"));
+
+ procedure = reinterpret_cast<Proc>(GetProcAddress(module, procedure_name));
}
- return g_set_input_scope;
+ return procedure;
}
-InputScope GetInputScopeType(TextInputType text_input_type) {
+typedef HRESULT (WINAPI *SetInputScopeFunc)(HWND window_handle,
Seigo Nonaka 2013/07/31 13:23:09 Can we use SetInputScopesFunc for both case?
yoichio 2013/08/01 10:29:22 I think yes and manually tested.
+ InputScope input_scope);
+
+InputScope ConvertTextInputTypeToInputScope(TextInputType text_input_type) {
// Following mapping is based in IE10 on Windows 8.
switch (text_input_type) {
case TEXT_INPUT_TYPE_PASSWORD:
@@ -133,17 +133,71 @@ InputScope GetInputScopeType(TextInputType text_input_type) {
}
}
+typedef HRESULT (WINAPI *SetInputScopesFunc)(HWND window_handle,
+ const InputScope* input_scope_list,
+ UINT num_input_scopes,
+ WCHAR** phrase_list,
+ UINT num_phrases,
+ WCHAR* regular_expression,
+ WCHAR* speech_recognition_hints);
+
+InputScope ConvertTextInputModeToInputScope(TextInputMode text_input_mode) {
+ switch (text_input_mode) {
+ case TEXT_INPUT_MODE_VERBATIM:
+ case TEXT_INPUT_MODE_LATIN:
+ case TEXT_INPUT_MODE_LATIN_NAME:
+ case TEXT_INPUT_MODE_LATIN_PROSE:
+ return IS_ALPHANUMERIC_HALFWIDTH;
+ case TEXT_INPUT_MODE_FULL_WIDTH_LATIN:
+ return IS_ALPHANUMERIC_FULLWIDTH;
+ case TEXT_INPUT_MODE_KANA:
+ return IS_HIRAGANA;
+ case TEXT_INPUT_MODE_KATAKANA:
+ return IS_KATAKANA_FULLWIDTH;
+ case TEXT_INPUT_MODE_NUMERIC:
+ return IS_NUMBER;
+ case TEXT_INPUT_MODE_TEL:
+ return IS_TELEPHONE_FULLTELEPHONENUMBER;
+ case TEXT_INPUT_MODE_EMAIL:
+ return IS_EMAIL_SMTPEMAILADDRESS;
+ case TEXT_INPUT_MODE_URL:
+ return IS_URL;
+ default:
+ return IS_DEFAULT;
+ }
+}
+
} // namespace
ITfInputScope* CreateInputScope(TextInputType text_input_type) {
- return new TSFInputScope(GetInputScopeType(text_input_type));
+ return new TSFInputScope(ConvertTextInputTypeToInputScope(text_input_type));
}
void SetInputScopeForTsfUnawareWindow(HWND window_handle,
TextInputType text_input_type) {
- SetInputScopeFunc set_input_scope = GetSetInputScope();
+ SetInputScopeFunc set_input_scope =
+ GetTSFProcedure<SetInputScopeFunc>("SetInputScope");
if (set_input_scope)
- set_input_scope(window_handle, GetInputScopeType(text_input_type));
+ set_input_scope(window_handle,
+ ConvertTextInputTypeToInputScope(text_input_type));
+}
+
+void SetInputScopesForTsfUnawareWindow(
+ HWND window_handle,
+ TextInputType text_input_type,
+ TextInputMode text_input_mode) {
+ SetInputScopesFunc set_input_scopes =
+ GetTSFProcedure<SetInputScopesFunc>("SetInputScopes");
+ if (set_input_scopes) {
Seigo Nonaka 2013/07/31 13:23:09 nit: I prefer early exit, but up to you.
yoichio 2013/08/01 10:29:22 Done.
+ InputScope input_scopes[] = {
+ ConvertTextInputTypeToInputScope(text_input_type),
+ ConvertTextInputModeToInputScope(text_input_mode),
+ };
+
+ set_input_scopes(window_handle, input_scopes,
+ (input_scopes[0] == input_scopes[1] ? 1 : 2), NULL, 0,
+ NULL, NULL);
+ }
}
} // namespace tsf_inputscope
« ui/base/ime/win/tsf_input_scope.h ('K') | « ui/base/ime/win/tsf_input_scope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698