Changes the text input type of Omnibox (Views) to TEXT_INPUT_TYPE_SEARCH.

If we specifies the text input type to TEXT_INPUT_TYPE_URL, MS-IME on Win8 metro thinks URL must be ASCII and always switches to Latin character mode (aka direct input mode) automatically, even if a user changed to non-Latin (e.g. Japanese) character mode last time.
This behavior is not good for those who use non-Latin characters in their daily life.

If we specifies the text input type to TEXT_INPUT_TYPE_SEARCH, MS-IME keeps the input mode specified last time.

The drawback of this CL is that MS-IME does not show '/' and '.com' keys on a software keyboard.  We think this change is worth making considering the number of users who use non-Latin characters and who use Latin characters on a software keyboard.

BUG=247994
TEST=Test manually.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223584 0039d316-1c4b-4281-b951-d872f2087c98
parent 6c050661
......@@ -50,6 +50,11 @@
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
#if defined(OS_WIN)
#include "base/win/metro.h"
#include "chrome/browser/browser_process.h"
#endif
#if defined(USE_AURA)
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
......@@ -81,6 +86,29 @@ OmniboxState::OmniboxState(const OmniboxEditModel::State& model_state,
OmniboxState::~OmniboxState() {}
// We'd like to set the text input type to TEXT_INPUT_TYPE_URL, because this
// triggers URL-specific layout in software keyboards, e.g. adding top-level "/"
// and ".com" keys for English. However, this also causes IMEs to default to
// Latin character mode, which makes entering search queries difficult for IME
// users. Therefore, we try to guess whether an IME will be used based on the
// application language, and set the input type accordingly.
ui::TextInputType DetermineTextInputType() {
#if defined(OS_WIN)
if (base::win::IsTSFAwareRequired()) {
DCHECK(g_browser_process);
const std::string& locale = g_browser_process->GetApplicationLocale();
const std::string& language = locale.substr(0, 2);
// Assume CJK + Thai users are using an IME.
if (language == "ja" ||
language == "ko" ||
language == "th" ||
language == "zh")
return ui::TEXT_INPUT_TYPE_SEARCH;
}
#endif
return ui::TEXT_INPUT_TYPE_URL;
}
bool IsOmniboxAutoCompletionForImeEnabled() {
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableOmniboxAutoCompletionForIme);
......@@ -130,7 +158,7 @@ OmniboxViewViews::~OmniboxViewViews() {
void OmniboxViewViews::Init() {
SetController(this);
SetTextInputType(ui::TEXT_INPUT_TYPE_URL);
SetTextInputType(DetermineTextInputType());
SetBackgroundColor(location_bar_view_->GetColor(
ToolbarModel::NONE, LocationBarView::BACKGROUND));
......
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