Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_ | |
| 6 #define CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #if defined(TOOLKIT_USES_GTK) | |
| 10 #include <gdk/gdk.h> | |
| 11 #endif | |
| 12 | |
| 13 #include "content/common/content_export.h" | |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
| 16 #include "ui/gfx/native_widget_types.h" | |
| 17 | |
| 18 class BrowserAccessibilityManager; | |
| 19 class RenderWidgetHost; | |
| 20 | |
| 21 namespace gfx { | |
| 22 class Rect; | |
| 23 class Size; | |
| 24 } | |
| 25 | |
| 26 // RenderWidgetHostView is an interface implemented by an object that acts as | |
| 27 // the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its | |
| 28 // associated RenderProcessHost own the "Model" in this case which is the | |
| 29 // child renderer process. The View is responsible for receiving events from | |
| 30 // the surrounding environment and passing them to the RenderWidgetHost, and | |
| 31 // for actually displaying the content of the RenderWidgetHost when it | |
| 32 // changes. | |
| 33 // | |
| 34 // TODO(joi): Move to content namespace. | |
| 35 class CONTENT_EXPORT RenderWidgetHostView { | |
| 36 public: | |
| 37 RenderWidgetHostView(); | |
| 38 virtual ~RenderWidgetHostView(); | |
| 39 | |
| 40 // Platform-specific creator. Use this to construct new RenderWidgetHostViews | |
| 41 // rather than using RenderWidgetHostViewWin & friends. | |
| 42 // | |
| 43 // This function must NOT size it, because the RenderView in the renderer | |
| 44 // wouldn't have been created yet. The widget would set its "waiting for | |
| 45 // resize ack" flag, and the ack would never come becasue no RenderView | |
| 46 // received it. | |
| 47 // | |
| 48 // The RenderWidgetHost must already be created (because we can't know if it's | |
| 49 // going to be a regular RenderWidgetHost or a RenderViewHost (a subclass). | |
| 50 static RenderWidgetHostView* CreateViewForWidget( | |
| 51 RenderWidgetHost* widget); | |
| 52 | |
| 53 // Initialize this object for use as a drawing area. |parent_view| may be | |
| 54 // left as NULL on platforms where a parent view is not required to initialize | |
| 55 // a child window. | |
| 56 virtual void InitAsChild(gfx::NativeView parent_view) = 0; | |
| 57 | |
| 58 // Returns the associated RenderWidgetHost. | |
| 59 virtual RenderWidgetHost* GetRenderWidgetHost() const = 0; | |
| 60 | |
| 61 // Tells the View to size itself to the specified size. | |
| 62 virtual void SetSize(const gfx::Size& size) = 0; | |
| 63 | |
| 64 // Tells the View to size and move itself to the specified size and point in | |
| 65 // screen space. | |
| 66 virtual void SetBounds(const gfx::Rect& rect) = 0; | |
| 67 | |
| 68 // Retrieves the native view used to contain plugins and identify the | |
| 69 // renderer in IPC messages. | |
| 70 virtual gfx::NativeView GetNativeView() const = 0; | |
| 71 virtual gfx::NativeViewId GetNativeViewId() const = 0; | |
| 72 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0; | |
| 73 | |
| 74 // Set focus to the associated View component. | |
| 75 virtual void Focus() = 0; | |
| 76 // Returns true if the View currently has the focus. | |
| 77 virtual bool HasFocus() const = 0; | |
| 78 | |
| 79 // Shows/hides the view. These must always be called together in pairs. | |
| 80 // It is not legal to call Hide() multiple times in a row. | |
| 81 virtual void Show() = 0; | |
| 82 virtual void Hide() = 0; | |
| 83 | |
| 84 // Whether the view is showing. | |
| 85 virtual bool IsShowing() = 0; | |
| 86 | |
| 87 // Retrieve the bounds of the View, in screen coordinates. | |
| 88 virtual gfx::Rect GetViewBounds() const = 0; | |
| 89 | |
| 90 // Returns true if the View's context menu is showing. | |
| 91 virtual bool IsShowingContextMenu() const = 0; | |
| 92 | |
| 93 // Tells the View whether the context menu is showing. | |
| 94 virtual void SetShowingContextMenu(bool showing) = 0; | |
| 95 | |
| 96 #if defined(OS_MACOSX) | |
| 97 // Set the view's active state (i.e., tint state of controls). | |
| 98 virtual void SetActive(bool active) = 0; | |
| 99 | |
| 100 // Tells the view whether or not to accept first responder status. If |flag| | |
| 101 // is true, the view does not accept first responder status and instead | |
| 102 // manually becomes first responder when it receives a mouse down event. If | |
| 103 // |flag| is false, the view participates in the key-view chain as normal. | |
| 104 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) = 0; | |
| 105 | |
| 106 // Notifies the view that its enclosing window has changed visibility | |
| 107 // (minimized/unminimized, app hidden/unhidden, etc). | |
| 108 // TODO(stuartmorgan): This is a temporary plugin-specific workaround for | |
| 109 // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding | |
| 110 // message and renderer-side handling) can be removed in favor of using | |
| 111 // WasHidden/DidBecomeSelected. | |
| 112 virtual void SetWindowVisibility(bool visible) = 0; | |
| 113 | |
| 114 // Informs the view that its containing window's frame changed. | |
| 115 virtual void WindowFrameChanged() = 0; | |
| 116 #endif // defined(OS_MACOSX) | |
| 117 | |
| 118 #if defined(TOOLKIT_USES_GTK) | |
| 119 // Gets the event for the last mouse down. | |
| 120 virtual GdkEventButton* GetLastMouseDown() = 0; | |
| 121 #if !defined(TOOLKIT_VIEWS) | |
| 122 // Builds a submenu containing all the gtk input method commands. | |
| 123 virtual gfx::NativeView BuildInputMethodsGtkMenu() = 0; | |
| 124 #endif // !defined(TOOLKIT_VIEWS) | |
| 125 #endif // defined(TOOLKIT_USES_GTK) | |
| 126 | |
| 127 // TODO(joi): May be able to move into impl if RWHVMacDelegate stops | |
| 128 // being exposed to Chrome. | |
| 129 virtual void UnhandledWheelEvent(const WebKit::WebMouseWheelEvent& event) = 0; | |
| 130 | |
| 131 // Subclasses should override this method to do what is appropriate to set | |
| 132 // the custom background for their platform. | |
| 133 virtual void SetBackground(const SkBitmap& background) = 0; | |
| 134 virtual const SkBitmap& GetBackground() = 0; | |
| 135 | |
| 136 // TODO(joi): Remove this when we remove the dependency by chrome/ | |
| 137 // on browser_accessibility* files in content. | |
| 138 virtual BrowserAccessibilityManager* | |
| 139 GetBrowserAccessibilityManager() const = 0; | |
| 140 | |
| 141 private: | |
| 142 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostView); | |
|
jam
2012/02/15 17:02:19
ditto
Jói
2012/02/16 12:41:42
Done.
| |
| 143 }; | |
| 144 | |
| 145 #endif // CONTENT_PUBLIC_BROWSER_RENDER_WIDGET_HOST_VIEW_H_ | |
| 146 | |
| 147 | |
| OLD | NEW |