| Index: chrome/browser/tab_contents/web_drag_dest_gtk.cc
|
| diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
|
| index d575fc3ff22f1e7f8ac16bc0e4efcefc9c33f791..e6d0796782e18dfebd7d65f51dd5995e0a38fbb5 100644
|
| --- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc
|
| +++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc
|
| @@ -9,19 +9,17 @@
|
| #include "base/file_path.h"
|
| #include "base/message_loop.h"
|
| #include "base/utf_string_conversions.h"
|
| -#include "chrome/browser/bookmarks/bookmark_node_data.h"
|
| -#include "chrome/browser/profiles/profile.h"
|
| -#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
|
| -#include "chrome/browser/ui/browser.h"
|
| -#include "chrome/browser/ui/browser_window.h"
|
| -#include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
|
| -#include "chrome/browser/ui/gtk/gtk_util.h"
|
| -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| -#include "chrome/common/url_constants.h"
|
| #include "content/browser/renderer_host/render_view_host.h"
|
| +#include "content/browser/tab_contents/gtk_drag_utils.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| +#include "content/common/url_constants.h"
|
| #include "net/base/net_util.h"
|
| #include "ui/base/dragdrop/gtk_dnd_util.h"
|
| +#include "ui/base/gtk/gtk_screen_utils.h"
|
| +
|
| +#if defined(TOOLKIT_VIEWS)
|
| +#include "ui/base/dragdrop/bookmark_format.h"
|
| +#endif
|
|
|
| using WebKit::WebDragOperation;
|
| using WebKit::WebDragOperationNone;
|
| @@ -38,7 +36,7 @@ namespace {
|
| // details.
|
| GdkAtom GetBookmarkTargetAtom() {
|
| #if defined(TOOLKIT_VIEWS)
|
| - return BookmarkNodeData::GetBookmarkCustomFormat();
|
| + return ui::GetBookmarkCustomFormat();
|
| #else
|
| return ui::GetAtomForTarget(ui::CHROME_BOOKMARK_ITEM);
|
| #endif
|
| @@ -48,9 +46,9 @@ GdkAtom GetBookmarkTargetAtom() {
|
|
|
| WebDragDestGtk::WebDragDestGtk(TabContents* tab_contents, GtkWidget* widget)
|
| : tab_contents_(tab_contents),
|
| - tab_(NULL),
|
| widget_(widget),
|
| context_(NULL),
|
| + delegate_(NULL),
|
| method_factory_(this) {
|
| gtk_drag_dest_set(widget, static_cast<GtkDestDefaults>(0),
|
| NULL, 0,
|
| @@ -82,7 +80,7 @@ WebDragDestGtk::~WebDragDestGtk() {
|
| void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) {
|
| if (context_) {
|
| is_drop_target_ = operation != WebDragOperationNone;
|
| - gdk_drag_status(context_, gtk_util::WebDragOpToGdkDragAction(operation),
|
| + gdk_drag_status(context_, content::WebDragOpToGdkDragAction(operation),
|
| drag_over_time_);
|
| }
|
| }
|
| @@ -90,28 +88,22 @@ void WebDragDestGtk::UpdateDragStatus(WebDragOperation operation) {
|
| void WebDragDestGtk::DragLeave() {
|
| tab_contents_->render_view_host()->DragTargetDragLeave();
|
|
|
| - if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
|
| - tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragLeave(
|
| - bookmark_drag_data_);
|
| + if (delegate())
|
| + delegate()->OnDragLeave();
|
| }
|
|
|
| gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
|
| GdkDragContext* context,
|
| gint x, gint y,
|
| guint time) {
|
| - // Ideally we would want to initialize the the TabContentsWrapper member in
|
| - // the constructor. We cannot do that as the WebDragDestGtk object is
|
| - // created during the construction of the TabContents object.
|
| - // The TabContentsWrapper is created much later.
|
| - if (!tab_)
|
| - tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_);
|
| -
|
| if (context_ != context) {
|
| context_ = context;
|
| drop_data_.reset(new WebDropData);
|
| - bookmark_drag_data_.Clear();
|
| is_drop_target_ = false;
|
|
|
| + if (delegate())
|
| + delegate()->DragInitialize(tab_contents_);
|
| +
|
| // text/plain must come before text/uri-list. This is a hack that works in
|
| // conjunction with OnDragDataReceived. Since some file managers populate
|
| // text/plain with file URLs when dragging files, we want to handle
|
| @@ -138,12 +130,13 @@ gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
|
| } else if (data_requests_ == 0) {
|
| tab_contents_->render_view_host()->
|
| DragTargetDragOver(
|
| - gtk_util::ClientPoint(widget_),
|
| - gtk_util::ScreenPoint(widget_),
|
| - gtk_util::GdkDragActionToWebDragOp(context->actions));
|
| - if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
|
| - tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragOver(
|
| - bookmark_drag_data_);
|
| + ui::ClientPoint(widget_),
|
| + ui::ScreenPoint(widget_),
|
| + content::GdkDragActionToWebDragOp(context->actions));
|
| +
|
| + if (delegate())
|
| + delegate()->OnDragOver();
|
| +
|
| drag_over_time_ = time;
|
| }
|
|
|
| @@ -223,19 +216,12 @@ void WebDragDestGtk::OnDragDataReceived(
|
| // URL bookmark.
|
| // Note that bookmark drag data is encoded in the same format for both
|
| // GTK and Views, hence we can share the same logic here.
|
| - if (data->target == GetBookmarkTargetAtom()) {
|
| + if (data->target == GetBookmarkTargetAtom() && delegate()) {
|
| if (data->data && data->length > 0) {
|
| - Profile* profile =
|
| - Profile::FromBrowserContext(tab_contents_->browser_context());
|
| - bookmark_drag_data_.ReadFromVector(
|
| - bookmark_utils::GetNodesFromSelection(
|
| - NULL, data,
|
| - ui::CHROME_BOOKMARK_ITEM,
|
| - profile, NULL, NULL));
|
| - bookmark_drag_data_.SetOriginatingProfile(profile);
|
| + delegate()->OnReceiveDataFromGtk(data);
|
| } else {
|
| - bookmark_drag_data_.ReadFromTuple(drop_data_->url,
|
| - drop_data_->url_title);
|
| + delegate()->OnReceiveProcessedData(drop_data_->url,
|
| + drop_data_->url_title);
|
| }
|
| }
|
|
|
| @@ -244,15 +230,13 @@ void WebDragDestGtk::OnDragDataReceived(
|
| // |x| and |y| are seemingly arbitrary at this point.
|
| tab_contents_->render_view_host()->
|
| DragTargetDragEnter(*drop_data_.get(),
|
| - gtk_util::ClientPoint(widget_),
|
| - gtk_util::ScreenPoint(widget_),
|
| - gtk_util::GdkDragActionToWebDragOp(context->actions));
|
| -
|
| - // This is non-null if tab_contents_ is showing an ExtensionWebUI with
|
| - // support for (at the moment experimental) drag and drop extensions.
|
| - if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
|
| - tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDragEnter(
|
| - bookmark_drag_data_);
|
| + ui::ClientPoint(widget_),
|
| + ui::ScreenPoint(widget_),
|
| + content::GdkDragActionToWebDragOp(context->actions));
|
| +
|
| + if (delegate())
|
| + delegate()->OnDragEnter();
|
| +
|
| drag_over_time_ = time;
|
| }
|
| }
|
| @@ -279,20 +263,10 @@ gboolean WebDragDestGtk::OnDragDrop(GtkWidget* sender, GdkDragContext* context,
|
| method_factory_.RevokeAll();
|
|
|
| tab_contents_->render_view_host()->
|
| - DragTargetDrop(gtk_util::ClientPoint(widget_),
|
| - gtk_util::ScreenPoint(widget_));
|
| -
|
| - // This is non-null if tab_contents_ is showing an ExtensionWebUI with
|
| - // support for (at the moment experimental) drag and drop extensions.
|
| - if (tab_ && tab_->bookmark_tab_helper()->GetBookmarkDragDelegate())
|
| - tab_->bookmark_tab_helper()->GetBookmarkDragDelegate()->OnDrop(
|
| - bookmark_drag_data_);
|
| -
|
| - // Focus the target browser.
|
| - Browser* browser = Browser::GetBrowserForController(
|
| - &tab_contents_->controller(), NULL);
|
| - if (browser)
|
| - browser->window()->Show();
|
| + DragTargetDrop(ui::ClientPoint(widget_), ui::ScreenPoint(widget_));
|
| +
|
| + if (delegate())
|
| + delegate()->OnDrop();
|
|
|
| // The second parameter is just an educated guess as to whether or not the
|
| // drag succeeded, but at least we will get the drag-end animation right
|
|
|