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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 23159008: Changes the Omnibox input type to SEARCH. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Synced. Created 7 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index dd689927690d195fd6470bb25b41875d56e3d403..f4a5c853ce56bd011b5200b54e73c5a1d83e00ba 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -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));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698