| OLD | NEW |
| 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/dropdown_bar_host.h" | 5 #include "chrome/browser/ui/views/dropdown_bar_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | |
| 8 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 9 #include "ui/events/event.h" | |
| 10 #include "ui/views/view_constants_aura.h" | 8 #include "ui/views/view_constants_aura.h" |
| 11 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
| 12 | 10 |
| 13 using content::NativeWebKeyboardEvent; | |
| 14 using content::WebContents; | |
| 15 | |
| 16 NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent( | |
| 17 const WebContents* contents, | |
| 18 const ui::KeyEvent& key_event) { | |
| 19 // NativeWebKeyboardEvent should take a const gfx::NativeEvent, which would | |
| 20 // prevent this casting. | |
| 21 ui::Event* ui_event = | |
| 22 static_cast<ui::Event*>(const_cast<ui::KeyEvent*>(&key_event)); | |
| 23 return NativeWebKeyboardEvent(ui_event); | |
| 24 } | |
| 25 | |
| 26 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, | 11 void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos, |
| 27 bool no_redraw) { | 12 bool no_redraw) { |
| 28 if (!host_->IsVisible()) | 13 if (!host_->IsVisible()) |
| 29 host_->GetNativeView()->Show(); | 14 host_->GetNativeView()->Show(); |
| 30 host_->GetNativeView()->SetBounds(new_pos); | 15 host_->GetNativeView()->SetBounds(new_pos); |
| 31 | 16 |
| 32 // The z-order of |host_| is controlled by the view specified via | 17 // The z-order of |host_| is controlled by the view specified via |
| 33 // views::kHostViewKey. | 18 // views::kHostViewKey. |
| 34 } | 19 } |
| 35 | 20 |
| 36 void DropdownBarHost::SetHostViewNative(views::View* host_view) { | 21 void DropdownBarHost::SetHostViewNative(views::View* host_view) { |
| 37 host_->GetNativeView()->SetProperty(views::kHostViewKey, host_view); | 22 host_->GetNativeView()->SetProperty(views::kHostViewKey, host_view); |
| 38 } | 23 } |
| OLD | NEW |