| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_WIN_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_WIN_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_WIN_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_WIN_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "base/win/win_util.h" | 11 #include "base/win/win_util.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/port/browser/render_view_host_delegate_view.h" | 13 #include "content/port/browser/render_view_host_delegate_view.h" |
| 14 #include "content/public/browser/web_contents_view.h" | 14 #include "content/public/browser/web_contents_view.h" |
| 15 #include "ui/base/win/window_impl.h" | 15 #include "ui/base/win/window_impl.h" |
| 16 | 16 |
| 17 class WebDragDest; | 17 class WebDragDest; |
| 18 class WebContentsDragWin; | 18 class WebContentsDragWin; |
| 19 class WebContentsImpl; | |
| 20 | |
| 21 namespace content { | |
| 22 class RenderWidgetHostViewWin; | |
| 23 class WebContentsViewDelegate; | |
| 24 } | |
| 25 | 19 |
| 26 namespace ui { | 20 namespace ui { |
| 27 class HWNDMessageFilter; | 21 class HWNDMessageFilter; |
| 28 } | 22 } |
| 29 | 23 |
| 24 namespace content { |
| 25 class RenderWidgetHostViewWin; |
| 26 class WebContentsViewDelegate; |
| 27 class WebContentsImpl; |
| 28 |
| 30 // An implementation of WebContentsView for Windows. | 29 // An implementation of WebContentsView for Windows. |
| 31 class CONTENT_EXPORT WebContentsViewWin | 30 class CONTENT_EXPORT WebContentsViewWin |
| 32 : public content::WebContentsView, | 31 : public WebContentsView, |
| 33 public content::RenderViewHostDelegateView, | 32 public RenderViewHostDelegateView, |
| 34 public ui::WindowImpl { | 33 public ui::WindowImpl { |
| 35 public: | 34 public: |
| 36 WebContentsViewWin(WebContentsImpl* web_contents, | 35 WebContentsViewWin(WebContentsImpl* web_contents, |
| 37 content::WebContentsViewDelegate* delegate); | 36 WebContentsViewDelegate* delegate); |
| 38 virtual ~WebContentsViewWin(); | 37 virtual ~WebContentsViewWin(); |
| 39 | 38 |
| 40 BEGIN_MSG_MAP_EX(WebContentsViewWin) | 39 BEGIN_MSG_MAP_EX(WebContentsViewWin) |
| 41 MESSAGE_HANDLER(WM_CREATE, OnCreate) | 40 MESSAGE_HANDLER(WM_CREATE, OnCreate) |
| 42 MESSAGE_HANDLER(WM_DESTROY, OnDestroy) | 41 MESSAGE_HANDLER(WM_DESTROY, OnDestroy) |
| 43 MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged) | 42 MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged) |
| 44 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnMouseDown) | 43 MESSAGE_HANDLER(WM_LBUTTONDOWN, OnMouseDown) |
| 45 MESSAGE_HANDLER(WM_MBUTTONDOWN, OnMouseDown) | 44 MESSAGE_HANDLER(WM_MBUTTONDOWN, OnMouseDown) |
| 46 MESSAGE_HANDLER(WM_RBUTTONDOWN, OnMouseDown) | 45 MESSAGE_HANDLER(WM_RBUTTONDOWN, OnMouseDown) |
| 47 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) | 46 MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) |
| 48 MESSAGE_HANDLER(base::win::kReflectedMessage, OnReflectedMessage) | 47 MESSAGE_HANDLER(base::win::kReflectedMessage, OnReflectedMessage) |
| 49 // Hacks for old ThinkPad touchpads/scroll points. | 48 // Hacks for old ThinkPad touchpads/scroll points. |
| 50 MESSAGE_HANDLER(WM_NCCALCSIZE, OnNCCalcSize) | 49 MESSAGE_HANDLER(WM_NCCALCSIZE, OnNCCalcSize) |
| 51 MESSAGE_HANDLER(WM_NCHITTEST, OnNCHitTest) | 50 MESSAGE_HANDLER(WM_NCHITTEST, OnNCHitTest) |
| 52 MESSAGE_HANDLER(WM_HSCROLL, OnScroll) | 51 MESSAGE_HANDLER(WM_HSCROLL, OnScroll) |
| 53 MESSAGE_HANDLER(WM_VSCROLL, OnScroll) | 52 MESSAGE_HANDLER(WM_VSCROLL, OnScroll) |
| 54 MESSAGE_HANDLER(WM_SIZE, OnSize) | 53 MESSAGE_HANDLER(WM_SIZE, OnSize) |
| 55 END_MSG_MAP() | 54 END_MSG_MAP() |
| 56 | 55 |
| 57 // Overridden from WebContentsView: | 56 // Overridden from WebContentsView: |
| 58 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; | 57 virtual void CreateView(const gfx::Size& initial_size) OVERRIDE; |
| 59 virtual content::RenderWidgetHostView* CreateViewForWidget( | 58 virtual RenderWidgetHostView* CreateViewForWidget( |
| 60 content::RenderWidgetHost* render_widget_host) OVERRIDE; | 59 RenderWidgetHost* render_widget_host) OVERRIDE; |
| 61 virtual gfx::NativeView GetNativeView() const OVERRIDE; | 60 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 62 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; | 61 virtual gfx::NativeView GetContentNativeView() const OVERRIDE; |
| 63 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; | 62 virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE; |
| 64 virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE; | 63 virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE; |
| 65 virtual void SetPageTitle(const string16& title) OVERRIDE; | 64 virtual void SetPageTitle(const string16& title) OVERRIDE; |
| 66 virtual void OnTabCrashed(base::TerminationStatus status, | 65 virtual void OnTabCrashed(base::TerminationStatus status, |
| 67 int error_code) OVERRIDE; | 66 int error_code) OVERRIDE; |
| 68 virtual void SizeContents(const gfx::Size& size) OVERRIDE; | 67 virtual void SizeContents(const gfx::Size& size) OVERRIDE; |
| 69 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; | 68 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; |
| 70 virtual void Focus() OVERRIDE; | 69 virtual void Focus() OVERRIDE; |
| 71 virtual void SetInitialFocus() OVERRIDE; | 70 virtual void SetInitialFocus() OVERRIDE; |
| 72 virtual void StoreFocus() OVERRIDE; | 71 virtual void StoreFocus() OVERRIDE; |
| 73 virtual void RestoreFocus() OVERRIDE; | 72 virtual void RestoreFocus() OVERRIDE; |
| 74 virtual WebDropData* GetDropData() const OVERRIDE; | 73 virtual WebDropData* GetDropData() const OVERRIDE; |
| 75 virtual bool IsEventTracking() const OVERRIDE; | 74 virtual bool IsEventTracking() const OVERRIDE; |
| 76 virtual void CloseTabAfterEventTracking() OVERRIDE; | 75 virtual void CloseTabAfterEventTracking() OVERRIDE; |
| 77 virtual gfx::Rect GetViewBounds() const OVERRIDE; | 76 virtual gfx::Rect GetViewBounds() const OVERRIDE; |
| 78 | 77 |
| 79 // Implementation of RenderViewHostDelegateView. | 78 // Implementation of RenderViewHostDelegateView. |
| 80 virtual void ShowContextMenu( | 79 virtual void ShowContextMenu( |
| 81 const content::ContextMenuParams& params, | 80 const ContextMenuParams& params, |
| 82 content::ContextMenuSourceType type) OVERRIDE; | 81 ContextMenuSourceType type) OVERRIDE; |
| 83 virtual void ShowPopupMenu(const gfx::Rect& bounds, | 82 virtual void ShowPopupMenu(const gfx::Rect& bounds, |
| 84 int item_height, | 83 int item_height, |
| 85 double item_font_size, | 84 double item_font_size, |
| 86 int selected_item, | 85 int selected_item, |
| 87 const std::vector<WebMenuItem>& items, | 86 const std::vector<WebMenuItem>& items, |
| 88 bool right_aligned, | 87 bool right_aligned, |
| 89 bool allow_multiple_selection) OVERRIDE; | 88 bool allow_multiple_selection) OVERRIDE; |
| 90 virtual void StartDragging(const WebDropData& drop_data, | 89 virtual void StartDragging(const WebDropData& drop_data, |
| 91 WebKit::WebDragOperationsMask operations, | 90 WebKit::WebDragOperationsMask operations, |
| 92 const gfx::ImageSkia& image, | 91 const gfx::ImageSkia& image, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 120 LRESULT OnScroll( | 119 LRESULT OnScroll( |
| 121 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); | 120 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); |
| 122 LRESULT OnSize( | 121 LRESULT OnSize( |
| 123 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); | 122 UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); |
| 124 | 123 |
| 125 gfx::Size initial_size_; | 124 gfx::Size initial_size_; |
| 126 | 125 |
| 127 // The WebContentsImpl whose contents we display. | 126 // The WebContentsImpl whose contents we display. |
| 128 WebContentsImpl* web_contents_; | 127 WebContentsImpl* web_contents_; |
| 129 | 128 |
| 130 content::RenderWidgetHostViewWin* view_; | 129 RenderWidgetHostViewWin* view_; |
| 131 | 130 |
| 132 scoped_ptr<content::WebContentsViewDelegate> delegate_; | 131 scoped_ptr<WebContentsViewDelegate> delegate_; |
| 133 | 132 |
| 134 // The helper object that handles drag destination related interactions with | 133 // The helper object that handles drag destination related interactions with |
| 135 // Windows. | 134 // Windows. |
| 136 scoped_refptr<WebDragDest> drag_dest_; | 135 scoped_refptr<WebDragDest> drag_dest_; |
| 137 | 136 |
| 138 // Used to handle the drag-and-drop. | 137 // Used to handle the drag-and-drop. |
| 139 scoped_refptr<WebContentsDragWin> drag_handler_; | 138 scoped_refptr<WebContentsDragWin> drag_handler_; |
| 140 | 139 |
| 141 scoped_ptr<ui::HWNDMessageFilter> hwnd_message_filter_; | 140 scoped_ptr<ui::HWNDMessageFilter> hwnd_message_filter_; |
| 142 | 141 |
| 143 DISALLOW_COPY_AND_ASSIGN(WebContentsViewWin); | 142 DISALLOW_COPY_AND_ASSIGN(WebContentsViewWin); |
| 144 }; | 143 }; |
| 145 | 144 |
| 145 } // namespace content |
| 146 |
| 146 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_WIN_H_ | 147 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_WIN_H_ |
| OLD | NEW |