diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 04:03:27 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 04:03:27 +0000 |
commit | 5c7c41ad79c21366a9a27b4fea114b2ebf8fbc58 (patch) | |
tree | 4f8becf0d748f502f9b6932d91768bc066ec0144 /chrome/browser/gtk/tab_contents_drag_source.h | |
parent | c0d769d16ca94f36239fcd82725d909947f1cc1c (diff) | |
download | chromium_src-5c7c41ad79c21366a9a27b4fea114b2ebf8fbc58.zip chromium_src-5c7c41ad79c21366a9a27b4fea114b2ebf8fbc58.tar.gz chromium_src-5c7c41ad79c21366a9a27b4fea114b2ebf8fbc58.tar.bz2 |
Refactors drag support from TabContentsViewGtk into
TabContentsDragHandler so that it can be used by both Gtk and Views.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/165302
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tab_contents_drag_source.h')
-rw-r--r-- | chrome/browser/gtk/tab_contents_drag_source.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/chrome/browser/gtk/tab_contents_drag_source.h b/chrome/browser/gtk/tab_contents_drag_source.h new file mode 100644 index 0000000..1d35669 --- /dev/null +++ b/chrome/browser/gtk/tab_contents_drag_source.h @@ -0,0 +1,85 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_GTK_TAB_CONTENTS_DRAG_SOURCE_H_ +#define CHROME_BROWSER_GTK_TAB_CONTENTS_DRAG_SOURCE_H_ + +#include <gtk/gtk.h> + +#include "base/basictypes.h" +#include "base/gfx/native_widget_types.h" +#include "base/message_loop.h" + +class TabContents; +class TabContentsView; +struct WebDropData; + +// TabContentsDragSource takes care of managing the drag from a TabContents +// with Gtk. +class TabContentsDragSource : public MessageLoopForUI::Observer { + public: + explicit TabContentsDragSource(TabContentsView* tab_contents_view); + ~TabContentsDragSource(); + + TabContents* tab_contents() const; + + // Starts a drag for the tab contents this TabContentsDragSource was + // created for. + void StartDragging(const WebDropData& drop_data, + GdkEventButton* last_mouse_down); + + // MessageLoop::Observer implementation: + virtual void WillProcessEvent(GdkEvent* event); + virtual void DidProcessEvent(GdkEvent* event); + + private: + static gboolean OnDragFailedThunk(GtkWidget* widget, + GdkDragContext* drag_context, + GtkDragResult result, + TabContentsDragSource* handler) { + return handler->OnDragFailed(); + } + gboolean OnDragFailed(); + static void OnDragEndThunk(GtkWidget* widget, + GdkDragContext* drag_context, + TabContentsDragSource* handler) { + handler->OnDragEnd(); + } + void OnDragEnd(); + static void OnDragDataGetThunk(GtkWidget* drag_widget, + GdkDragContext* context, + GtkSelectionData* selection_data, + guint target_type, + guint time, + TabContentsDragSource* handler) { + handler->OnDragDataGet(context, selection_data, target_type, time); + } + void OnDragDataGet(GdkDragContext* context, GtkSelectionData* selection_data, + guint target_type, guint time); + + gfx::NativeView GetContentNativeView() const; + + // The view we're manging the drag for. + TabContentsView* tab_contents_view_; + + // The drop data for the current drag (for drags that originate in the render + // view). Non-NULL iff there is a current drag. + scoped_ptr<WebDropData> drop_data_; + + // The mime type for the file contents of the current drag (if any). + GdkAtom drag_file_mime_type_; + + // Whether the current drag has failed. Meaningless if we are not the source + // for a current drag. + bool drag_failed_; + + // This is the widget we use to initiate drags. Since we don't use the + // renderer widget, we can persist drags even when our contents is switched + // out. + GtkWidget* drag_widget_; + + DISALLOW_COPY_AND_ASSIGN(TabContentsDragSource); +}; + +#endif // CHROME_BROWSER_GTK_TAB_CONTENTS_DRAG_SOURCE_H_ |