// 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 "chrome/browser/renderer_host/render_widget_host_view.h" #include "gfx/native_widget_types.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "views/controls/native/native_view_host.h" #include "views/event.h" #include "views/view.h" #include "webkit/glue/webcursor.h" 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: 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); virtual void InitAsFullscreen(RenderWidgetHostView* parent_host_view); virtual RenderWidgetHost* GetRenderWidgetHost() const; virtual void DidBecomeSelected(); virtual void WasHidden(); virtual void SetSize(const gfx::Size& size); virtual void MovePluginWindows( const std::vector& moves); virtual void Focus(); virtual void Blur(); virtual bool HasFocus(); virtual void Show(); virtual void Hide(); virtual bool IsShowing(); virtual gfx::Rect GetViewBounds() const; virtual void UpdateCursor(const WebCursor& cursor); virtual void SetIsLoading(bool is_loading); virtual void ImeUpdateTextInputState(WebKit::WebTextInputType type, const gfx::Rect& caret_rect); virtual void ImeCancelComposition(); virtual void DidUpdateBackingStore( const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, const std::vector& copy_rects); virtual void RenderViewGone(); virtual void Destroy(); virtual void WillDestroyRenderWidget(RenderWidgetHost* rwh) {} virtual void SetTooltipText(const std::wstring& tooltip_text); virtual void SelectionChanged(const std::string& text); virtual void ShowingContextMenu(bool showing); virtual BackingStore* AllocBackingStore(const gfx::Size& size); virtual void SetBackground(const SkBitmap& background); virtual void CreatePluginContainer(gfx::PluginWindowHandle id); virtual void DestroyPluginContainer(gfx::PluginWindowHandle id); virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate); virtual bool ContainsNativeView(gfx::NativeView native_view) const; virtual void AcceleratedCompositingActivated(bool activated); gfx::NativeView native_view() const; virtual gfx::NativeView GetNativeView() { return native_view(); } virtual void Paint(gfx::Canvas* canvas); // Overridden from views::View. gfx::NativeCursor GetCursorForPoint(views::Event::EventType type, const gfx::Point& point); // Views mouse events, overridden from views::View. virtual bool OnMousePressed(const views::MouseEvent& event); virtual bool OnMouseDragged(const views::MouseEvent& event); virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); virtual void OnMouseMoved(const views::MouseEvent& e); virtual void OnMouseEntered(const views::MouseEvent& event); virtual void OnMouseExited(const views::MouseEvent& event); virtual bool OnMouseWheel(const views::MouseWheelEvent& e); // Views keyboard events, overridden from views::View. virtual bool OnKeyPressed(const views::KeyEvent &e); virtual bool OnKeyReleased(const views::KeyEvent &e); virtual void DidGainFocus(); virtual void WillLoseFocus(); // Forwards a keyboard event to renderer. void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event); // Views touch events, overridden from views::View. virtual bool OnTouchEvent(const views::TouchEvent& e); 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 (