// 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_GTK_H_ #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ #include #include #include #include #include "base/scoped_ptr.h" #include "base/time.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/common/owned_widget_gtk.h" #include "gfx/native_widget_types.h" #include "webkit/glue/plugins/gtk_plugin_container_manager.h" #include "webkit/glue/webcursor.h" class RenderWidgetHost; class GpuViewHost; class GtkIMContextWrapper; class GtkKeyBindingsHandler; class MenuGtk; class NativeWebKeyboardEvent; typedef struct _GtkClipboard GtkClipboard; typedef struct _GtkSelectionData GtkSelectionData; // ----------------------------------------------------------------------------- // See comments in render_widget_host_view.h about this class and its members. // ----------------------------------------------------------------------------- class RenderWidgetHostViewGtk : public RenderWidgetHostView { public: explicit RenderWidgetHostViewGtk(RenderWidgetHost* widget); ~RenderWidgetHostViewGtk(); // 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 RenderWidgetHost* GetRenderWidgetHost() const { return host_; } virtual void DidBecomeSelected(); virtual void WasHidden(); virtual void SetSize(const gfx::Size& size); virtual gfx::NativeView GetNativeView(); 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 IMEUpdateStatus(int control, const gfx::Rect& caret_rect); virtual void DidPaintBackingStoreRects(const std::vector& rects); virtual void DidScrollBackingStoreRect(const gfx::Rect& rect, int dx, int dy); 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 VideoLayer* AllocVideoLayer(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(bool deemphasized); virtual bool ContainsNativeView(gfx::NativeView native_view) const; gfx::NativeView native_view() const { return view_.get(); } void Paint(const gfx::Rect&); // Called by GtkIMContextWrapper to forward a keyboard event to renderer. // Before calling RenderWidgetHost::ForwardKeyboardEvent(), this method // calls GtkKeyBindingsHandler::Match() against the event and send matched // edit commands to renderer by calling // RenderWidgetHost::ForwardEditCommandsForNextKeyEvent(). void ForwardKeyboardEvent(const NativeWebKeyboardEvent& event); // Appends the input methods context menu to the specified |menu| object as a // submenu. void AppendInputMethodsContextMenu(MenuGtk* menu); private: friend class RenderWidgetHostViewGtkWidget; // Returns whether the widget needs an input grab (GTK+ and X) to work // properly. bool NeedsInputGrab(); // Returns whether this render view is a popup ( dropdowns. It should be true for most such cases, but false // for extension popups. bool do_x_grab_; // A convenience wrapper object for GtkIMContext; scoped_ptr im_context_; // A convenience object for handling editor key bindings defined in gtk // keyboard theme. scoped_ptr key_bindings_handler_; // Helper class that lets us allocate plugin containers and move them. GtkPluginContainerManager plugin_container_manager_; // The size that we want the renderer to be. We keep this in a separate // variable because resizing in GTK+ is async. gfx::Size requested_size_; }; #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_