Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/tab_contents/web_drag_dest_gtk.h

Issue 8196001: content: Split web_drag_dest_gtk.cc into chrome/ and content/ parts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: :( Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_
6 #define CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ 6 #define CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "chrome/browser/bookmarks/bookmark_node_data.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
16 #include "ui/base/gtk/gtk_signal.h" 15 #include "ui/base/gtk/gtk_signal.h"
17 #include "webkit/glue/webdropdata.h" 16 #include "webkit/glue/webdropdata.h"
18 17
19 class TabContents; 18 class TabContents;
20 class TabContentsWrapper; 19
20 // An optional delegate that listens for drags of bookmark data.
21 class WebDragBookmarkDelegate {
jam 2011/10/11 01:42:21 nit: this should be in its own file since current
22 public:
23 // Announces that a drag has started. It's valid that a drag starts, along
24 // with over/enter/leave/drop notifications without receiving any bookmark
25 // data.
26 virtual void DragInitialize(TabContents* contents) = 0;
27
28 // Called when WebDragDestkGtk detects that there's bookmark data in a
29 // drag. Not every drag will trigger these.
30 virtual void OnReceiveDataFromGtk(GtkSelectionData* data) = 0;
31 virtual void OnReceiveProcessedData(const GURL& url,
32 const string16& title) = 0;
33
34 // Notifications of drag progression.
35 virtual void OnDragOver() = 0;
36 virtual void OnDragEnter() = 0;
37 virtual void OnDrop() = 0;
38
39 // This should also clear any state kept about this drag.
40 virtual void OnDragLeave() = 0;
41
42 virtual ~WebDragBookmarkDelegate() {}
43 };
21 44
22 // A helper class that handles DnD for drops in the renderer. In GTK parlance, 45 // A helper class that handles DnD for drops in the renderer. In GTK parlance,
23 // this handles destination-side DnD, but not source-side DnD. 46 // this handles destination-side DnD, but not source-side DnD.
24 class WebDragDestGtk { 47 class WebDragDestGtk {
25 public: 48 public:
26 WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget); 49 WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget);
27 virtual ~WebDragDestGtk(); 50 virtual ~WebDragDestGtk();
28 51
29 // This is called when the renderer responds to a drag motion event. We must 52 // This is called when the renderer responds to a drag motion event. We must
30 // update the system drag cursor. 53 // update the system drag cursor.
31 void UpdateDragStatus(WebKit::WebDragOperation operation); 54 void UpdateDragStatus(WebKit::WebDragOperation operation);
32 55
33 // Informs the renderer when a system drag has left the render view. 56 // Informs the renderer when a system drag has left the render view.
34 // See OnDragLeave(). 57 // See OnDragLeave().
35 void DragLeave(); 58 void DragLeave();
36 59
60 WebDragBookmarkDelegate* delegate() const { return delegate_; }
61 void set_delegate(WebDragBookmarkDelegate* delegate) { delegate_ = delegate; }
62
37 private: 63 private:
38 FRIEND_TEST_ALL_PREFIXES(WebDragDestGtkTest, NoTabContentsWrapper);
39
40 // Called when a system drag crosses over the render view. As there is no drag 64 // Called when a system drag crosses over the render view. As there is no drag
41 // enter event, we treat it as an enter event (and not a regular motion event) 65 // enter event, we treat it as an enter event (and not a regular motion event)
42 // when |context_| is NULL. 66 // when |context_| is NULL.
43 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragMotion, GdkDragContext*, 67 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragMotion, GdkDragContext*,
44 gint, gint, guint); 68 gint, gint, guint);
45 69
46 // We make a series of requests for the drag data when the drag first enters 70 // We make a series of requests for the drag data when the drag first enters
47 // the render view. This is the callback that is used to give us the data 71 // the render view. This is the callback that is used to give us the data
48 // for each individual target. When |data_requests_| reaches 0, we know we 72 // for each individual target. When |data_requests_| reaches 0, we know we
49 // have attained all the data, and we can finally tell the renderer about the 73 // have attained all the data, and we can finally tell the renderer about the
50 // drag. 74 // drag.
51 CHROMEGTK_CALLBACK_6(WebDragDestGtk, void, OnDragDataReceived, 75 CHROMEGTK_CALLBACK_6(WebDragDestGtk, void, OnDragDataReceived,
52 GdkDragContext*, gint, gint, GtkSelectionData*, 76 GdkDragContext*, gint, gint, GtkSelectionData*,
53 guint, guint); 77 guint, guint);
54 78
55 // The drag has left our widget; forward this information to the renderer. 79 // The drag has left our widget; forward this information to the renderer.
56 CHROMEGTK_CALLBACK_2(WebDragDestGtk, void, OnDragLeave, GdkDragContext*, 80 CHROMEGTK_CALLBACK_2(WebDragDestGtk, void, OnDragLeave, GdkDragContext*,
57 guint); 81 guint);
58 82
59 // Called by GTK when the user releases the mouse, executing a drop. 83 // Called by GTK when the user releases the mouse, executing a drop.
60 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragDrop, GdkDragContext*, 84 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragDrop, GdkDragContext*,
61 gint, gint, guint); 85 gint, gint, guint);
62 86
63 TabContents* tab_contents_; 87 TabContents* tab_contents_;
64 88
65 // The TabContentsWrapper for |tab_contents_|.
66 // Weak reference; may be NULL if the contents aren't contained in a wrapper
67 // (e.g. WebUI dialogs).
68 TabContentsWrapper* tab_;
69
70 // The render view. 89 // The render view.
71 GtkWidget* widget_; 90 GtkWidget* widget_;
72 91
73 // The current drag context for system drags over our render view, or NULL if 92 // The current drag context for system drags over our render view, or NULL if
74 // there is no system drag or the system drag is not over our render view. 93 // there is no system drag or the system drag is not over our render view.
75 GdkDragContext* context_; 94 GdkDragContext* context_;
76 95
77 // The data for the current drag, or NULL if |context_| is NULL. 96 // The data for the current drag, or NULL if |context_| is NULL.
78 scoped_ptr<WebDropData> drop_data_; 97 scoped_ptr<WebDropData> drop_data_;
79 98
80 // The number of outstanding drag data requests we have sent to the drag 99 // The number of outstanding drag data requests we have sent to the drag
81 // source. 100 // source.
82 int data_requests_; 101 int data_requests_;
83 102
84 // The last time we sent a message to the renderer related to a drag motion. 103 // The last time we sent a message to the renderer related to a drag motion.
85 gint drag_over_time_; 104 gint drag_over_time_;
86 105
87 // Whether the cursor is over a drop target, according to the last message we 106 // Whether the cursor is over a drop target, according to the last message we
88 // got from the renderer. 107 // got from the renderer.
89 bool is_drop_target_; 108 bool is_drop_target_;
90 109
91 // Handler ID for the destroy signal handler. We connect to the destroy 110 // Handler ID for the destroy signal handler. We connect to the destroy
92 // signal handler so that we won't call dest_unset on it after it is 111 // signal handler so that we won't call dest_unset on it after it is
93 // destroyed, but we have to cancel the handler if we are destroyed before 112 // destroyed, but we have to cancel the handler if we are destroyed before
94 // |widget_| is. 113 // |widget_| is.
95 int destroy_handler_; 114 int destroy_handler_;
96 115
97 // The bookmark data for the current tab. This will be empty if there is not 116 // A delegate that can receive drag information about drag events.
98 // a native bookmark drag (or we haven't gotten the data from the source yet). 117 WebDragBookmarkDelegate* delegate_;
99 BookmarkNodeData bookmark_drag_data_;
100 118
101 ScopedRunnableMethodFactory<WebDragDestGtk> method_factory_; 119 ScopedRunnableMethodFactory<WebDragDestGtk> method_factory_;
102 120
103 DISALLOW_COPY_AND_ASSIGN(WebDragDestGtk); 121 DISALLOW_COPY_AND_ASSIGN(WebDragDestGtk);
104 }; 122 };
105 123
106 #endif // CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ 124 #endif // CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698