| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_WEB_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_WEB_CONTENTS_VIEW_H_ |
| 6 #define CHROME_BROWSER_WEB_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_WEB_CONTENTS_VIEW_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/gfx/rect.h" | 14 #include "base/gfx/rect.h" |
| 15 #include "base/gfx/size.h" | 15 #include "base/gfx/size.h" |
| 16 #include "chrome/browser/render_view_host_delegate.h" | 16 #include "chrome/browser/render_view_host_delegate.h" |
| 17 | 17 |
| 18 class InfoBarView; | 18 class InfoBarView; |
| 19 class RenderViewHost; | 19 class RenderViewHost; |
| 20 class RenderWidgetHost; | 20 class RenderWidgetHost; |
| 21 class RenderWidgetHostView; | 21 class RenderWidgetHostView; |
| 22 class RenderWidgetHostViewWin; // TODO(brettw) this should not be necessary. | 22 class RenderWidgetHostViewWin; // TODO(brettw) this should not be necessary. |
| 23 struct ViewHostMsg_ContextMenu_Params; | |
| 24 class WebContents; | 23 class WebContents; |
| 25 struct WebDropData; | 24 struct WebDropData; |
| 26 class WebKeyboardEvent; | 25 class WebKeyboardEvent; |
| 27 | 26 |
| 28 // The WebContentsView is an interface that is implemented by the platform- | 27 // The WebContentsView is an interface that is implemented by the platform- |
| 29 // dependent web contents views. The WebContents uses this interface to talk to | 28 // dependent web contents views. The WebContents uses this interface to talk to |
| 30 // them. View-related messages will also get forwarded directly to this class | 29 // them. View-related messages will also get forwarded directly to this class |
| 31 // from RenderViewHost via RenderViewHostDelegate::View. | 30 // from RenderViewHost via RenderViewHostDelegate::View. |
| 32 // | 31 // |
| 33 // It contains a small amount of logic with respect to creating new sub-view | 32 // It contains a small amount of logic with respect to creating new sub-view |
| (...skipping 27 matching lines...) Expand all Loading... |
| 61 virtual void GetContainerBounds(gfx::Rect *out) const = 0; | 60 virtual void GetContainerBounds(gfx::Rect *out) const = 0; |
| 62 | 61 |
| 63 // Helper function for GetContainerBounds. Most callers just want to know the | 62 // Helper function for GetContainerBounds. Most callers just want to know the |
| 64 // size, and this makes it more clear. | 63 // size, and this makes it more clear. |
| 65 gfx::Size GetContainerSize() const { | 64 gfx::Size GetContainerSize() const { |
| 66 gfx::Rect rc; | 65 gfx::Rect rc; |
| 67 GetContainerBounds(&rc); | 66 GetContainerBounds(&rc); |
| 68 return gfx::Size(rc.width(), rc.height()); | 67 return gfx::Size(rc.width(), rc.height()); |
| 69 } | 68 } |
| 70 | 69 |
| 71 // The user started dragging content of the specified type within the tab. | |
| 72 // Contextual information about the dragged content is supplied by drop_data. | |
| 73 virtual void StartDragging(const WebDropData& drop_data) = 0; | |
| 74 | |
| 75 // Enumerate and 'un-parent' any plugin windows that are children of us. | 70 // Enumerate and 'un-parent' any plugin windows that are children of us. |
| 76 virtual void DetachPluginWindows() = 0; | 71 virtual void DetachPluginWindows() = 0; |
| 77 | 72 |
| 78 // Displays the given error in the info bar. A new info bar will be shown if | 73 // Displays the given error in the info bar. A new info bar will be shown if |
| 79 // one is not shown already. The new error text will replace any existing | 74 // one is not shown already. The new error text will replace any existing |
| 80 // text shown by this same function. | 75 // text shown by this same function. |
| 81 // | 76 // |
| 82 // Note: this replacement behavior is historical; crashed plugin and out of | 77 // Note: this replacement behavior is historical; crashed plugin and out of |
| 83 // JS memory used the same message. This seems reasonable, but it may not be | 78 // JS memory used the same message. This seems reasonable, but it may not be |
| 84 // the best thing for all error messages. | 79 // the best thing for all error messages. |
| 85 virtual void DisplayErrorInInfoBar(const std::wstring& text) = 0; | 80 virtual void DisplayErrorInInfoBar(const std::wstring& text) = 0; |
| 86 | 81 |
| 87 // Set/get whether or not the info bar is visible. See also the ChromeFrame | 82 // Set/get whether or not the info bar is visible. See also the ChromeFrame |
| 88 // method InfoBarVisibilityChanged and TabContents::IsInfoBarVisible. | 83 // method InfoBarVisibilityChanged and TabContents::IsInfoBarVisible. |
| 89 virtual void SetInfoBarVisible(bool visible) = 0; | 84 virtual void SetInfoBarVisible(bool visible) = 0; |
| 90 virtual bool IsInfoBarVisible() const = 0; | 85 virtual bool IsInfoBarVisible() const = 0; |
| 91 | 86 |
| 92 // Create the InfoBarView and returns it if none has been created. | 87 // Create the InfoBarView and returns it if none has been created. |
| 93 // Just returns existing InfoBarView if it is already created. | 88 // Just returns existing InfoBarView if it is already created. |
| 94 // TODO(brettw) this probably shouldn't be here. There should be methods to | 89 // TODO(brettw) this probably shouldn't be here. There should be methods to |
| 95 // tell us what we need to display instead. | 90 // tell us what we need to display instead. |
| 96 virtual InfoBarView* GetInfoBarView() = 0; | 91 virtual InfoBarView* GetInfoBarView() = 0; |
| 97 | 92 |
| 98 // The page wants to update the mouse cursor during a drag & drop operation. | 93 // Sets the page title for the native widgets corresponding to the view. This |
| 99 // |is_drop_target| is true if the mouse is over a valid drop target. | 94 // is not strictly necessary and isn't expected to be displayed anywhere, but |
| 100 virtual void UpdateDragCursor(bool is_drop_target) = 0; | 95 // can aid certain debugging tools such as Spy++ on Windows where you are |
| 96 // trying to find a specific window. |
| 97 virtual void SetPageTitle(const std::wstring& title) = 0; |
| 101 | 98 |
| 102 // Runs a context menu with the given parameters from the renderer. | 99 // Schedules a complete repaint of the window. This is used for cases where |
| 103 virtual void ShowContextMenu( | 100 // the existing contents became invalid due to an external event, such as the |
| 104 const ViewHostMsg_ContextMenu_Params& params) = 0; | 101 // renderer crashing. |
| 105 | 102 virtual void Invalidate() = 0; |
| 106 // Posts the given keyboard message and handles it in the native way. This | |
| 107 // is called when the renderer reflects a keyboard message back up to us for | |
| 108 // default handling. | |
| 109 virtual void HandleKeyboardEvent(const WebKeyboardEvent& event) = 0; | |
| 110 | 103 |
| 111 protected: | 104 protected: |
| 112 WebContentsView() {} // Abstract interface. | 105 WebContentsView() {} // Abstract interface. |
| 113 | 106 |
| 114 // Internal interface for the RenderViewHostDelegate::View interface. | 107 // Internal interface for some functions in the RenderViewHostDelegate::View |
| 115 // Subclasses should implement this rather thank ...::View directly, since the | 108 // interface. Subclasses should implement this rather than the corresponding |
| 116 // routing stuff will already be computed. | 109 // ...::View functions directly, since the routing stuff will already be |
| 110 // computed. They should implement the rest of the functions as normal. |
| 117 // | 111 // |
| 118 // The only difference is that the Create functions return the newly | 112 // The only difference is that the Create functions return the newly |
| 119 // created objects so that they can be associated with the given routes. When | 113 // created objects so that they can be associated with the given routes. When |
| 120 // they are shown later, we'll look them up again and pass the objects to | 114 // they are shown later, we'll look them up again and pass the objects to |
| 121 // the Show functions rather than the route ID. | 115 // the Show functions rather than the route ID. |
| 122 virtual WebContents* CreateNewWindowInternal(int route_id, | 116 virtual WebContents* CreateNewWindowInternal(int route_id, |
| 123 HANDLE modal_dialog_event) = 0; | 117 HANDLE modal_dialog_event) = 0; |
| 124 virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id) = 0; | 118 virtual RenderWidgetHostView* CreateNewWidgetInternal(int route_id) = 0; |
| 125 virtual void ShowCreatedWindowInternal(WebContents* new_web_contents, | 119 virtual void ShowCreatedWindowInternal(WebContents* new_web_contents, |
| 126 WindowOpenDisposition disposition, | 120 WindowOpenDisposition disposition, |
| 127 const gfx::Rect& initial_pos, | 121 const gfx::Rect& initial_pos, |
| 128 bool user_gesture) = 0; | 122 bool user_gesture) = 0; |
| 129 virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, | 123 virtual void ShowCreatedWidgetInternal(RenderWidgetHostView* widget_host_view, |
| 130 const gfx::Rect& initial_pos) = 0; | 124 const gfx::Rect& initial_pos) = 0; |
| 131 | 125 |
| 132 private: | 126 private: |
| 133 // We implement RenderViewHostDelegate::View directly and do some book-keeping | 127 // We implement these functions on RenderViewHostDelegate::View directly and |
| 134 // associated with the request. The request is then forwarded to *Internal | 128 // do some book-keeping associated with the request. The request is then |
| 135 // which does platform-specific work. | 129 // forwarded to *Internal which does platform-specific work. |
| 136 virtual void CreateNewWindow(int route_id, HANDLE modal_dialog_event); | 130 virtual void CreateNewWindow(int route_id, HANDLE modal_dialog_event); |
| 137 virtual void CreateNewWidget(int route_id); | 131 virtual void CreateNewWidget(int route_id); |
| 138 virtual void ShowCreatedWindow(int route_id, | 132 virtual void ShowCreatedWindow(int route_id, |
| 139 WindowOpenDisposition disposition, | 133 WindowOpenDisposition disposition, |
| 140 const gfx::Rect& initial_pos, | 134 const gfx::Rect& initial_pos, |
| 141 bool user_gesture); | 135 bool user_gesture); |
| 142 virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); | 136 virtual void ShowCreatedWidget(int route_id, const gfx::Rect& initial_pos); |
| 143 | 137 |
| 144 // Tracks created WebContents objects that have not been shown yet. They are | 138 // Tracks created WebContents objects that have not been shown yet. They are |
| 145 // identified by the route ID passed to CreateNewWindow. | 139 // identified by the route ID passed to CreateNewWindow. |
| 146 typedef std::map<int, WebContents*> PendingContents; | 140 typedef std::map<int, WebContents*> PendingContents; |
| 147 PendingContents pending_contents_; | 141 PendingContents pending_contents_; |
| 148 | 142 |
| 149 // These maps hold on to the widgets that we created on behalf of the | 143 // These maps hold on to the widgets that we created on behalf of the |
| 150 // renderer that haven't shown yet. | 144 // renderer that haven't shown yet. |
| 151 typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews; | 145 typedef std::map<int, RenderWidgetHostView*> PendingWidgetViews; |
| 152 PendingWidgetViews pending_widget_views_; | 146 PendingWidgetViews pending_widget_views_; |
| 153 | 147 |
| 154 DISALLOW_COPY_AND_ASSIGN(WebContentsView); | 148 DISALLOW_COPY_AND_ASSIGN(WebContentsView); |
| 155 }; | 149 }; |
| 156 | 150 |
| 157 #endif // CHROME_BROWSER_WEB_CONTENTS_VIEW_H_ | 151 #endif // CHROME_BROWSER_WEB_CONTENTS_VIEW_H_ |
| OLD | NEW |