| 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_SOURCE_WIN_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "content/public/browser/notification_observer.h" | 9 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class WebContentsImpl; | 22 class WebContentsImpl; |
| 23 | 23 |
| 24 // An IDropSource implementation for a WebContentsImpl. Handles notifications | 24 // An IDropSource implementation for a WebContentsImpl. Handles notifications |
| 25 // sent by an active drag-drop operation as the user mouses over other drop | 25 // sent by an active drag-drop operation as the user mouses over other drop |
| 26 // targets on their system. This object tells Windows whether or not the drag | 26 // targets on their system. This object tells Windows whether or not the drag |
| 27 // should continue, and supplies the appropriate cursors. | 27 // should continue, and supplies the appropriate cursors. |
| 28 class WebDragSource : public ui::DragSourceWin, | 28 class WebDragSource : public ui::DragSourceWin, |
| 29 public NotificationObserver { | 29 public NotificationObserver { |
| 30 public: | 30 public: |
| 31 // Create a new DragSource for a given HWND and WebContents. | 31 // Create a new DragSource for a given HWND and WebContents. |
| 32 WebDragSource(gfx::NativeWindow source_wnd, WebContents* web_contents); | 32 WebDragSource(gfx::NativeWindow source_wnd, |
| 33 WebContents* web_contents, |
| 34 ui::DragDropTypes::DragEventSource event_source); |
| 33 virtual ~WebDragSource(); | 35 virtual ~WebDragSource(); |
| 34 | 36 |
| 35 // NotificationObserver implementation. | 37 // NotificationObserver implementation. |
| 36 virtual void Observe(int type, | 38 virtual void Observe(int type, |
| 37 const NotificationSource& source, | 39 const NotificationSource& source, |
| 38 const NotificationDetails& details); | 40 const NotificationDetails& details); |
| 39 | 41 |
| 40 void set_effect(DWORD effect) { effect_ = effect; } | 42 void set_effect(DWORD effect) { effect_ = effect; } |
| 41 // Used to set the active data object for the current drag operation. The | 43 // Used to set the active data object for the current drag operation. The |
| 42 // caller must ensure that |data| is not destroyed before the nested drag loop | 44 // caller must ensure that |data| is not destroyed before the nested drag loop |
| 43 // terminates. | 45 // terminates. |
| 44 void set_data(ui::OSExchangeData* data) { data_ = data; } | 46 void set_data(ui::OSExchangeData* data) { data_ = data; } |
| 45 | 47 |
| 46 protected: | 48 protected: |
| 47 // ui::DragSourceWin | 49 // ui::DragSourceWin |
| 48 virtual void OnDragSourceCancel(); | 50 virtual void OnDragSourceCancel(); |
| 49 virtual void OnDragSourceDrop(); | 51 virtual void OnDragSourceDrop(); |
| 50 virtual void OnDragSourceMove(); | 52 virtual void OnDragSourceMove(); |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 // Cannot construct thusly. | 55 // Cannot construct thusly. |
| 54 WebDragSource(); | 56 WebDragSource(); |
| 55 | 57 |
| 56 // OnDragSourceDrop schedules its main work to be done after IDropTarget::Drop | 58 // OnDragSourceDrop schedules its main work to be done after IDropTarget::Drop |
| 57 // by posting a task to this function. | 59 // by posting a task to this function. |
| 58 void DelayedOnDragSourceDrop(); | 60 void DelayedOnDragSourceDrop(); |
| 59 | 61 |
| 62 void CancelLongPressGestureIfNeeded(); |
| 63 |
| 60 // Keep a reference to the window so we can translate the cursor position. | 64 // Keep a reference to the window so we can translate the cursor position. |
| 61 gfx::NativeWindow source_wnd_; | 65 gfx::NativeWindow source_wnd_; |
| 62 | 66 |
| 63 // We use this as a channel to the renderer to tell it about various drag | 67 // We use this as a channel to the renderer to tell it about various drag |
| 64 // drop events that it needs to know about (such as when a drag operation it | 68 // drop events that it needs to know about (such as when a drag operation it |
| 65 // initiated terminates). | 69 // initiated terminates). |
| 66 WebContentsImpl* web_contents_; | 70 WebContentsImpl* web_contents_; |
| 67 | 71 |
| 68 NotificationRegistrar registrar_; | 72 NotificationRegistrar registrar_; |
| 69 | 73 |
| 70 DWORD effect_; | 74 DWORD effect_; |
| 71 | 75 |
| 72 ui::OSExchangeData* data_; | 76 ui::OSExchangeData* data_; |
| 73 | 77 |
| 74 DISALLOW_COPY_AND_ASSIGN(WebDragSource); | 78 DISALLOW_COPY_AND_ASSIGN(WebDragSource); |
| 75 }; | 79 }; |
| 76 | 80 |
| 77 } // namespace content | 81 } // namespace content |
| 78 | 82 |
| 79 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ | 83 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ |
| OLD | NEW |