Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / content / browser / renderer_host / render_widget_host_view_base.h
blobeadf92b87d20c6372e778627304cafd7725fb870
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_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_
8 #if defined(OS_MACOSX)
9 #include <OpenGL/OpenGL.h>
10 #endif
12 #if defined(TOOLKIT_GTK)
13 #include <gdk/gdk.h>
14 #endif
16 #include <string>
17 #include <vector>
19 #include "base/memory/scoped_ptr.h"
20 #include "base/callback_forward.h"
21 #include "base/timer/timer.h"
22 #include "content/common/content_export.h"
23 #include "content/port/browser/render_widget_host_view_port.h"
24 #include "ui/gfx/native_widget_types.h"
25 #include "ui/gfx/range/range.h"
26 #include "ui/gfx/rect.h"
28 namespace content {
30 class RenderWidgetHostImpl;
32 // Basic implementation shared by concrete RenderWidgetHostView
33 // subclasses.
35 // Note that nothing should use this class, except concrete subclasses
36 // that are deriving from it, and code that is written specifically to
37 // use one of these concrete subclasses (i.e. platform-specific code).
39 // To enable embedders that add ports, everything else in content/
40 // should use the RenderWidgetHostViewPort interface.
42 // RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
43 class CONTENT_EXPORT RenderWidgetHostViewBase
44 : public RenderWidgetHostViewPort {
45 public:
46 virtual ~RenderWidgetHostViewBase();
48 // RenderWidgetHostViewPort implementation.
49 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
50 virtual void SelectionChanged(const base::string16& text,
51 size_t offset,
52 const gfx::Range& range) OVERRIDE;
53 virtual void SetBackground(const SkBitmap& background) OVERRIDE;
54 virtual const SkBitmap& GetBackground() OVERRIDE;
55 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE;
56 virtual float GetOverdrawBottomHeight() const OVERRIDE;
57 virtual bool IsShowingContextMenu() const OVERRIDE;
58 virtual void SetShowingContextMenu(bool showing_menu) OVERRIDE;
59 virtual base::string16 GetSelectedText() const OVERRIDE;
60 virtual bool IsMouseLocked() OVERRIDE;
61 virtual void UnhandledWheelEvent(
62 const blink::WebMouseWheelEvent& event) OVERRIDE;
63 virtual InputEventAckState FilterInputEvent(
64 const blink::WebInputEvent& input_event) OVERRIDE;
65 virtual void OnSetNeedsFlushInput() OVERRIDE;
66 virtual void OnDidFlushInput() OVERRIDE;
67 virtual void GestureEventAck(int gesture_event_type,
68 InputEventAckState ack_result) OVERRIDE;
69 virtual void SetPopupType(blink::WebPopupType popup_type) OVERRIDE;
70 virtual blink::WebPopupType GetPopupType() OVERRIDE;
71 virtual BrowserAccessibilityManager*
72 GetBrowserAccessibilityManager() const OVERRIDE;
73 virtual void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
74 InputEventAckState ack_result) OVERRIDE;
75 virtual scoped_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget()
76 OVERRIDE;
77 virtual bool CanSubscribeFrame() const OVERRIDE;
78 virtual void BeginFrameSubscription(
79 scoped_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) OVERRIDE;
80 virtual void EndFrameSubscription() OVERRIDE;
81 virtual void OnSwapCompositorFrame(
82 uint32 output_surface_id,
83 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE {}
84 virtual void ResizeCompositingSurface(const gfx::Size&) OVERRIDE {}
85 virtual void OnOverscrolled(gfx::Vector2dF accumulated_overscroll,
86 gfx::Vector2dF current_fling_velocity) OVERRIDE;
87 virtual uint32 RendererFrameNumber() OVERRIDE;
88 virtual void DidReceiveRendererFrame() OVERRIDE;
90 void SetBrowserAccessibilityManager(BrowserAccessibilityManager* manager);
92 // Notification that a resize or move session ended on the native widget.
93 void UpdateScreenInfo(gfx::NativeView view);
95 // Tells if the display property (work area/scale factor) has
96 // changed since the last time.
97 bool HasDisplayPropertyChanged(gfx::NativeView view);
99 #if defined(OS_WIN)
100 // The callback that DetachPluginsHelper calls for each child window. Call
101 // this directly if you want to do custom filtering on plugin windows first.
102 static void DetachPluginWindowsCallback(HWND window);
103 #endif
105 protected:
106 // Interface class only, do not construct.
107 RenderWidgetHostViewBase();
109 #if defined(OS_WIN)
110 // Shared implementation of MovePluginWindows for use by win and aura/wina.
111 static void MovePluginWindowsHelper(
112 HWND parent,
113 const std::vector<WebPluginGeometry>& moves);
115 static void PaintPluginWindowsHelper(
116 HWND parent,
117 const gfx::Rect& damaged_screen_rect);
119 // Needs to be called before the HWND backing the view goes away to avoid
120 // crashes in Windowed plugins.
121 static void DetachPluginsHelper(HWND parent);
122 #endif
124 // Whether this view is a popup and what kind of popup it is (select,
125 // autofill...).
126 blink::WebPopupType popup_type_;
128 // A custom background to paint behind the web content. This will be tiled
129 // horizontally. Can be null, in which case we fall back to painting white.
130 SkBitmap background_;
132 // While the mouse is locked, the cursor is hidden from the user. Mouse events
133 // are still generated. However, the position they report is the last known
134 // mouse position just as mouse lock was entered; the movement they report
135 // indicates what the change in position of the mouse would be had it not been
136 // locked.
137 bool mouse_locked_;
139 // Whether we are showing a context menu.
140 bool showing_context_menu_;
142 // A buffer containing the text inside and around the current selection range.
143 base::string16 selection_text_;
145 // The offset of the text stored in |selection_text_| relative to the start of
146 // the web page.
147 size_t selection_text_offset_;
149 // The current selection range relative to the start of the web page.
150 gfx::Range selection_range_;
152 protected:
153 // The scale factor of the display the renderer is currently on.
154 float current_device_scale_factor_;
156 private:
157 void FlushInput();
159 // Manager of the tree representation of the WebKit render tree.
160 scoped_ptr<BrowserAccessibilityManager> browser_accessibility_manager_;
162 gfx::Rect current_display_area_;
164 uint32 renderer_frame_number_;
166 base::OneShotTimer<RenderWidgetHostViewBase> flush_input_timer_;
168 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewBase);
171 } // namespace content
173 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_BASE_H_