// Copyright (c) 2010 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 CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_VIEWS_H_ #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_VIEWS_H_ #pragma once #include #include #include #include "base/scoped_ptr.h" #include "base/time.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "ui/gfx/native_widget_types.h" #include "views/controls/native/native_view_host.h" #include "views/events/event.h" #include "views/view.h" #include "webkit/glue/webcursor.h" class IMEContextHandler; class RenderWidgetHost; struct NativeWebKeyboardEvent; // ----------------------------------------------------------------------------- // See comments in render_widget_host_view.h about this class and its members. // ----------------------------------------------------------------------------- class RenderWidgetHostViewViews : public RenderWidgetHostView, public views::View { public: // Internal class name. static const char kViewClassName[]; explicit RenderWidgetHostViewViews(RenderWidgetHost* widget); virtual ~RenderWidgetHostViewViews(); // Initialize this object for use as a drawing area. void InitAsChild(); // RenderWidgetHostView implementation. virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) OVERRIDE; virtual void InitAsFullscreen() OVERRIDE; virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; virtual void DidBecomeSelected() OVERRIDE; virtual void WasHidden() OVERRIDE; virtual void SetSize(const gfx::Size& size) OVERRIDE; virtual gfx::NativeView GetNativeView() OVERRIDE; virtual void MovePluginWindows( const std::vector& moves) OVERRIDE; virtual void Focus() OVERRIDE; virtual void Blur() OVERRIDE; virtual bool HasFocus() OVERRIDE; virtual void Show() OVERRIDE; virtual void Hide() OVERRIDE; virtual bool IsShowing() OVERRIDE; virtual gfx::Rect GetViewBounds() const OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; virtual void ImeUpdateTextInputState(WebKit::WebTextInputType type, const gfx::Rect& caret_rect) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void DidUpdateBackingStore( const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, const std::vector& copy_rects) OVERRIDE; virtual void RenderViewGone(base::TerminationStatus status, int error_code) OVERRIDE; virtual void Destroy() OVERRIDE; virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) OVERRIDE {} virtual void SetTooltipText(const std::wstring& tooltip_text) OVERRIDE; virtual void SelectionChanged(const std::string& text) OVERRIDE; virtual void ShowingContextMenu(bool showing) OVERRIDE; virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE; virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE; virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate) OVERRIDE; virtual bool ContainsNativeView(gfx::NativeView native_view) const OVERRIDE; virtual void AcceleratedCompositingActivated(bool activated) OVERRIDE; virtual gfx::PluginWindowHandle AcquireCompositingSurface() OVERRIDE; virtual void ReleaseCompositingSurface( gfx::PluginWindowHandle surface) OVERRIDE; // On some systems, there can be two native views, where an outer native view // contains the inner native view (e.g. when using GTK+). This returns the // inner view. This can return NULL when it's not attached to a view. gfx::NativeView GetInnerNativeView() const; virtual void OnPaint(gfx::Canvas* canvas); // Overridden from views::View. virtual std::string GetClassName() const; gfx::NativeCursor GetCursorForPoint(ui::EventType type, const gfx::Point& point); // Views mouse events, overridden from views::View. virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled) OVERRIDE; virtual void OnMouseMoved(const views::MouseEvent& e) OVERRIDE; virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; virtual bool OnMouseWheel(const views::MouseWheelEvent& e) OVERRIDE; // Views keyboard events, overridden from views::View. virtual bool OnKeyPressed(const views::KeyEvent &e) OVERRIDE; virtual bool OnKeyReleased(const views::KeyEvent &e) OVERRIDE; virtual void OnFocus() OVERRIDE; virtual void OnBlur() OVERRIDE; // Forwards a web keyboard event to renderer. void ForwardWebKeyboardEvent(const NativeWebKeyboardEvent& event); // Forwards a keyboard event to renderer. void ForwardKeyEvent(const views::KeyEvent& event); // Views touch events, overridden from views::View. virtual View::TouchStatus OnTouchEvent(const views::TouchEvent& e) OVERRIDE; private: friend class RenderWidgetHostViewViewsWidget; // Returns whether the widget needs an input grab to work // properly. bool NeedsInputGrab(); // Returns whether this render view is a popup (