summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 04:03:27 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 04:03:27 +0000
commit5c7c41ad79c21366a9a27b4fea114b2ebf8fbc58 (patch)
tree4f8becf0d748f502f9b6932d91768bc066ec0144 /chrome/browser/views
parentc0d769d16ca94f36239fcd82725d909947f1cc1c (diff)
downloadchromium_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/views')
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.cc33
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.h8
2 files changed, 19 insertions, 22 deletions
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
index e2ad712..54f22b4 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
@@ -14,6 +14,7 @@
#include "build/build_config.h"
#include "chrome/browser/blocked_popup_container.h"
#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/gtk/tab_contents_drag_source.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_factory.h"
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
@@ -93,6 +94,7 @@ TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents)
: TabContentsView(tab_contents),
views::WidgetGtk(TYPE_CHILD),
ignore_next_char_event_(false) {
+ drag_source_.reset(new TabContentsDragSource(this));
}
TabContentsViewGtk::~TabContentsViewGtk() {
@@ -159,14 +161,7 @@ void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
}
void TabContentsViewGtk::StartDragging(const WebDropData& drop_data) {
- NOTIMPLEMENTED();
-
- // Until we have d'n'd implemented, just immediately pretend we're
- // already done with the drag and drop so we don't get stuck
- // thinking we're in mid-drag.
- // TODO(port): remove me when the above NOTIMPLEMENTED is fixed.
- if (tab_contents()->render_view_host())
- tab_contents()->render_view_host()->DragSourceSystemDragEnded();
+ drag_source_->StartDragging(drop_data, &last_mouse_down_);
}
void TabContentsViewGtk::OnContentsDestroy() {
@@ -175,20 +170,8 @@ void TabContentsViewGtk::OnContentsDestroy() {
// can be moved into OnDestroy which is a Windows message handler as the
// window is being torn down.
- // When a tab is closed all its child plugin windows are destroyed
- // automatically. This happens before plugins get any notification that its
- // instances are tearing down.
- //
- // Plugins like Quicktime assume that their windows will remain valid as long
- // as they have plugin instances active. Quicktime crashes in this case
- // because its windowing code cleans up an internal data structure that the
- // handler for NPP_DestroyStream relies on.
- //
- // The fix is to detach plugin windows from web contents when it is going
- // away. This will prevent the plugin windows from getting destroyed
- // automatically. The detached plugin windows will get cleaned up in proper
- // sequence as part of the usual cleanup when the plugin instance goes away.
- NOTIMPLEMENTED();
+ // We don't want to try to handle drag events from this point on.
+ drag_source_.reset();
}
void TabContentsViewGtk::SetPageTitle(const std::wstring& title) {
@@ -279,6 +262,12 @@ void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) {
MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
+gboolean TabContentsViewGtk::OnButtonPress(GtkWidget* widget,
+ GdkEventButton* event) {
+ last_mouse_down_ = *event;
+ return views::WidgetGtk::OnButtonPress(widget, event);
+}
+
void TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget,
GtkAllocation* allocation) {
WasSized(gfx::Size(allocation->width, allocation->height));
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h
index 900fecc..561267b 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.h
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.h
@@ -12,6 +12,7 @@
class RenderViewContextMenuWin;
class SadTabView;
+class TabContentsDragSource;
namespace views {
class NativeViewHost;
}
@@ -58,6 +59,7 @@ class TabContentsViewGtk : public TabContentsView,
// Signal handlers -----------------------------------------------------------
// Overridden from views::WidgetGtk:
+ virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event);
virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation);
// Handles notifying the TabContents and other operations when the window was
@@ -81,6 +83,12 @@ class TabContentsViewGtk : public TabContentsView,
// The context menu. Callbacks are asynchronous so we need to keep it around.
scoped_ptr<RenderViewContextMenuWin> context_menu_;
+ // Handles drags from this TabContentsView.
+ scoped_ptr<TabContentsDragSource> drag_source_;
+
+ // The event for the last mouse down we handled. We need this for drags.
+ GdkEventButton last_mouse_down_;
+
DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk);
};