| 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" |
| 11 #include "ui/base/dragdrop/drag_source.h" | 11 #include "ui/base/dragdrop/drag_source.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class RenderViewHost; | 16 class RenderViewHost; |
| 17 class WebContents; | 17 class WebContents; |
| 18 } | |
| 19 | 18 |
| 20 // An IDropSource implementation for a WebContentsImpl. Handles notifications | 19 // An IDropSource implementation for a WebContentsImpl. Handles notifications |
| 21 // sent by an active drag-drop operation as the user mouses over other drop | 20 // sent by an active drag-drop operation as the user mouses over other drop |
| 22 // targets on their system. This object tells Windows whether or not the drag | 21 // targets on their system. This object tells Windows whether or not the drag |
| 23 // should continue, and supplies the appropriate cursors. | 22 // should continue, and supplies the appropriate cursors. |
| 24 class WebDragSource : public ui::DragSource, | 23 class WebDragSource : public ui::DragSource, |
| 25 public content::NotificationObserver { | 24 public NotificationObserver { |
| 26 public: | 25 public: |
| 27 // Create a new DragSource for a given HWND and WebContents. | 26 // Create a new DragSource for a given HWND and WebContents. |
| 28 WebDragSource(gfx::NativeWindow source_wnd, | 27 WebDragSource(gfx::NativeWindow source_wnd, WebContents* web_contents); |
| 29 content::WebContents* web_contents); | |
| 30 virtual ~WebDragSource(); | 28 virtual ~WebDragSource(); |
| 31 | 29 |
| 32 // content::NotificationObserver implementation. | 30 // NotificationObserver implementation. |
| 33 virtual void Observe(int type, | 31 virtual void Observe(int type, |
| 34 const content::NotificationSource& source, | 32 const NotificationSource& source, |
| 35 const content::NotificationDetails& details); | 33 const NotificationDetails& details); |
| 36 | 34 |
| 37 void set_effect(DWORD effect) { effect_ = effect; } | 35 void set_effect(DWORD effect) { effect_ = effect; } |
| 38 | 36 |
| 39 protected: | 37 protected: |
| 40 // ui::DragSource | 38 // ui::DragSource |
| 41 virtual void OnDragSourceCancel(); | 39 virtual void OnDragSourceCancel(); |
| 42 virtual void OnDragSourceDrop(); | 40 virtual void OnDragSourceDrop(); |
| 43 virtual void OnDragSourceMove(); | 41 virtual void OnDragSourceMove(); |
| 44 | 42 |
| 45 private: | 43 private: |
| 46 // Cannot construct thusly. | 44 // Cannot construct thusly. |
| 47 WebDragSource(); | 45 WebDragSource(); |
| 48 | 46 |
| 49 // OnDragSourceDrop schedules its main work to be done after IDropTarget::Drop | 47 // OnDragSourceDrop schedules its main work to be done after IDropTarget::Drop |
| 50 // by posting a task to this function. | 48 // by posting a task to this function. |
| 51 void DelayedOnDragSourceDrop(); | 49 void DelayedOnDragSourceDrop(); |
| 52 | 50 |
| 53 // Keep a reference to the window so we can translate the cursor position. | 51 // Keep a reference to the window so we can translate the cursor position. |
| 54 gfx::NativeWindow source_wnd_; | 52 gfx::NativeWindow source_wnd_; |
| 55 | 53 |
| 56 // We use this as a channel to the renderer to tell it about various drag | 54 // We use this as a channel to the renderer to tell it about various drag |
| 57 // drop events that it needs to know about (such as when a drag operation it | 55 // drop events that it needs to know about (such as when a drag operation it |
| 58 // initiated terminates). | 56 // initiated terminates). |
| 59 content::RenderViewHost* render_view_host_; | 57 RenderViewHost* render_view_host_; |
| 60 | 58 |
| 61 content::NotificationRegistrar registrar_; | 59 NotificationRegistrar registrar_; |
| 62 | 60 |
| 63 DWORD effect_; | 61 DWORD effect_; |
| 64 | 62 |
| 65 DISALLOW_COPY_AND_ASSIGN(WebDragSource); | 63 DISALLOW_COPY_AND_ASSIGN(WebDragSource); |
| 66 }; | 64 }; |
| 67 | 65 |
| 66 } // namespace content |
| 67 |
| 68 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ | 68 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_ |
| OLD | NEW |