Home | History | Annotate | Download | only in views
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/ui/views/dropdown_bar_host.h"
      6 
      7 #include "base/logging.h"
      8 #include "ui/aura/window.h"
      9 #include "ui/events/event.h"
     10 #include "ui/views/view_constants_aura.h"
     11 #include "ui/views/widget/widget.h"
     12 
     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,
     27                                               bool no_redraw) {
     28   if (!host_->IsVisible())
     29     host_->GetNativeView()->Show();
     30   host_->GetNativeView()->SetBounds(new_pos);
     31 
     32   // The z-order of |host_| is controlled by the view specified via
     33   // views::kHostViewKey.
     34 }
     35 
     36 void DropdownBarHost::SetHostViewNative(views::View* host_view) {
     37   host_->GetNativeView()->SetProperty(views::kHostViewKey, host_view);
     38 }
     39