| 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_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ |
| 6 #define CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ | 6 #define CONTENT_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/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
| 16 #include "ui/base/gtk/gtk_signal.h" | 16 #include "ui/base/gtk/gtk_signal.h" |
| 17 #include "webkit/glue/webdropdata.h" | 17 #include "webkit/glue/webdropdata.h" |
| 18 | 18 |
| 19 class RenderViewHostImpl; | |
| 20 | |
| 21 namespace content { | 19 namespace content { |
| 22 | 20 |
| 21 class RenderViewHostImpl; |
| 23 class WebContents; | 22 class WebContents; |
| 24 class WebDragDestDelegate; | 23 class WebDragDestDelegate; |
| 25 | 24 |
| 26 // A helper class that handles DnD for drops in the renderer. In GTK parlance, | 25 // A helper class that handles DnD for drops in the renderer. In GTK parlance, |
| 27 // this handles destination-side DnD, but not source-side DnD. | 26 // this handles destination-side DnD, but not source-side DnD. |
| 28 class CONTENT_EXPORT WebDragDestGtk { | 27 class CONTENT_EXPORT WebDragDestGtk { |
| 29 public: | 28 public: |
| 30 WebDragDestGtk(WebContents* web_contents, GtkWidget* widget); | 29 WebDragDestGtk(WebContents* web_contents, GtkWidget* widget); |
| 31 ~WebDragDestGtk(); | 30 ~WebDragDestGtk(); |
| 32 | 31 |
| 33 // This is called when the renderer responds to a drag motion event. We must | 32 // This is called when the renderer responds to a drag motion event. We must |
| 34 // update the system drag cursor. | 33 // update the system drag cursor. |
| 35 void UpdateDragStatus(WebKit::WebDragOperation operation); | 34 void UpdateDragStatus(WebKit::WebDragOperation operation); |
| 36 | 35 |
| 37 // Informs the renderer when a system drag has left the render view. | 36 // Informs the renderer when a system drag has left the render view. |
| 38 // See OnDragLeave(). | 37 // See OnDragLeave(). |
| 39 void DragLeave(); | 38 void DragLeave(); |
| 40 | 39 |
| 41 WebDragDestDelegate* delegate() const { return delegate_; } | 40 WebDragDestDelegate* delegate() const { return delegate_; } |
| 42 void set_delegate(WebDragDestDelegate* delegate) { delegate_ = delegate; } | 41 void set_delegate(WebDragDestDelegate* delegate) { delegate_ = delegate; } |
| 43 | 42 |
| 44 private: | 43 private: |
| 45 RenderViewHostImpl* GetRenderViewHost() const; | 44 content::RenderViewHostImpl* GetRenderViewHost() const; |
| 46 | 45 |
| 47 // Called when a system drag crosses over the render view. As there is no drag | 46 // Called when a system drag crosses over the render view. As there is no drag |
| 48 // enter event, we treat it as an enter event (and not a regular motion event) | 47 // enter event, we treat it as an enter event (and not a regular motion event) |
| 49 // when |context_| is NULL. | 48 // when |context_| is NULL. |
| 50 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragMotion, GdkDragContext*, | 49 CHROMEGTK_CALLBACK_4(WebDragDestGtk, gboolean, OnDragMotion, GdkDragContext*, |
| 51 gint, gint, guint); | 50 gint, gint, guint); |
| 52 | 51 |
| 53 // We make a series of requests for the drag data when the drag first enters | 52 // We make a series of requests for the drag data when the drag first enters |
| 54 // the render view. This is the callback that is used to give us the data | 53 // the render view. This is the callback that is used to give us the data |
| 55 // for each individual target. When |data_requests_| reaches 0, we know we | 54 // for each individual target. When |data_requests_| reaches 0, we know we |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 WebDragDestDelegate* delegate_; | 99 WebDragDestDelegate* delegate_; |
| 101 | 100 |
| 102 base::WeakPtrFactory<WebDragDestGtk> method_factory_; | 101 base::WeakPtrFactory<WebDragDestGtk> method_factory_; |
| 103 | 102 |
| 104 DISALLOW_COPY_AND_ASSIGN(WebDragDestGtk); | 103 DISALLOW_COPY_AND_ASSIGN(WebDragDestGtk); |
| 105 }; | 104 }; |
| 106 | 105 |
| 107 } // namespace content | 106 } // namespace content |
| 108 | 107 |
| 109 #endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ | 108 #endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_GTK_H_ |
| OLD | NEW |