OLD | NEW |
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 "base/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/find_bar_controller.h" | 10 #include "chrome/browser/find_bar_controller.h" |
11 #include "chrome/browser/renderer_host/render_view_host.h" | 11 #include "chrome/browser/renderer_host/render_view_host.h" |
12 #include "chrome/browser/view_ids.h" | 12 #include "chrome/browser/view_ids.h" |
13 #include "chrome/browser/views/find_bar_view.h" | 13 #include "chrome/browser/views/find_bar_view.h" |
14 #include "chrome/browser/views/frame/browser_view.h" | 14 #include "chrome/browser/views/frame/browser_view.h" |
15 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
16 #include "chrome/browser/tab_contents/tab_contents_view.h" | 16 #include "chrome/browser/tab_contents/tab_contents_view.h" |
17 #include "views/focus/external_focus_tracker.h" | 17 #include "views/focus/external_focus_tracker.h" |
(...skipping 23 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 bool FindBarHost::MaybeForwardKeystrokeToWebpage( | 43 bool FindBarHost::MaybeForwardKeystrokeToWebpage( |
44 const views::Textfield::Keystroke& key_stroke) { | 44 const views::Textfield::Keystroke& key_stroke) { |
45 if (!ShouldForwardKeystrokeToWebpageNative(key_stroke)) { | 45 if (!ShouldForwardKeystrokeToWebpageNative(key_stroke)) { |
46 // Native implementation says not to forward these events. | 46 // Native implementation says not to forward these events. |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 switch (key_stroke.GetKeyboardCode()) { | 50 switch (key_stroke.GetKeyboardCode()) { |
51 case base::VKEY_DOWN: | 51 case app::VKEY_DOWN: |
52 case base::VKEY_UP: | 52 case app::VKEY_UP: |
53 case base::VKEY_PRIOR: | 53 case app::VKEY_PRIOR: |
54 case base::VKEY_NEXT: | 54 case app::VKEY_NEXT: |
55 break; | 55 break; |
56 case base::VKEY_HOME: | 56 case app::VKEY_HOME: |
57 case base::VKEY_END: | 57 case app::VKEY_END: |
58 if (key_stroke.IsControlHeld()) | 58 if (key_stroke.IsControlHeld()) |
59 break; | 59 break; |
60 // Fall through. | 60 // Fall through. |
61 default: | 61 default: |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 TabContents* contents = find_bar_controller_->tab_contents(); | 65 TabContents* contents = find_bar_controller_->tab_contents(); |
66 if (!contents) | 66 if (!contents) |
67 return false; | 67 return false; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 | 155 |
156 FindBarTesting* FindBarHost::GetFindBarTesting() { | 156 FindBarTesting* FindBarHost::GetFindBarTesting() { |
157 return this; | 157 return this; |
158 } | 158 } |
159 | 159 |
160 //////////////////////////////////////////////////////////////////////////////// | 160 //////////////////////////////////////////////////////////////////////////////// |
161 // FindBarWin, views::AcceleratorTarget implementation: | 161 // FindBarWin, views::AcceleratorTarget implementation: |
162 | 162 |
163 bool FindBarHost::AcceleratorPressed(const views::Accelerator& accelerator) { | 163 bool FindBarHost::AcceleratorPressed(const views::Accelerator& accelerator) { |
164 base::KeyboardCode key = accelerator.GetKeyCode(); | 164 app::KeyboardCode key = accelerator.GetKeyCode(); |
165 if (key == base::VKEY_RETURN && accelerator.IsCtrlDown()) { | 165 if (key == app::VKEY_RETURN && accelerator.IsCtrlDown()) { |
166 // Ctrl+Enter closes the Find session and navigates any link that is active. | 166 // Ctrl+Enter closes the Find session and navigates any link that is active. |
167 find_bar_controller_->EndFindSession(FindBarController::kActivateSelection); | 167 find_bar_controller_->EndFindSession(FindBarController::kActivateSelection); |
168 } else if (key == base::VKEY_ESCAPE) { | 168 } else if (key == app::VKEY_ESCAPE) { |
169 // This will end the Find session and hide the window, causing it to loose | 169 // This will end the Find session and hide the window, causing it to loose |
170 // focus and in the process unregister us as the handler for the Escape | 170 // focus and in the process unregister us as the handler for the Escape |
171 // accelerator through the FocusWillChange event. | 171 // accelerator through the FocusWillChange event. |
172 find_bar_controller_->EndFindSession(FindBarController::kKeepSelection); | 172 find_bar_controller_->EndFindSession(FindBarController::kKeepSelection); |
173 } else { | 173 } else { |
174 NOTREACHED() << "Unknown accelerator"; | 174 NOTREACHED() << "Unknown accelerator"; |
175 } | 175 } |
176 | 176 |
177 return true; | 177 return true; |
178 } | 178 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 DCHECK(bounds); | 270 DCHECK(bounds); |
271 // The BrowserView does Layout for the components that we care about | 271 // The BrowserView does Layout for the components that we care about |
272 // positioning relative to, so we ask it to tell us where we should go. | 272 // positioning relative to, so we ask it to tell us where we should go. |
273 *bounds = browser_view()->GetFindBarBoundingBox(); | 273 *bounds = browser_view()->GetFindBarBoundingBox(); |
274 } | 274 } |
275 | 275 |
276 void FindBarHost::RegisterAccelerators() { | 276 void FindBarHost::RegisterAccelerators() { |
277 DropdownBarHost::RegisterAccelerators(); | 277 DropdownBarHost::RegisterAccelerators(); |
278 | 278 |
279 // Register for Ctrl+Return. | 279 // Register for Ctrl+Return. |
280 views::Accelerator escape(base::VKEY_RETURN, false, true, false); | 280 views::Accelerator escape(app::VKEY_RETURN, false, true, false); |
281 focus_manager()->RegisterAccelerator(escape, this); | 281 focus_manager()->RegisterAccelerator(escape, this); |
282 } | 282 } |
283 | 283 |
284 void FindBarHost::UnregisterAccelerators() { | 284 void FindBarHost::UnregisterAccelerators() { |
285 // Unregister Ctrl+Return. | 285 // Unregister Ctrl+Return. |
286 views::Accelerator escape(base::VKEY_RETURN, false, true, false); | 286 views::Accelerator escape(app::VKEY_RETURN, false, true, false); |
287 focus_manager()->UnregisterAccelerator(escape, this); | 287 focus_manager()->UnregisterAccelerator(escape, this); |
288 | 288 |
289 DropdownBarHost::UnregisterAccelerators(); | 289 DropdownBarHost::UnregisterAccelerators(); |
290 } | 290 } |
291 | 291 |
292 //////////////////////////////////////////////////////////////////////////////// | 292 //////////////////////////////////////////////////////////////////////////////// |
293 // private: | 293 // private: |
294 | 294 |
295 FindBarView* FindBarHost::find_bar_view() { | 295 FindBarView* FindBarHost::find_bar_view() { |
296 return static_cast<FindBarView*>(view()); | 296 return static_cast<FindBarView*>(view()); |
297 } | 297 } |
OLD | NEW |