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

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

Issue 8527015: Fix omnibox mouse click highlight/word select/focus issue in aura build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor change in comments. Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 10 matching lines...) Expand all
21 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
22 #include "ui/base/accessibility/accessible_view_state.h" 22 #include "ui/base/accessibility/accessible_view_state.h"
23 #include "ui/base/dragdrop/drag_drop_types.h" 23 #include "ui/base/dragdrop/drag_drop_types.h"
24 #include "ui/base/ime/text_input_type.h" 24 #include "ui/base/ime/text_input_type.h"
25 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/resource/resource_bundle.h" 26 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/gfx/font.h" 27 #include "ui/gfx/font.h"
28 #include "ui/gfx/render_text.h" 28 #include "ui/gfx/render_text.h"
29 #include "views/border.h" 29 #include "views/border.h"
30 #include "views/controls/textfield/textfield.h" 30 #include "views/controls/textfield/textfield.h"
31 #include "views/events/event.h"
31 #include "views/layout/fill_layout.h" 32 #include "views/layout/fill_layout.h"
32 33
33 #if defined(TOUCH_UI) 34 #if defined(TOUCH_UI)
34 #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents _view.h" 35 #include "chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents _view.h"
35 #else 36 #else
36 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h" 37 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view. h"
37 #endif 38 #endif
38 39
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" 41 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE { 73 virtual bool OnKeyReleased(const views::KeyEvent& event) OVERRIDE {
73 return omnibox_view_->HandleKeyReleaseEvent(event); 74 return omnibox_view_->HandleKeyReleaseEvent(event);
74 } 75 }
75 76
76 virtual bool IsFocusable() const OVERRIDE { 77 virtual bool IsFocusable() const OVERRIDE {
77 // Bypass Textfield::IsFocusable. The omnibox in popup window requires 78 // Bypass Textfield::IsFocusable. The omnibox in popup window requires
78 // focus in order for text selection to work. 79 // focus in order for text selection to work.
79 return views::View::IsFocusable(); 80 return views::View::IsFocusable();
80 } 81 }
81 82
83 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
84 return omnibox_view_->HandleMousePressEvent(event);
85 }
86
82 private: 87 private:
83 OmniboxViewViews* omnibox_view_; 88 OmniboxViewViews* omnibox_view_;
84 89
85 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield); 90 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield);
86 }; 91 };
87 92
88 // Stores omnibox state for each tab. 93 // Stores omnibox state for each tab.
89 struct ViewState { 94 struct ViewState {
90 explicit ViewState(const gfx::SelectionModel& selection_model) 95 explicit ViewState(const gfx::SelectionModel& selection_model)
91 : selection_model(selection_model) { 96 : selection_model(selection_model) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // the control-key state is changed. 264 // the control-key state is changed.
260 if (event.key_code() == ui::VKEY_CONTROL) { 265 if (event.key_code() == ui::VKEY_CONTROL) {
261 // TODO(oshima): investigate if we need to support keyboard with two 266 // TODO(oshima): investigate if we need to support keyboard with two
262 // controls. See omnibox_view_gtk.cc. 267 // controls. See omnibox_view_gtk.cc.
263 model_->OnControlKeyChanged(false); 268 model_->OnControlKeyChanged(false);
264 return true; 269 return true;
265 } 270 }
266 return false; 271 return false;
267 } 272 }
268 273
274 bool OmniboxViewViews::HandleMousePressEvent(const views::MouseEvent& event) {
275 if (!textfield_->HasFocus() && !textfield_->HasSelection()) {
oshima 2011/11/14 19:31:09 We may need to check if the textfield has IME comp
jennyz 2011/11/14 19:50:14 Done. Will do.
276 textfield_->SelectAll();
277 textfield_->RequestFocus();
278 return true;
279 }
280
281 return false;
282 }
283
269 void OmniboxViewViews::HandleFocusIn() { 284 void OmniboxViewViews::HandleFocusIn() {
270 // TODO(oshima): Get control key state. 285 // TODO(oshima): Get control key state.
271 model_->OnSetFocus(false); 286 model_->OnSetFocus(false);
272 // Don't call controller_->OnSetFocus as this view has already 287 // Don't call controller_->OnSetFocus as this view has already
273 // acquired the focus. 288 // acquired the focus.
274 } 289 }
275 290
276 void OmniboxViewViews::HandleFocusOut() { 291 void OmniboxViewViews::HandleFocusOut() {
277 // TODO(oshima): we don't have native view. This requires 292 // TODO(oshima): we don't have native view. This requires
278 // further refactoring. 293 // further refactoring.
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, 746 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller,
732 toolbar_model, 747 toolbar_model,
733 profile, 748 profile,
734 command_updater, 749 command_updater,
735 popup_window_mode, 750 popup_window_mode,
736 location_bar); 751 location_bar);
737 omnibox_view->Init(); 752 omnibox_view->Init();
738 return omnibox_view; 753 return omnibox_view;
739 } 754 }
740 #endif 755 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698