OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/dropdown_bar_host.h" | 5 #include "chrome/browser/views/dropdown_bar_host.h" |
6 | 6 |
| 7 #include "app/keyboard_code_conversion_win.h" |
7 #include "chrome/browser/renderer_host/render_view_host.h" | 8 #include "chrome/browser/renderer_host/render_view_host.h" |
8 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
9 #include "chrome/browser/tab_contents/tab_contents_view.h" | 10 #include "chrome/browser/tab_contents/tab_contents_view.h" |
10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 11 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
11 #include "chrome/browser/views/frame/browser_view.h" | 12 #include "chrome/browser/views/frame/browser_view.h" |
12 #include "views/controls/scrollbar/native_scroll_bar.h" | 13 #include "views/controls/scrollbar/native_scroll_bar.h" |
13 #include "views/widget/widget_win.h" | 14 #include "views/widget/widget_win.h" |
14 | 15 |
15 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( | 16 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( |
16 const TabContents* contents, | 17 const TabContents* contents, |
17 const views::Textfield::Keystroke& key_stroke) { | 18 const views::KeyEvent& key_event) { |
18 HWND hwnd = contents->GetContentNativeView(); | 19 HWND hwnd = contents->GetContentNativeView(); |
19 return NativeWebKeyboardEvent( | 20 WORD key = WindowsKeyCodeForKeyboardCode(key_event.GetKeyCode()); |
20 hwnd, key_stroke.message(), key_stroke.key(), 0); | 21 |
| 22 return NativeWebKeyboardEvent(hwnd, key_event.message(), key, 0); |
21 } | 23 } |
22 | 24 |
23 views::Widget* DropdownBarHost::CreateHost() { | 25 views::Widget* DropdownBarHost::CreateHost() { |
24 views::WidgetWin* widget = new views::WidgetWin(); | 26 views::WidgetWin* widget = new views::WidgetWin(); |
25 // Don't let WidgetWin manage our lifetime. We want our lifetime to | 27 // Don't let WidgetWin manage our lifetime. We want our lifetime to |
26 // coincide with TabContents. | 28 // coincide with TabContents. |
27 widget->set_delete_on_destroy(false); | 29 widget->set_delete_on_destroy(false); |
28 widget->set_window_style(WS_CHILD | WS_CLIPCHILDREN); | 30 widget->set_window_style(WS_CHILD | WS_CLIPCHILDREN); |
29 widget->set_window_ex_style(WS_EX_TOPMOST); | 31 widget->set_window_ex_style(WS_EX_TOPMOST); |
30 | 32 |
31 return widget; | 33 return widget; |
32 } | 34 } |
33 | 35 |
34 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, | 36 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, |
35 bool no_redraw) { | 37 bool no_redraw) { |
36 gfx::Rect window_rect; | 38 gfx::Rect window_rect; |
37 host_->GetBounds(&window_rect, true); | 39 host_->GetBounds(&window_rect, true); |
38 DWORD swp_flags = SWP_NOOWNERZORDER; | 40 DWORD swp_flags = SWP_NOOWNERZORDER; |
39 if (!window_rect.IsEmpty()) | 41 if (!window_rect.IsEmpty()) |
40 swp_flags |= SWP_NOSIZE; | 42 swp_flags |= SWP_NOSIZE; |
41 if (no_redraw) | 43 if (no_redraw) |
42 swp_flags |= SWP_NOREDRAW; | 44 swp_flags |= SWP_NOREDRAW; |
43 if (!host_->IsVisible()) | 45 if (!host_->IsVisible()) |
44 swp_flags |= SWP_SHOWWINDOW; | 46 swp_flags |= SWP_SHOWWINDOW; |
45 | 47 |
46 ::SetWindowPos(host_->GetNativeView(), HWND_TOP, new_pos.x(), new_pos.y(), | 48 ::SetWindowPos(host_->GetNativeView(), HWND_TOP, new_pos.x(), new_pos.y(), |
47 new_pos.width(), new_pos.height(), swp_flags); | 49 new_pos.width(), new_pos.height(), swp_flags); |
48 } | 50 } |
OLD | NEW |