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