// 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_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ #pragma once #include #include #include #include "base/callback.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process_util.h" #include "base/property_bag.h" #include "base/string16.h" #include "base/timer.h" #include "build/build_config.h" #include "content/common/view_message_enums.h" #include "content/public/browser/render_widget_host.h" #include "content/public/common/page_zoom.h" #include "ui/base/ime/text_input_type.h" #include "ui/gfx/native_widget_types.h" class BackingStore; class MockRenderWidgetHost; class WebCursor; struct EditCommand; struct ViewHostMsg_UpdateRect_Params; namespace base { class TimeTicks; } namespace ui { class Range; } namespace WebKit { class WebInputEvent; class WebMouseEvent; struct WebCompositionUnderline; struct WebScreenInfo; } namespace content { class RenderWidgetHostViewPort; class TapSuppressionController; // This implements the RenderWidgetHost interface that is exposed to // embedders of content, and adds things only visible to content. class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, public IPC::Channel::Listener { public: // routing_id can be MSG_ROUTING_NONE, in which case the next available // routing id is taken from the RenderProcessHost. RenderWidgetHostImpl(RenderProcessHost* process, int routing_id); virtual ~RenderWidgetHostImpl(); // Use RenderWidgetHostImpl::From(rwh) to downcast a // RenderWidgetHost to a RenderWidgetHostImpl. Internally, this // uses RenderWidgetHost::AsRenderWidgetHostImpl(). static RenderWidgetHostImpl* From(RenderWidgetHost* rwh); // RenderWidgetHost implementation. virtual void Undo() OVERRIDE; virtual void Redo() OVERRIDE; virtual void Cut() OVERRIDE; virtual void Copy() OVERRIDE; virtual void CopyToFindPboard() OVERRIDE; virtual void Paste() OVERRIDE; virtual void PasteAndMatchStyle() OVERRIDE; virtual void Delete() OVERRIDE; virtual void SelectAll() OVERRIDE; virtual void UpdateTextDirection(WebKit::WebTextDirection direction) OVERRIDE; virtual void NotifyTextDirection() OVERRIDE; virtual void Blur() OVERRIDE; virtual bool CopyFromBackingStore(const gfx::Rect& src_rect, const gfx::Size& accelerated_dest_size, skia::PlatformCanvas* output) OVERRIDE; virtual void AsyncCopyFromBackingStore( const gfx::Rect& src_rect, const gfx::Size& accelerated_dest_size, skia::PlatformCanvas* output, base::Callback callback) OVERRIDE; #if defined(TOOLKIT_GTK) virtual bool CopyFromBackingStoreToGtkWindow(const gfx::Rect& dest_rect, GdkWindow* target) OVERRIDE; #elif defined(OS_MACOSX) virtual gfx::Size GetBackingStoreSize() OVERRIDE; virtual bool CopyFromBackingStoreToCGContext(const CGRect& dest_rect, CGContextRef target) OVERRIDE; #endif virtual void EnableFullAccessibilityMode() OVERRIDE; virtual void ForwardMouseEvent( const WebKit::WebMouseEvent& mouse_event) OVERRIDE; virtual void ForwardWheelEvent( const WebKit::WebMouseWheelEvent& wheel_event) OVERRIDE; virtual void ForwardKeyboardEvent( const NativeWebKeyboardEvent& key_event) OVERRIDE; virtual const gfx::Point& GetLastScrollOffset() const OVERRIDE; virtual RenderProcessHost* GetProcess() const OVERRIDE; virtual int GetRoutingID() const OVERRIDE; virtual RenderWidgetHostView* GetView() const OVERRIDE; virtual bool IsRenderView() const OVERRIDE; virtual void PaintAtSize(TransportDIB::Handle dib_handle, int tag, const gfx::Size& page_size, const gfx::Size& desired_size) OVERRIDE; virtual void Replace(const string16& word) OVERRIDE; virtual void ResizeRectChanged(const gfx::Rect& new_rect) OVERRIDE; virtual void RestartHangMonitorTimeout() OVERRIDE; virtual void SetIgnoreInputEvents(bool ignore_input_events) OVERRIDE; virtual void Stop() OVERRIDE; virtual void WasResized() OVERRIDE; virtual void AddKeyboardListener(KeyboardListener* listener) OVERRIDE; virtual void RemoveKeyboardListener(KeyboardListener* listener) OVERRIDE; // Sets the View of this RenderWidgetHost. void SetView(RenderWidgetHostView* view); int surface_id() const { return surface_id_; } bool empty() const { return current_size_.IsEmpty(); } // Returns the property bag for this widget, where callers can add extra data // they may wish to associate with it. Returns a pointer rather than a // reference since the PropertyAccessors expect this. const base::PropertyBag* property_bag() const { return &property_bag_; } base::PropertyBag* property_bag() { return &property_bag_; } // Called when a renderer object already been created for this host, and we // just need to be attached to it. Used for window.open,