| 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_DRAG_WIN_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 public base::RefCountedThreadSafe<WebContentsDragWin> { | 39 public base::RefCountedThreadSafe<WebContentsDragWin> { |
| 40 public: | 40 public: |
| 41 WebContentsDragWin(gfx::NativeWindow source_window, | 41 WebContentsDragWin(gfx::NativeWindow source_window, |
| 42 WebContents* web_contents, | 42 WebContents* web_contents, |
| 43 WebDragDest* drag_dest, | 43 WebDragDest* drag_dest, |
| 44 const base::Callback<void()>& drag_end_callback); | 44 const base::Callback<void()>& drag_end_callback); |
| 45 virtual ~WebContentsDragWin(); | 45 virtual ~WebContentsDragWin(); |
| 46 | 46 |
| 47 // Called on UI thread. | 47 // Called on UI thread. |
| 48 void StartDragging(const DropData& drop_data, | 48 void StartDragging(const DropData& drop_data, |
| 49 WebKit::WebDragOperationsMask ops, | 49 blink::WebDragOperationsMask ops, |
| 50 const gfx::ImageSkia& image, | 50 const gfx::ImageSkia& image, |
| 51 const gfx::Vector2d& image_offset); | 51 const gfx::Vector2d& image_offset); |
| 52 void CancelDrag(); | 52 void CancelDrag(); |
| 53 | 53 |
| 54 // DataObjectImpl::Observer implementation. | 54 // DataObjectImpl::Observer implementation. |
| 55 // Called on drag-and-drop thread. | 55 // Called on drag-and-drop thread. |
| 56 virtual void OnWaitForData(); | 56 virtual void OnWaitForData(); |
| 57 virtual void OnDataObjectDisposed(); | 57 virtual void OnDataObjectDisposed(); |
| 58 | 58 |
| 59 // Don't invoke OLE DoDragDrop during tests. | 59 // Don't invoke OLE DoDragDrop during tests. |
| 60 static void DisableDragDropForTesting(); | 60 static void DisableDragDropForTesting(); |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Called on either UI thread or drag-and-drop thread. | 63 // Called on either UI thread or drag-and-drop thread. |
| 64 void PrepareDragForDownload(const DropData& drop_data, | 64 void PrepareDragForDownload(const DropData& drop_data, |
| 65 ui::OSExchangeData* data, | 65 ui::OSExchangeData* data, |
| 66 const GURL& page_url, | 66 const GURL& page_url, |
| 67 const std::string& page_encoding); | 67 const std::string& page_encoding); |
| 68 void PrepareDragForFileContents(const DropData& drop_data, | 68 void PrepareDragForFileContents(const DropData& drop_data, |
| 69 ui::OSExchangeData* data); | 69 ui::OSExchangeData* data); |
| 70 void PrepareDragForUrl(const DropData& drop_data, | 70 void PrepareDragForUrl(const DropData& drop_data, |
| 71 ui::OSExchangeData* data); | 71 ui::OSExchangeData* data); |
| 72 // Returns false if the source window becomes invalid when the drag ends. | 72 // Returns false if the source window becomes invalid when the drag ends. |
| 73 // This could happen when the window gets destroyed when the drag is still in | 73 // This could happen when the window gets destroyed when the drag is still in |
| 74 // progress. No further processing should be done beyond this return point | 74 // progress. No further processing should be done beyond this return point |
| 75 // because the instance has been destroyed. | 75 // because the instance has been destroyed. |
| 76 bool DoDragging(const DropData& drop_data, | 76 bool DoDragging(const DropData& drop_data, |
| 77 WebKit::WebDragOperationsMask ops, | 77 blink::WebDragOperationsMask ops, |
| 78 const GURL& page_url, | 78 const GURL& page_url, |
| 79 const std::string& page_encoding, | 79 const std::string& page_encoding, |
| 80 const gfx::ImageSkia& image, | 80 const gfx::ImageSkia& image, |
| 81 const gfx::Vector2d& image_offset); | 81 const gfx::Vector2d& image_offset); |
| 82 | 82 |
| 83 // Called on drag-and-drop thread. | 83 // Called on drag-and-drop thread. |
| 84 void StartBackgroundDragging(const DropData& drop_data, | 84 void StartBackgroundDragging(const DropData& drop_data, |
| 85 WebKit::WebDragOperationsMask ops, | 85 blink::WebDragOperationsMask ops, |
| 86 const GURL& page_url, | 86 const GURL& page_url, |
| 87 const std::string& page_encoding, | 87 const std::string& page_encoding, |
| 88 const gfx::ImageSkia& image, | 88 const gfx::ImageSkia& image, |
| 89 const gfx::Vector2d& image_offset); | 89 const gfx::Vector2d& image_offset); |
| 90 // Called on UI thread. | 90 // Called on UI thread. |
| 91 void EndDragging(); | 91 void EndDragging(); |
| 92 void CloseThread(); | 92 void CloseThread(); |
| 93 | 93 |
| 94 // For debug check only. Access only on drag-and-drop thread. | 94 // For debug check only. Access only on drag-and-drop thread. |
| 95 base::PlatformThreadId drag_drop_thread_id_; | 95 base::PlatformThreadId drag_drop_thread_id_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 113 bool drag_ended_; | 113 bool drag_ended_; |
| 114 | 114 |
| 115 base::Callback<void()> drag_end_callback_; | 115 base::Callback<void()> drag_end_callback_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(WebContentsDragWin); | 117 DISALLOW_COPY_AND_ASSIGN(WebContentsDragWin); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace content | 120 } // namespace content |
| 121 | 121 |
| 122 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ | 122 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ |
| OLD | NEW |