| 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_DRAG_DEST_WIN_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
| 11 #include "ui/base/dragdrop/drop_target.h" | 11 #include "ui/base/dragdrop/drop_target.h" |
| 12 #include "webkit/glue/webdropdata.h" | 12 #include "webkit/glue/webdropdata.h" |
| 13 | 13 |
| 14 namespace content { |
| 14 class InterstitialDropTarget; | 15 class InterstitialDropTarget; |
| 15 | |
| 16 namespace content { | |
| 17 class RenderViewHost; | 16 class RenderViewHost; |
| 18 class WebContents; | 17 class WebContents; |
| 19 class WebDragDestDelegate; | 18 class WebDragDestDelegate; |
| 20 } | |
| 21 | 19 |
| 22 // A helper object that provides drop capabilities to a WebContentsImpl. The | 20 // A helper object that provides drop capabilities to a WebContentsImpl. The |
| 23 // DropTarget handles drags that enter the region of the WebContents by | 21 // DropTarget handles drags that enter the region of the WebContents by |
| 24 // passing on the events to the renderer. | 22 // passing on the events to the renderer. |
| 25 class CONTENT_EXPORT WebDragDest : public ui::DropTarget { | 23 class CONTENT_EXPORT WebDragDest : public ui::DropTarget { |
| 26 public: | 24 public: |
| 27 // Create a new WebDragDest associating it with the given HWND and | 25 // Create a new WebDragDest associating it with the given HWND and |
| 28 // WebContents. | 26 // WebContents. |
| 29 WebDragDest(HWND source_hwnd, content::WebContents* contents); | 27 WebDragDest(HWND source_hwnd, WebContents* contents); |
| 30 virtual ~WebDragDest(); | 28 virtual ~WebDragDest(); |
| 31 | 29 |
| 32 WebDropData* current_drop_data() const { return drop_data_.get(); } | 30 WebDropData* current_drop_data() const { return drop_data_.get(); } |
| 33 | 31 |
| 34 void set_drag_cursor(WebKit::WebDragOperation op) { | 32 void set_drag_cursor(WebKit::WebDragOperation op) { |
| 35 drag_cursor_ = op; | 33 drag_cursor_ = op; |
| 36 } | 34 } |
| 37 | 35 |
| 38 content::WebDragDestDelegate* delegate() const { return delegate_; } | 36 WebDragDestDelegate* delegate() const { return delegate_; } |
| 39 void set_delegate(content::WebDragDestDelegate* d) { delegate_ = d; } | 37 void set_delegate(WebDragDestDelegate* d) { delegate_ = d; } |
| 40 | 38 |
| 41 protected: | 39 protected: |
| 42 virtual DWORD OnDragEnter(IDataObject* data_object, | 40 virtual DWORD OnDragEnter(IDataObject* data_object, |
| 43 DWORD key_state, | 41 DWORD key_state, |
| 44 POINT cursor_position, | 42 POINT cursor_position, |
| 45 DWORD effect); | 43 DWORD effect); |
| 46 | 44 |
| 47 virtual DWORD OnDragOver(IDataObject* data_object, | 45 virtual DWORD OnDragOver(IDataObject* data_object, |
| 48 DWORD key_state, | 46 DWORD key_state, |
| 49 POINT cursor_position, | 47 POINT cursor_position, |
| 50 DWORD effect); | 48 DWORD effect); |
| 51 | 49 |
| 52 virtual void OnDragLeave(IDataObject* data_object); | 50 virtual void OnDragLeave(IDataObject* data_object); |
| 53 | 51 |
| 54 virtual DWORD OnDrop(IDataObject* data_object, | 52 virtual DWORD OnDrop(IDataObject* data_object, |
| 55 DWORD key_state, | 53 DWORD key_state, |
| 56 POINT cursor_position, | 54 POINT cursor_position, |
| 57 DWORD effect); | 55 DWORD effect); |
| 58 | 56 |
| 59 private: | 57 private: |
| 60 // Our associated WebContents. | 58 // Our associated WebContents. |
| 61 content::WebContents* web_contents_; | 59 WebContents* web_contents_; |
| 62 | 60 |
| 63 // We keep track of the render view host we're dragging over. If it changes | 61 // We keep track of the render view host we're dragging over. If it changes |
| 64 // during a drag, we need to re-send the DragEnter message. WARNING: | 62 // during a drag, we need to re-send the DragEnter message. WARNING: |
| 65 // this pointer should never be dereferenced. We only use it for comparing | 63 // this pointer should never be dereferenced. We only use it for comparing |
| 66 // pointers. | 64 // pointers. |
| 67 content::RenderViewHost* current_rvh_; | 65 RenderViewHost* current_rvh_; |
| 68 | 66 |
| 69 // Used to determine what cursor we should display when dragging over web | 67 // Used to determine what cursor we should display when dragging over web |
| 70 // content area. This can be updated async during a drag operation. | 68 // content area. This can be updated async during a drag operation. |
| 71 WebKit::WebDragOperation drag_cursor_; | 69 WebKit::WebDragOperation drag_cursor_; |
| 72 | 70 |
| 73 // A special drop target handler for when we try to d&d while an interstitial | 71 // A special drop target handler for when we try to d&d while an interstitial |
| 74 // page is showing. | 72 // page is showing. |
| 75 scoped_ptr<InterstitialDropTarget> interstitial_drop_target_; | 73 scoped_ptr<InterstitialDropTarget> interstitial_drop_target_; |
| 76 | 74 |
| 77 // A delegate that can receive drag information about drag events. | 75 // A delegate that can receive drag information about drag events. |
| 78 content::WebDragDestDelegate* delegate_; | 76 WebDragDestDelegate* delegate_; |
| 79 | 77 |
| 80 // The data for the current drag, or NULL if |context_| is NULL. | 78 // The data for the current drag, or NULL if |context_| is NULL. |
| 81 scoped_ptr<WebDropData> drop_data_; | 79 scoped_ptr<WebDropData> drop_data_; |
| 82 | 80 |
| 83 DISALLOW_COPY_AND_ASSIGN(WebDragDest); | 81 DISALLOW_COPY_AND_ASSIGN(WebDragDest); |
| 84 }; | 82 }; |
| 85 | 83 |
| 84 } // namespace content |
| 85 |
| 86 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_ | 86 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_DEST_WIN_H_ |
| OLD | NEW |