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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 10386173: ash: Select omnibox text on mouse up instead of down. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge and add test todo Created 8 years, 7 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 | Annotate | Revision Log
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/property_bag.h" 7 #include "base/property_bag.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE { 80 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE {
81 bool handled = views::Textfield::OnKeyPressed(event); 81 bool handled = views::Textfield::OnKeyPressed(event);
82 return omnibox_view_->HandleAfterKeyEvent(event, handled) || handled; 82 return omnibox_view_->HandleAfterKeyEvent(event, handled) || handled;
83 } 83 }
84 84
85 virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE { 85 virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE {
86 return omnibox_view_->HandleKeyReleaseEvent(event); 86 return omnibox_view_->HandleKeyReleaseEvent(event);
87 } 87 }
88 88
89 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE { 89 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
90 return omnibox_view_->HandleMousePressEvent(event); 90 // Pass through the views::Textfield's return value; we don't need to
91 // override its behavior.
92 bool result = views::Textfield::OnMousePressed(event);
93 omnibox_view_->HandleMousePressEvent(event);
94 return result;
95 }
96
97 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE {
98 bool result = views::Textfield::OnMouseDragged(event);
99 omnibox_view_->HandleMouseDragEvent(event);
100 return result;
101 }
102
103 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
104 views::Textfield::OnMouseReleased(event);
105 omnibox_view_->HandleMouseReleaseEvent(event);
91 } 106 }
92 107
93 private: 108 private:
94 OmniboxViewViews* omnibox_view_; 109 OmniboxViewViews* omnibox_view_;
95 110
96 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield); 111 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield);
97 }; 112 };
98 113
99 // Stores omnibox state for each tab. 114 // Stores omnibox state for each tab.
100 struct ViewState { 115 struct ViewState {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 LocationBarView* location_bar) 188 LocationBarView* location_bar)
174 : popup_window_mode_(popup_window_mode), 189 : popup_window_mode_(popup_window_mode),
175 model_(new AutocompleteEditModel(this, controller, profile)), 190 model_(new AutocompleteEditModel(this, controller, profile)),
176 controller_(controller), 191 controller_(controller),
177 toolbar_model_(toolbar_model), 192 toolbar_model_(toolbar_model),
178 command_updater_(command_updater), 193 command_updater_(command_updater),
179 security_level_(ToolbarModel::NONE), 194 security_level_(ToolbarModel::NONE),
180 ime_composing_before_change_(false), 195 ime_composing_before_change_(false),
181 delete_at_end_pressed_(false), 196 delete_at_end_pressed_(false),
182 location_bar_view_(location_bar), 197 location_bar_view_(location_bar),
183 ime_candidate_window_open_(false) { 198 ime_candidate_window_open_(false),
199 select_all_on_mouse_release_(false) {
184 } 200 }
185 201
186 OmniboxViewViews::~OmniboxViewViews() { 202 OmniboxViewViews::~OmniboxViewViews() {
187 #if defined(OS_CHROMEOS) 203 #if defined(OS_CHROMEOS)
188 chromeos::input_method::InputMethodManager::GetInstance()-> 204 chromeos::input_method::InputMethodManager::GetInstance()->
189 RemoveCandidateWindowObserver(this); 205 RemoveCandidateWindowObserver(this);
190 #endif 206 #endif
191 207
192 // Explicitly teardown members which have a reference to us. Just to be safe 208 // Explicitly teardown members which have a reference to us. Just to be safe
193 // we want them to be destroyed before destroying any other internal state. 209 // we want them to be destroyed before destroying any other internal state.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // the control-key state is changed. 314 // the control-key state is changed.
299 if (event.key_code() == ui::VKEY_CONTROL) { 315 if (event.key_code() == ui::VKEY_CONTROL) {
300 // TODO(oshima): investigate if we need to support keyboard with two 316 // TODO(oshima): investigate if we need to support keyboard with two
301 // controls. 317 // controls.
302 model_->OnControlKeyChanged(false); 318 model_->OnControlKeyChanged(false);
303 return true; 319 return true;
304 } 320 }
305 return false; 321 return false;
306 } 322 }
307 323
308 bool OmniboxViewViews::HandleMousePressEvent(const views::MouseEvent& event) { 324 void OmniboxViewViews::HandleMousePressEvent(const views::MouseEvent& event) {
309 if (!textfield_->HasFocus() && !textfield_->HasSelection()) { 325 select_all_on_mouse_release_ =
326 (event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
327 !textfield_->HasFocus();
328 }
329
330 void OmniboxViewViews::HandleMouseDragEvent(const views::MouseEvent& event) {
331 select_all_on_mouse_release_ = false;
332 }
333
334 void OmniboxViewViews::HandleMouseReleaseEvent(const views::MouseEvent& event) {
335 if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
336 select_all_on_mouse_release_) {
310 textfield_->SelectAll(); 337 textfield_->SelectAll();
311 textfield_->RequestFocus();
312 return true;
313 } 338 }
314 339 select_all_on_mouse_release_ = false;
315 return false;
316 } 340 }
317 341
318 void OmniboxViewViews::HandleFocusIn() { 342 void OmniboxViewViews::HandleFocusIn() {
319 // TODO(oshima): Get control key state. 343 // TODO(oshima): Get control key state.
320 model_->OnSetFocus(false); 344 model_->OnSetFocus(false);
321 // Don't call controller_->OnSetFocus as this view has already 345 // Don't call controller_->OnSetFocus as this view has already
322 // acquired the focus. 346 // acquired the focus.
323 } 347 }
324 348
325 void OmniboxViewViews::HandleFocusOut() { 349 void OmniboxViewViews::HandleFocusOut() {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, 892 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller,
869 toolbar_model, 893 toolbar_model,
870 profile, 894 profile,
871 command_updater, 895 command_updater,
872 popup_window_mode, 896 popup_window_mode,
873 location_bar); 897 location_bar);
874 omnibox_view->Init(); 898 omnibox_view->Init();
875 return omnibox_view; 899 return omnibox_view;
876 } 900 }
877 #endif 901 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | ui/views/controls/textfield/native_textfield_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698