text: // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  // Use of this source code is governed by a BSD-style license that can be
  // found in the LICENSE file.
  
  #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_
  #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_
  
  #include <vector>
  
  #include "base/memory/ref_counted.h"
  #include "base/memory/scoped_ptr.h"
  #include "content/common/content_export.h"
  #include "content/port/browser/render_view_host_delegate_view.h"
  #include "content/public/browser/web_contents_view.h"
  #include "ui/aura/client/drag_drop_delegate.h"
  #include "ui/aura/window_delegate.h"
  
  namespace aura {
  class Window;
  }
  
  namespace ui {
  class DropTargetEvent;
  }
  
  namespace content {
  class WebContentsViewDelegate;
  class WebContentsImpl;
  class WebDragDestDelegate;
  
  class CONTENT_EXPORT WebContentsViewAura
      : public WebContentsView,
        public RenderViewHostDelegateView,
        public aura::WindowDelegate,
        public aura::client::DragDropDelegate {
   public:
    WebContentsViewAura(WebContentsImpl* web_contents,
                        WebContentsViewDelegate* delegate);
  
   private:
    virtual ~WebContentsViewAura();
  
    void SizeChangedCommon(const gfx::Size& size);
  
    void EndDrag(WebKit::WebDragOperationsMask ops);
  
    // Overridden from WebContentsView:
    virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
    virtual RenderWidgetHostView* CreateViewForWidget(
        RenderWidgetHost* render_widget_host) OVERRIDE;
    virtual gfx::NativeView GetNativeView() const OVERRIDE;
    virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
    virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
    virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE;
    virtual void SetPageTitle(const string16& title) OVERRIDE;
    virtual void OnTabCrashed(base::TerminationStatus status,
                              int error_code) OVERRIDE;
    virtual void SizeContents(const gfx::Size& size) OVERRIDE;
    virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
    virtual void Focus() OVERRIDE;
    virtual void SetInitialFocus() OVERRIDE;
    virtual void StoreFocus() OVERRIDE;
    virtual void RestoreFocus() OVERRIDE;
    virtual WebDropData* GetDropData() const OVERRIDE;
    virtual bool IsEventTracking() const OVERRIDE;
    virtual void CloseTabAfterEventTracking() OVERRIDE;
    virtual gfx::Rect GetViewBounds() const OVERRIDE;
  
    // Overridden from RenderViewHostDelegateView:
    virtual void ShowContextMenu(
        const ContextMenuParams& params,
        ContextMenuSourceType type) OVERRIDE;
    virtual void ShowPopupMenu(const gfx::Rect& bounds,
                               int item_height,
                               double item_font_size,
                               int selected_item,
                               const std::vector<WebMenuItem>& items,
                               bool right_aligned,
                               bool allow_multiple_selection) OVERRIDE;
    virtual void StartDragging(const WebDropData& drop_data,
                               WebKit::WebDragOperationsMask operations,
                               const gfx::ImageSkia& image,
                               const gfx::Vector2d& image_offset) OVERRIDE;
    virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
    virtual void GotFocus() OVERRIDE;
    virtual void TakeFocus(bool reverse) OVERRIDE;
  
    // Overridden from aura::WindowDelegate:
    virtual gfx::Size GetMinimumSize() const OVERRIDE;
    virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
                                 const gfx::Rect& new_bounds) OVERRIDE;
    virtual void OnFocus(aura::Window* old_focused_window) OVERRIDE;
    virtual void OnBlur() OVERRIDE;
    virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
    virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
    virtual bool ShouldDescendIntoChildForEventHandling(
        aura::Window* child,
        const gfx::Point& location) OVERRIDE;
    virtual bool CanFocus() OVERRIDE;
    virtual void OnCaptureLost() OVERRIDE;
    virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
    virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
    virtual void OnWindowDestroying() OVERRIDE;
    virtual void OnWindowDestroyed() OVERRIDE;
    virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
    virtual bool HasHitTestMask() const OVERRIDE;
    virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
    virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE;
  
    // Overridden from ui::EventHandler:
    virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
    virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
    virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
    virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
  
    // Overridden from aura::client::DragDropDelegate:
    virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE;
    virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
    virtual void OnDragExited() OVERRIDE;
    virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
  
    scoped_ptr<aura::Window> window_;
  
    // The WebContentsImpl whose contents we display.
    WebContentsImpl* web_contents_;
  
    RenderWidgetHostView* view_;
  
    scoped_ptr<WebContentsViewDelegate> delegate_;
  
    WebKit::WebDragOperationsMask current_drag_op_;
  
    scoped_ptr<WebDropData> current_drop_data_;
  
    WebDragDestDelegate* drag_dest_delegate_;
  
    // We keep track of the render view host we're dragging over.  If it changes
    // during a drag, we need to re-send the DragEnter message.  WARNING:
    // this pointer should never be dereferenced.  We only use it for comparing
    // pointers.
    void* current_rvh_for_drag_;
  
    DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura);
  };
  
  }  // namespace content
  
  #endif  // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_
  