| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ | |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "content/public/browser/notification_observer.h" | |
| 10 #include "content/public/browser/notification_registrar.h" | |
| 11 #include "ui/base/dragdrop/drag_source_win.h" | |
| 12 #include "ui/gfx/native_widget_types.h" | |
| 13 #include "ui/gfx/point.h" | |
| 14 | |
| 15 namespace ui { | |
| 16 class OSExchangeData; | |
| 17 } // namespace ui | |
| 18 | |
| 19 namespace content { | |
| 20 class RenderViewHost; | |
| 21 class WebContents; | |
| 22 class WebContentsImpl; | |
| 23 | |
| 24 // An IDropSource implementation for a WebContentsImpl. Handles notifications | |
| 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 | |
| 27 // should continue, and supplies the appropriate cursors. | |
| 28 class WebDragSource : public ui::DragSourceWin, | |
| 29 public NotificationObserver { | |
| 30 public: | |
| 31 // Create a new DragSource for a given HWND and WebContents. | |
| 32 WebDragSource(gfx::NativeWindow source_wnd, WebContents* web_contents); | |
| 33 virtual ~WebDragSource(); | |
| 34 | |
| 35 // NotificationObserver implementation. | |
| 36 virtual void Observe(int type, | |
| 37 const NotificationSource& source, | |
| 38 const NotificationDetails& details); | |
| 39 | |
| 40 void set_effect(DWORD effect) { effect_ = effect; } | |
| 41 // 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 | |
| 43 // terminates. | |
| 44 void set_data(ui::OSExchangeData* data) { data_ = data; } | |
| 45 | |
| 46 protected: | |
| 47 // ui::DragSourceWin | |
| 48 virtual void OnDragSourceCancel(); | |
| 49 virtual void OnDragSourceDrop(); | |
| 50 virtual void OnDragSourceMove(); | |
| 51 | |
| 52 private: | |
| 53 // Cannot construct thusly. | |
| 54 WebDragSource(); | |
| 55 | |
| 56 // OnDragSourceDrop schedules its main work to be done after IDropTarget::Drop | |
| 57 // by posting a task to this function. | |
| 58 void DelayedOnDragSourceDrop(); | |
| 59 | |
| 60 // Keep a reference to the window so we can translate the cursor position. | |
| 61 gfx::NativeWindow source_wnd_; | |
| 62 | |
| 63 // 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 | |
| 65 // initiated terminates). | |
| 66 WebContentsImpl* web_contents_; | |
| 67 | |
| 68 NotificationRegistrar registrar_; | |
| 69 | |
| 70 DWORD effect_; | |
| 71 | |
| 72 ui::OSExchangeData* data_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(WebDragSource); | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ | |
| OLD | NEW |