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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 WebContentsDragWin(gfx::NativeWindow source_window, | 42 WebContentsDragWin(gfx::NativeWindow source_window, |
43 content::WebContents* web_contents, | 43 content::WebContents* web_contents, |
44 WebDragDest* drag_dest, | 44 WebDragDest* drag_dest, |
45 const base::Callback<void()>& drag_end_callback); | 45 const base::Callback<void()>& drag_end_callback); |
46 virtual ~WebContentsDragWin(); | 46 virtual ~WebContentsDragWin(); |
47 | 47 |
48 // Called on UI thread. | 48 // Called on UI thread. |
49 void StartDragging(const WebDropData& drop_data, | 49 void StartDragging(const WebDropData& drop_data, |
50 WebKit::WebDragOperationsMask ops, | 50 WebKit::WebDragOperationsMask ops, |
51 const gfx::ImageSkia& image, | 51 const gfx::ImageSkia& image, |
52 const gfx::Point& image_offset); | 52 const gfx::Vector2d& image_offset); |
53 void CancelDrag(); | 53 void CancelDrag(); |
54 | 54 |
55 // DataObjectImpl::Observer implementation. | 55 // DataObjectImpl::Observer implementation. |
56 // Called on drag-and-drop thread. | 56 // Called on drag-and-drop thread. |
57 virtual void OnWaitForData(); | 57 virtual void OnWaitForData(); |
58 virtual void OnDataObjectDisposed(); | 58 virtual void OnDataObjectDisposed(); |
59 | 59 |
60 private: | 60 private: |
61 // Called on either UI thread or drag-and-drop thread. | 61 // Called on either UI thread or drag-and-drop thread. |
62 void PrepareDragForDownload(const WebDropData& drop_data, | 62 void PrepareDragForDownload(const WebDropData& drop_data, |
63 ui::OSExchangeData* data, | 63 ui::OSExchangeData* data, |
64 const GURL& page_url, | 64 const GURL& page_url, |
65 const std::string& page_encoding); | 65 const std::string& page_encoding); |
66 void PrepareDragForFileContents(const WebDropData& drop_data, | 66 void PrepareDragForFileContents(const WebDropData& drop_data, |
67 ui::OSExchangeData* data); | 67 ui::OSExchangeData* data); |
68 void PrepareDragForUrl(const WebDropData& drop_data, | 68 void PrepareDragForUrl(const WebDropData& drop_data, |
69 ui::OSExchangeData* data); | 69 ui::OSExchangeData* data); |
70 // Returns false if the source window becomes invalid when the drag ends. | 70 // Returns false if the source window becomes invalid when the drag ends. |
71 // This could happen when the window gets destroyed when the drag is still in | 71 // This could happen when the window gets destroyed when the drag is still in |
72 // progress. No further processing should be done beyond this return point | 72 // progress. No further processing should be done beyond this return point |
73 // because the instance has been destroyed. | 73 // because the instance has been destroyed. |
74 bool DoDragging(const WebDropData& drop_data, | 74 bool DoDragging(const WebDropData& drop_data, |
75 WebKit::WebDragOperationsMask ops, | 75 WebKit::WebDragOperationsMask ops, |
76 const GURL& page_url, | 76 const GURL& page_url, |
77 const std::string& page_encoding, | 77 const std::string& page_encoding, |
78 const gfx::ImageSkia& image, | 78 const gfx::ImageSkia& image, |
79 const gfx::Point& image_offset); | 79 const gfx::Vector2d& image_offset); |
80 | 80 |
81 // Called on drag-and-drop thread. | 81 // Called on drag-and-drop thread. |
82 void StartBackgroundDragging(const WebDropData& drop_data, | 82 void StartBackgroundDragging(const WebDropData& drop_data, |
83 WebKit::WebDragOperationsMask ops, | 83 WebKit::WebDragOperationsMask ops, |
84 const GURL& page_url, | 84 const GURL& page_url, |
85 const std::string& page_encoding, | 85 const std::string& page_encoding, |
86 const gfx::ImageSkia& image, | 86 const gfx::ImageSkia& image, |
87 const gfx::Point& image_offset); | 87 const gfx::Vector2d& image_offset); |
88 // Called on UI thread. | 88 // Called on UI thread. |
89 void EndDragging(); | 89 void EndDragging(); |
90 void CloseThread(); | 90 void CloseThread(); |
91 | 91 |
92 // For debug check only. Access only on drag-and-drop thread. | 92 // For debug check only. Access only on drag-and-drop thread. |
93 base::PlatformThreadId drag_drop_thread_id_; | 93 base::PlatformThreadId drag_drop_thread_id_; |
94 | 94 |
95 // All the member variables below are accessed on UI thread. | 95 // All the member variables below are accessed on UI thread. |
96 | 96 |
97 gfx::NativeWindow source_window_; | 97 gfx::NativeWindow source_window_; |
(...skipping 11 matching lines...) Expand all Loading... |
109 | 109 |
110 // The flag to guard that EndDragging is not called twice. | 110 // The flag to guard that EndDragging is not called twice. |
111 bool drag_ended_; | 111 bool drag_ended_; |
112 | 112 |
113 base::Callback<void()> drag_end_callback_; | 113 base::Callback<void()> drag_end_callback_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(WebContentsDragWin); | 115 DISALLOW_COPY_AND_ASSIGN(WebContentsDragWin); |
116 }; | 116 }; |
117 | 117 |
118 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ | 118 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_DRAG_WIN_H_ |
OLD | NEW |