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

Side by Side Diff: chrome/browser/ui/views/find_bar_host.cc

Issue 6034002: Replace Textfield::Keystroke with views::KeyEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: key_code, ET_KEY_PRESS for WM_CHAR Created 9 years, 11 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/find_bar_host.h ('k') | chrome/browser/ui/views/find_bar_host_gtk.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/find_bar_host.h" 5 #include "chrome/browser/views/find_bar_host.h"
6 6
7 #include "app/keyboard_codes.h" 7 #include "app/keyboard_codes.h"
8 #include "chrome/browser/renderer_host/render_view_host.h" 8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/tab_contents/tab_contents.h" 9 #include "chrome/browser/tab_contents/tab_contents.h"
10 #include "chrome/browser/tab_contents/tab_contents_view.h" 10 #include "chrome/browser/tab_contents/tab_contents_view.h"
(...skipping 21 matching lines...) Expand all
32 32
33 FindBarHost::FindBarHost(BrowserView* browser_view) 33 FindBarHost::FindBarHost(BrowserView* browser_view)
34 : DropdownBarHost(browser_view), 34 : DropdownBarHost(browser_view),
35 find_bar_controller_(NULL) { 35 find_bar_controller_(NULL) {
36 Init(new FindBarView(this)); 36 Init(new FindBarView(this));
37 } 37 }
38 38
39 FindBarHost::~FindBarHost() { 39 FindBarHost::~FindBarHost() {
40 } 40 }
41 41
42 bool FindBarHost::MaybeForwardKeystrokeToWebpage( 42 bool FindBarHost::MaybeForwardKeyEventToWebpage(
43 const views::Textfield::Keystroke& key_stroke) { 43 const views::KeyEvent& key_event) {
44 if (!ShouldForwardKeystrokeToWebpageNative(key_stroke)) { 44 if (!ShouldForwardKeyEventToWebpageNative(key_event)) {
45 // Native implementation says not to forward these events. 45 // Native implementation says not to forward these events.
46 return false; 46 return false;
47 } 47 }
48 48
49 switch (key_stroke.GetKeyboardCode()) { 49 switch (key_event.GetKeyCode()) {
50 case app::VKEY_DOWN: 50 case app::VKEY_DOWN:
51 case app::VKEY_UP: 51 case app::VKEY_UP:
52 case app::VKEY_PRIOR: 52 case app::VKEY_PRIOR:
53 case app::VKEY_NEXT: 53 case app::VKEY_NEXT:
54 break; 54 break;
55 case app::VKEY_HOME: 55 case app::VKEY_HOME:
56 case app::VKEY_END: 56 case app::VKEY_END:
57 if (key_stroke.IsControlHeld()) 57 if (key_event.IsControlDown())
58 break; 58 break;
59 // Fall through. 59 // Fall through.
60 default: 60 default:
61 return false; 61 return false;
62 } 62 }
63 63
64 TabContents* contents = find_bar_controller_->tab_contents(); 64 TabContents* contents = find_bar_controller_->tab_contents();
65 if (!contents) 65 if (!contents)
66 return false; 66 return false;
67 67
68 RenderViewHost* render_view_host = contents->render_view_host(); 68 RenderViewHost* render_view_host = contents->render_view_host();
69 69
70 // Make sure we don't have a text field element interfering with keyboard 70 // Make sure we don't have a text field element interfering with keyboard
71 // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom". 71 // input. Otherwise Up and Down arrow key strokes get eaten. "Nom Nom Nom".
72 render_view_host->ClearFocusedNode(); 72 render_view_host->ClearFocusedNode();
73 NativeWebKeyboardEvent event = GetKeyboardEvent(contents, key_stroke); 73 NativeWebKeyboardEvent event = GetKeyboardEvent(contents, key_event);
74 render_view_host->ForwardKeyboardEvent(event); 74 render_view_host->ForwardKeyboardEvent(event);
75 return true; 75 return true;
76 } 76 }
77 77
78 FindBarController* FindBarHost::GetFindBarController() const { 78 FindBarController* FindBarHost::GetFindBarController() const {
79 return find_bar_controller_; 79 return find_bar_controller_;
80 } 80 }
81 81
82 void FindBarHost::SetFindBarController(FindBarController* find_bar_controller) { 82 void FindBarHost::SetFindBarController(FindBarController* find_bar_controller) {
83 find_bar_controller_ = find_bar_controller; 83 find_bar_controller_ = find_bar_controller;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 DropdownBarHost::UnregisterAccelerators(); 300 DropdownBarHost::UnregisterAccelerators();
301 } 301 }
302 302
303 //////////////////////////////////////////////////////////////////////////////// 303 ////////////////////////////////////////////////////////////////////////////////
304 // private: 304 // private:
305 305
306 FindBarView* FindBarHost::find_bar_view() { 306 FindBarView* FindBarHost::find_bar_view() {
307 return static_cast<FindBarView*>(view()); 307 return static_cast<FindBarView*>(view());
308 } 308 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_host.h ('k') | chrome/browser/ui/views/find_bar_host_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698