Broke ContentSettingBubbleModelTest.Plugins on Android.
[chromium-blink-merge.git] / content / browser / web_contents / web_contents_view_aura.h
blob46c76c67471c0387b84e72d65435c70b22087df5
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.
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/browser/renderer_host/overscroll_controller_delegate.h"
13 #include "content/common/content_export.h"
14 #include "content/port/browser/render_view_host_delegate_view.h"
15 #include "content/public/browser/web_contents_view.h"
16 #include "ui/aura/client/drag_drop_delegate.h"
17 #include "ui/aura/window_delegate.h"
18 #include "ui/compositor/layer_animation_observer.h"
20 namespace aura {
21 class Window;
24 namespace ui {
25 class DropTargetEvent;
28 namespace content {
29 class OverscrollNavigationOverlay;
30 class WebContentsViewDelegate;
31 class WebContentsImpl;
32 class WebDragDestDelegate;
34 class CONTENT_EXPORT WebContentsViewAura
35 : public WebContentsView,
36 public RenderViewHostDelegateView,
37 NON_EXPORTED_BASE(public OverscrollControllerDelegate),
38 public ui::ImplicitAnimationObserver,
39 public aura::WindowDelegate,
40 public aura::client::DragDropDelegate {
41 public:
42 WebContentsViewAura(WebContentsImpl* web_contents,
43 WebContentsViewDelegate* delegate);
45 private:
46 class WindowObserver;
48 virtual ~WebContentsViewAura();
50 void SizeChangedCommon(const gfx::Size& size);
52 void EndDrag(WebKit::WebDragOperationsMask ops);
54 // Creates and sets up the overlay window that will be displayed during the
55 // overscroll gesture.
56 void PrepareOverscrollWindow();
58 // Sets up the content window in preparation for starting an overscroll
59 // gesture.
60 void PrepareContentWindowForOverscroll();
62 // Resets any in-progress animation for the overscroll gesture. Note that this
63 // doesn't immediately reset the internal states; that happens after an
64 // animation.
65 void ResetOverscrollTransform();
67 // Completes the navigation in response to a completed overscroll gesture.
68 // The navigation happens after an animation (either the overlay window
69 // animates in, or the content window animates out).
70 void CompleteOverscrollNavigation(OverscrollMode mode);
72 // Returns the window that should be animated for the overscroll gesture.
73 // (note that during the overscroll gesture, either the overlay window or the
74 // content window can be animated).
75 aura::Window* GetWindowToAnimateForOverscroll();
77 // Returns the amount the animating window should be translated in response to
78 // the overscroll gesture.
79 gfx::Vector2d GetTranslationForOverscroll(int delta_x, int delta_y);
81 // A window showing the screenshot is overlayed during a navigation triggered
82 // by overscroll. This function sets this up.
83 void PrepareOverscrollNavigationOverlay();
85 // Changes the brightness of the layer depending on the amount of horizontal
86 // overscroll (|delta_x|, in pixels).
87 void UpdateOverscrollWindowBrightness(float delta_x);
89 // Overridden from WebContentsView:
90 virtual void CreateView(
91 const gfx::Size& initial_size, gfx::NativeView context) OVERRIDE;
92 virtual RenderWidgetHostView* CreateViewForWidget(
93 RenderWidgetHost* render_widget_host) OVERRIDE;
94 virtual RenderWidgetHostView* CreateViewForPopupWidget(
95 RenderWidgetHost* render_widget_host) OVERRIDE;
96 virtual gfx::NativeView GetNativeView() const OVERRIDE;
97 virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
98 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
99 virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE;
100 virtual void SetPageTitle(const string16& title) OVERRIDE;
101 virtual void OnTabCrashed(base::TerminationStatus status,
102 int error_code) OVERRIDE;
103 virtual void SizeContents(const gfx::Size& size) OVERRIDE;
104 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
105 virtual void Focus() OVERRIDE;
106 virtual void SetInitialFocus() OVERRIDE;
107 virtual void StoreFocus() OVERRIDE;
108 virtual void RestoreFocus() OVERRIDE;
109 virtual WebDropData* GetDropData() const OVERRIDE;
110 virtual bool IsEventTracking() const OVERRIDE;
111 virtual void CloseTabAfterEventTracking() OVERRIDE;
112 virtual gfx::Rect GetViewBounds() const OVERRIDE;
114 // Overridden from RenderViewHostDelegateView:
115 virtual void ShowContextMenu(
116 const ContextMenuParams& params,
117 ContextMenuSourceType type) OVERRIDE;
118 virtual void ShowPopupMenu(const gfx::Rect& bounds,
119 int item_height,
120 double item_font_size,
121 int selected_item,
122 const std::vector<WebMenuItem>& items,
123 bool right_aligned,
124 bool allow_multiple_selection) OVERRIDE;
125 virtual void StartDragging(const WebDropData& drop_data,
126 WebKit::WebDragOperationsMask operations,
127 const gfx::ImageSkia& image,
128 const gfx::Vector2d& image_offset,
129 const DragEventSourceInfo& event_info) OVERRIDE;
130 virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
131 virtual void GotFocus() OVERRIDE;
132 virtual void TakeFocus(bool reverse) OVERRIDE;
134 // Overridden from OverscrollControllerDelegate:
135 virtual void OnOverscrollUpdate(float delta_x, float delta_y) OVERRIDE;
136 virtual void OnOverscrollComplete(OverscrollMode overscroll_mode) OVERRIDE;
137 virtual void OnOverscrollModeChange(OverscrollMode old_mode,
138 OverscrollMode new_mode) OVERRIDE;
140 // Overridden from ui::ImplicitAnimationObserver:
141 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
143 // Overridden from aura::WindowDelegate:
144 virtual gfx::Size GetMinimumSize() const OVERRIDE;
145 virtual gfx::Size GetMaximumSize() const OVERRIDE;
146 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
147 const gfx::Rect& new_bounds) OVERRIDE;
148 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE;
149 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
150 virtual bool ShouldDescendIntoChildForEventHandling(
151 aura::Window* child,
152 const gfx::Point& location) OVERRIDE;
153 virtual bool CanFocus() OVERRIDE;
154 virtual void OnCaptureLost() OVERRIDE;
155 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
156 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
157 virtual void OnWindowDestroying() OVERRIDE;
158 virtual void OnWindowDestroyed() OVERRIDE;
159 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
160 virtual bool HasHitTestMask() const OVERRIDE;
161 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE;
162 virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE;
164 // Overridden from ui::EventHandler:
165 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
166 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
168 // Overridden from aura::client::DragDropDelegate:
169 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE;
170 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE;
171 virtual void OnDragExited() OVERRIDE;
172 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE;
174 scoped_ptr<aura::Window> window_;
175 scoped_ptr<aura::Window> overscroll_window_;
177 scoped_ptr<WindowObserver> window_observer_;
179 // The WebContentsImpl whose contents we display.
180 WebContentsImpl* web_contents_;
182 scoped_ptr<WebContentsViewDelegate> delegate_;
184 WebKit::WebDragOperationsMask current_drag_op_;
186 scoped_ptr<WebDropData> current_drop_data_;
188 WebDragDestDelegate* drag_dest_delegate_;
190 // We keep track of the render view host we're dragging over. If it changes
191 // during a drag, we need to re-send the DragEnter message. WARNING:
192 // this pointer should never be dereferenced. We only use it for comparing
193 // pointers.
194 void* current_rvh_for_drag_;
196 bool overscroll_change_brightness_;
198 // The overscroll gesture currently in progress.
199 OverscrollMode current_overscroll_gesture_;
201 // This is the completed overscroll gesture. This is used for the animation
202 // callback that happens in response to a completed overscroll gesture.
203 OverscrollMode completed_overscroll_gesture_;
205 // This manages the overlay window that shows the screenshot during a history
206 // navigation triggered by the overscroll gesture.
207 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_;
209 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura);
212 } // namespace content
214 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_