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

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

Issue 12090098: Tapping on omnibox should select all text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | 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/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 bool result = views::Textfield::OnMouseDragged(event); 185 bool result = views::Textfield::OnMouseDragged(event);
186 omnibox_view_->HandleMouseDragEvent(event); 186 omnibox_view_->HandleMouseDragEvent(event);
187 return result; 187 return result;
188 } 188 }
189 189
190 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { 190 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE {
191 views::Textfield::OnMouseReleased(event); 191 views::Textfield::OnMouseReleased(event);
192 omnibox_view_->HandleMouseReleaseEvent(event); 192 omnibox_view_->HandleMouseReleaseEvent(event);
193 } 193 }
194 194
195 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
196 views::Textfield::OnGestureEvent(event);
197 omnibox_view_->HandleGestureEvent(*event);
198 }
199
195 private: 200 private:
196 OmniboxViewViews* omnibox_view_; 201 OmniboxViewViews* omnibox_view_;
197 LocationBarView* location_bar_view_; 202 LocationBarView* location_bar_view_;
198 203
199 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield); 204 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield);
200 }; 205 };
201 206
202 // static 207 // static
203 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews"; 208 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews";
204 209
205 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, 210 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
206 ToolbarModel* toolbar_model, 211 ToolbarModel* toolbar_model,
207 Profile* profile, 212 Profile* profile,
208 CommandUpdater* command_updater, 213 CommandUpdater* command_updater,
209 bool popup_window_mode, 214 bool popup_window_mode,
210 LocationBarView* location_bar) 215 LocationBarView* location_bar)
211 : OmniboxView(profile, controller, toolbar_model, command_updater), 216 : OmniboxView(profile, controller, toolbar_model, command_updater),
212 textfield_(NULL), 217 textfield_(NULL),
213 popup_window_mode_(popup_window_mode), 218 popup_window_mode_(popup_window_mode),
214 security_level_(ToolbarModel::NONE), 219 security_level_(ToolbarModel::NONE),
215 ime_composing_before_change_(false), 220 ime_composing_before_change_(false),
216 delete_at_end_pressed_(false), 221 delete_at_end_pressed_(false),
217 location_bar_view_(location_bar), 222 location_bar_view_(location_bar),
218 ime_candidate_window_open_(false), 223 ime_candidate_window_open_(false),
219 select_all_on_mouse_release_(false) { 224 select_all_on_mouse_release_(false),
225 select_all_on_gesture_tap_(false) {
220 } 226 }
221 227
222 OmniboxViewViews::~OmniboxViewViews() { 228 OmniboxViewViews::~OmniboxViewViews() {
223 #if defined(OS_CHROMEOS) 229 #if defined(OS_CHROMEOS)
224 chromeos::input_method::GetInputMethodManager()-> 230 chromeos::input_method::GetInputMethodManager()->
225 RemoveCandidateWindowObserver(this); 231 RemoveCandidateWindowObserver(this);
226 #endif 232 #endif
227 233
228 // Explicitly teardown members which have a reference to us. Just to be safe 234 // Explicitly teardown members which have a reference to us. Just to be safe
229 // we want them to be destroyed before destroying any other internal state. 235 // we want them to be destroyed before destroying any other internal state.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void OmniboxViewViews::HandleMouseReleaseEvent(const ui::MouseEvent& event) { 382 void OmniboxViewViews::HandleMouseReleaseEvent(const ui::MouseEvent& event) {
377 if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) && 383 if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
378 select_all_on_mouse_release_) { 384 select_all_on_mouse_release_) {
379 // Select all in the reverse direction so as not to scroll the caret 385 // Select all in the reverse direction so as not to scroll the caret
380 // into view and shift the contents jarringly. 386 // into view and shift the contents jarringly.
381 SelectAll(true); 387 SelectAll(true);
382 } 388 }
383 select_all_on_mouse_release_ = false; 389 select_all_on_mouse_release_ = false;
384 } 390 }
385 391
392 void OmniboxViewViews::HandleGestureEvent(const ui::GestureEvent& event) {
393 if (!textfield_->HasFocus() && event.type() == ui::ET_GESTURE_TAP_DOWN) {
394 select_all_on_gesture_tap_ = true;
395 return;
396 }
397 if (select_all_on_gesture_tap_ && event.type() == ui::ET_GESTURE_TAP)
398 SelectAll(false);
399 select_all_on_gesture_tap_ = false;
400 }
401
386 void OmniboxViewViews::HandleFocusIn() { 402 void OmniboxViewViews::HandleFocusIn() {
387 // TODO(oshima): Get control key state. 403 // TODO(oshima): Get control key state.
388 model()->OnSetFocus(false); 404 model()->OnSetFocus(false);
389 // Don't call controller()->OnSetFocus as this view has already 405 // Don't call controller()->OnSetFocus as this view has already
390 // acquired the focus. 406 // acquired the focus.
391 } 407 }
392 408
393 void OmniboxViewViews::HandleFocusOut() { 409 void OmniboxViewViews::HandleFocusOut() {
394 gfx::NativeView native_view = NULL; 410 gfx::NativeView native_view = NULL;
395 #if defined(USE_AURA) 411 #if defined(USE_AURA)
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 if (!text.empty()) { 977 if (!text.empty()) {
962 // Record this paste, so we can do different behavior. 978 // Record this paste, so we can do different behavior.
963 model()->on_paste(); 979 model()->on_paste();
964 // Force a Paste operation to trigger the text_changed code in 980 // Force a Paste operation to trigger the text_changed code in
965 // OnAfterPossibleChange(), even if identical contents are pasted into the 981 // OnAfterPossibleChange(), even if identical contents are pasted into the
966 // text box. 982 // text box.
967 text_before_change_.clear(); 983 text_before_change_.clear();
968 textfield_->ReplaceSelection(text); 984 textfield_->ReplaceSelection(text);
969 } 985 }
970 } 986 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698