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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "ui/gfx/selection_model.h" 43 #include "ui/gfx/selection_model.h"
44 #include "ui/views/border.h" 44 #include "ui/views/border.h"
45 #include "ui/views/button_drag_utils.h" 45 #include "ui/views/button_drag_utils.h"
46 #include "ui/views/controls/textfield/textfield.h" 46 #include "ui/views/controls/textfield/textfield.h"
47 #include "ui/views/ime/input_method.h" 47 #include "ui/views/ime/input_method.h"
48 #include "ui/views/layout/fill_layout.h" 48 #include "ui/views/layout/fill_layout.h"
49 #include "ui/views/views_delegate.h" 49 #include "ui/views/views_delegate.h"
50 #include "ui/views/widget/widget.h" 50 #include "ui/views/widget/widget.h"
51 #include "url/gurl.h" 51 #include "url/gurl.h"
52 52
53 #if defined(OS_WIN)
54 #include "base/win/metro.h"
55 #include "chrome/browser/browser_process.h"
56 #endif
57
53 #if defined(USE_AURA) 58 #if defined(USE_AURA)
54 #include "ui/aura/focus_manager.h" 59 #include "ui/aura/focus_manager.h"
55 #include "ui/aura/root_window.h" 60 #include "ui/aura/root_window.h"
56 #include "ui/compositor/layer.h" 61 #include "ui/compositor/layer.h"
57 #endif 62 #endif
58 63
59 namespace { 64 namespace {
60 65
61 // Stores omnibox state for each tab. 66 // Stores omnibox state for each tab.
62 struct OmniboxState : public base::SupportsUserData::Data { 67 struct OmniboxState : public base::SupportsUserData::Data {
(...skipping 11 matching lines...) Expand all
74 const char OmniboxState::kKey[] = "OmniboxState"; 79 const char OmniboxState::kKey[] = "OmniboxState";
75 80
76 OmniboxState::OmniboxState(const OmniboxEditModel::State& model_state, 81 OmniboxState::OmniboxState(const OmniboxEditModel::State& model_state,
77 const gfx::SelectionModel& selection_model) 82 const gfx::SelectionModel& selection_model)
78 : model_state(model_state), 83 : model_state(model_state),
79 selection_model(selection_model) { 84 selection_model(selection_model) {
80 } 85 }
81 86
82 OmniboxState::~OmniboxState() {} 87 OmniboxState::~OmniboxState() {}
83 88
89 // We'd like to set the text input type to TEXT_INPUT_TYPE_URL, because this
90 // triggers URL-specific layout in software keyboards, e.g. adding top-level "/"
91 // and ".com" keys for English. However, this also causes IMEs to default to
92 // Latin character mode, which makes entering search queries difficult for IME
93 // users. Therefore, we try to guess whether an IME will be used based on the
94 // application language, and set the input type accordingly.
95 ui::TextInputType DetermineTextInputType() {
96 #if defined(OS_WIN)
97 if (base::win::IsTSFAwareRequired()) {
98 DCHECK(g_browser_process);
99 const std::string& locale = g_browser_process->GetApplicationLocale();
100 const std::string& language = locale.substr(0, 2);
101 // Assume CJK + Thai users are using an IME.
102 if (language == "ja" ||
103 language == "ko" ||
104 language == "th" ||
105 language == "zh")
106 return ui::TEXT_INPUT_TYPE_SEARCH;
107 }
108 #endif
109 return ui::TEXT_INPUT_TYPE_URL;
110 }
111
84 bool IsOmniboxAutoCompletionForImeEnabled() { 112 bool IsOmniboxAutoCompletionForImeEnabled() {
85 return !CommandLine::ForCurrentProcess()->HasSwitch( 113 return !CommandLine::ForCurrentProcess()->HasSwitch(
86 switches::kDisableOmniboxAutoCompletionForIme); 114 switches::kDisableOmniboxAutoCompletionForIme);
87 } 115 }
88 116
89 } // namespace 117 } // namespace
90 118
91 // static 119 // static
92 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; 120 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews";
93 121
(...skipping 29 matching lines...) Expand all
123 // Explicitly teardown members which have a reference to us. Just to be safe 151 // Explicitly teardown members which have a reference to us. Just to be safe
124 // we want them to be destroyed before destroying any other internal state. 152 // we want them to be destroyed before destroying any other internal state.
125 popup_view_.reset(); 153 popup_view_.reset();
126 } 154 }
127 155
128 //////////////////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////////////////
129 // OmniboxViewViews public: 157 // OmniboxViewViews public:
130 158
131 void OmniboxViewViews::Init() { 159 void OmniboxViewViews::Init() {
132 SetController(this); 160 SetController(this);
133 SetTextInputType(ui::TEXT_INPUT_TYPE_URL); 161 SetTextInputType(DetermineTextInputType());
134 SetBackgroundColor(location_bar_view_->GetColor( 162 SetBackgroundColor(location_bar_view_->GetColor(
135 ToolbarModel::NONE, LocationBarView::BACKGROUND)); 163 ToolbarModel::NONE, LocationBarView::BACKGROUND));
136 164
137 if (popup_window_mode_) 165 if (popup_window_mode_)
138 SetReadOnly(true); 166 SetReadOnly(true);
139 167
140 // Initialize the popup view using the same font. 168 // Initialize the popup view using the same font.
141 popup_view_.reset(OmniboxPopupContentsView::Create( 169 popup_view_.reset(OmniboxPopupContentsView::Create(
142 font_list(), this, model(), location_bar_view_)); 170 font_list(), this, model(), location_bar_view_));
143 171
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 const string16 text(GetClipboardText()); 920 const string16 text(GetClipboardText());
893 if (!text.empty()) { 921 if (!text.empty()) {
894 // Record this paste, so we can do different behavior. 922 // Record this paste, so we can do different behavior.
895 model()->on_paste(); 923 model()->on_paste();
896 // Force a Paste operation to trigger the text_changed code in 924 // Force a Paste operation to trigger the text_changed code in
897 // OnAfterPossibleChange(), even if identical contents are pasted. 925 // OnAfterPossibleChange(), even if identical contents are pasted.
898 text_before_change_.clear(); 926 text_before_change_.clear();
899 InsertOrReplaceText(text); 927 InsertOrReplaceText(text);
900 } 928 }
901 } 929 }
OLDNEW
« 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