// Copyright (c) 2006-2008 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_MAC_H_ #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ #import #include "base/time.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "webkit/glue/webcursor.h" class RenderWidgetHostViewMac; // This is the NSView that lives in the Cocoa view hierarchy. In Windows-land, // RenderWidgetHostViewWin is both the view and the delegate. We split the roles // but that means that the view needs to own the delegate and will dispose of it // when it's removed from the view system. @interface RenderWidgetHostViewCocoa : NSView { @private RenderWidgetHostViewMac* renderWidgetHostView_; } @end /////////////////////////////////////////////////////////////////////////////// // RenderWidgetHostViewMac // // An object representing the "View" of a rendered web page. This object is // responsible for displaying the content of the web page, and integrating with // the Cocoa view system. It is the implementation of the RenderWidgetHostView // that the cross-platform RenderWidgetHost object uses // to display the data. // // Comment excerpted from render_widget_host.h: // // "The lifetime of the RenderWidgetHost* is tied to the render process. // If the render process dies, the RenderWidgetHost* goes away and all // references to it must become NULL." // class RenderWidgetHostViewMac : public RenderWidgetHostView { public: // The view will associate itself with the given widget. The native view must // be hooked up immediately to the view hierarchy, or else when it is // deleted it will delete this out from under the caller. explicit RenderWidgetHostViewMac(RenderWidgetHost* widget); virtual ~RenderWidgetHostViewMac(); RenderWidgetHost* render_widget_host() const { return render_widget_host_; } base::TimeTicks& whiteout_start_time() { return whiteout_start_time_; } gfx::NativeView native_view() const { return cocoa_view_; } // Implementation of RenderWidgetHostView: virtual RenderWidgetHost* GetRenderWidgetHost() const; virtual void DidBecomeSelected(); virtual void WasHidden(); virtual void SetSize(const gfx::Size& size); virtual gfx::NativeView GetPluginNativeView(); virtual void MovePluginWindows( const std::vector& plugin_window_moves); virtual void Focus(); virtual void Blur(); virtual bool HasFocus(); virtual void Show(); virtual void Hide(); virtual gfx::Rect GetViewBounds() const; virtual void UpdateCursor(const WebCursor& cursor); virtual void UpdateCursorIfOverSelf(); virtual void SetIsLoading(bool is_loading); virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); virtual void DidPaintRect(const gfx::Rect& rect); virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy); virtual void RendererGone(); virtual void Destroy(); virtual void SetTooltipText(const std::wstring& tooltip_text); private: // Shuts down the render_widget_host_. This is a separate function so we can // invoke it from the message loop. void ShutdownHost(); // Redraws the window asynchronously. void Redraw(const gfx::Rect& invalid_rect); // The associated view. RenderWidgetHostViewCocoa* cocoa_view_; // WEAK // The associated Model. RenderWidgetHost* render_widget_host_; // The cursor for the page. This is passed up from the renderer. WebCursor current_cursor_; // Indicates if the page is loading. bool is_loading_; // true if the View is not visible. bool is_hidden_; // Tooltips // The text to be shown in the tooltip, supplied by the renderer. std::wstring tooltip_text_; // The time at which this view started displaying white pixels as a result of // not having anything to paint (empty backing store from renderer). This // value returns true for is_null() if we are not recording whiteout times. base::TimeTicks whiteout_start_time_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); }; #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_