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