Commit 60eaa6e6 authored by jam@chromium.org's avatar jam@chromium.org

Move the core drag&drop code for Windows to content\browser to match Mac/GTK....

Move the core drag&drop code for Windows to content\browser to match Mac/GTK. I've had to add temporary exceptions to DEPS which I'll remove in followup changes.

BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9562049

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124603 0039d316-1c4b-4281-b951-d872f2087c98
parent 20e4b247
......@@ -74,7 +74,10 @@ include_rules = [
"+content/browser/tab_contents/web_contents_view_mac.h",
"+content/browser/tab_contents/web_drag_dest_delegate.h",
"+content/browser/tab_contents/web_drag_dest_gtk.h",
"+content/browser/tab_contents/web_drag_dest_win.h",
"+content/browser/tab_contents/web_drag_source_gtk.h",
"+content/browser/tab_contents/web_drag_source_win.h",
"+content/browser/tab_contents/web_drag_utils_win.h",
"+content/browser/trace_controller.h",
# DO NOT ADD ANY MORE ITEMS TO THE ABOVE LIST!
......
......@@ -4,9 +4,10 @@
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h"
#include "chrome/browser/tab_contents/web_drop_target_win.h"
#include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_delegate.h"
#include "chrome/browser/ui/views/tab_contents/tab_contents_drag_win.h"
#include "content/browser/tab_contents/web_drag_dest_win.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
......@@ -98,8 +99,9 @@ void NativeTabContentsViewWin::InitNativeTabContentsView() {
// Remove the root view drop target so we can register our own.
RevokeDragDrop(GetNativeView());
drop_target_ = new WebDropTarget(GetNativeView(),
delegate_->GetWebContents());
drag_dest_ = new WebDragDest(GetNativeView(), delegate_->GetWebContents());
bookmark_handler_.reset(new WebDragBookmarkHandlerWin());
drag_dest_->set_delegate(bookmark_handler_.get());
}
void NativeTabContentsViewWin::Unparent() {
......@@ -147,7 +149,7 @@ bool NativeTabContentsViewWin::IsDoingDrag() const {
void NativeTabContentsViewWin::SetDragCursor(
WebKit::WebDragOperation operation) {
drop_target_->set_drag_cursor(operation);
drag_dest_->set_drag_cursor(operation);
}
views::NativeWidget* NativeTabContentsViewWin::AsNativeWidget() {
......@@ -158,9 +160,9 @@ views::NativeWidget* NativeTabContentsViewWin::AsNativeWidget() {
// NativeTabContentsViewWin, views::NativeWidgetWin overrides:
void NativeTabContentsViewWin::OnDestroy() {
if (drop_target_.get()) {
if (drag_dest_.get()) {
RevokeDragDrop(GetNativeView());
drop_target_ = NULL;
drag_dest_ = NULL;
}
NativeWidgetWin::OnDestroy();
......
......@@ -9,7 +9,8 @@
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view.h"
#include "ui/views/widget/native_widget_win.h"
class WebDropTarget;
class WebDragBookmarkHandlerWin;
class WebDragDest;
class TabContentsDragWin;
namespace content {
......@@ -24,7 +25,7 @@ class NativeTabContentsViewWin : public views::NativeWidgetWin,
internal::NativeTabContentsViewDelegate* delegate);
virtual ~NativeTabContentsViewWin();
WebDropTarget* drop_target() const { return drop_target_.get(); }
WebDragDest* drag_dest() const { return drag_dest_.get(); }
content::WebContents* GetWebContents() const;
......@@ -75,8 +76,9 @@ class NativeTabContentsViewWin : public views::NativeWidgetWin,
internal::NativeTabContentsViewDelegate* delegate_;
scoped_ptr<WebDragBookmarkHandlerWin> bookmark_handler_;
// A drop target object that handles drags over this TabContents.
scoped_refptr<WebDropTarget> drop_target_;
scoped_refptr<WebDragDest> drag_dest_;
// Used to handle the drag-and-drop.
scoped_refptr<TabContentsDragWin> drag_handler_;
......
......@@ -16,13 +16,13 @@
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/tab_contents/web_drag_source_win.h"
#include "chrome/browser/tab_contents/web_drag_utils_win.h"
#include "chrome/browser/tab_contents/web_drop_target_win.h"
#include "chrome/browser/ui/views/tab_contents/native_tab_contents_view_win.h"
#include "chrome/common/url_constants.h"
#include "content/browser/download/drag_download_file.h"
#include "content/browser/download/drag_download_util.h"
#include "content/browser/tab_contents/web_drag_dest_win.h"
#include "content/browser/tab_contents/web_drag_source_win.h"
#include "content/browser/tab_contents/web_drag_utils_win.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
......@@ -133,8 +133,8 @@ void TabContentsDragWin::StartDragging(const WebDropData& drop_data,
}
// We do not want to drag and drop the download to itself.
old_drop_target_suspended_state_ = view_->drop_target()->suspended();
view_->drop_target()->set_suspended(true);
old_drop_target_suspended_state_ = view_->drag_dest()->suspended();
view_->drag_dest()->set_suspended(true);
// Start a background thread to do the drag-and-drop.
DCHECK(!drag_drop_thread_.get());
......@@ -334,7 +334,7 @@ void TabContentsDragWin::EndDragging(bool restore_suspended_state) {
drag_ended_ = true;
if (restore_suspended_state)
view_->drop_target()->set_suspended(old_drop_target_suspended_state_);
view_->drag_dest()->set_suspended(old_drop_target_suspended_state_);
if (msg_hook) {
AttachThreadInput(drag_out_thread_id, GetCurrentThreadId(), FALSE);
......
......@@ -2549,12 +2549,6 @@
'browser/tab_contents/web_drag_bookmark_handler_mac.mm',
'browser/tab_contents/web_drag_bookmark_handler_win.cc',
'browser/tab_contents/web_drag_bookmark_handler_win.h',
'browser/tab_contents/web_drag_source_win.cc',
'browser/tab_contents/web_drag_source_win.h',
'browser/tab_contents/web_drag_utils_win.cc',
'browser/tab_contents/web_drag_utils_win.h',
'browser/tab_contents/web_drop_target_win.cc',
'browser/tab_contents/web_drop_target_win.h',
'browser/tabs/default_tab_handler.cc',
'browser/tabs/default_tab_handler.h',
'browser/tabs/pinned_tab_codec.cc',
......
......@@ -16,7 +16,7 @@ class RenderWidgetHostViewWin;
class TabContentsViewWin : public content::WebContentsView,
public ui::WindowImpl {
public:
// TODO(jam): make this take a WebContents once it's created from content.
// TODO(jam): make this take a TabContents once it's created from content.
explicit TabContentsViewWin(content::WebContents* web_contents);
virtual ~TabContentsViewWin();
......
......@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/tab_contents/web_drop_target_win.h"
#include "content/browser/tab_contents/web_drag_dest_win.h"
#include <windows.h>
#include <shlobj.h>
#include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h"
#include "chrome/browser/tab_contents/web_drag_utils_win.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/web_drag_dest_delegate.h"
#include "content/browser/tab_contents/web_drag_utils_win.h"
#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
......@@ -46,7 +45,7 @@ DWORD GetPreferredDropEffect(DWORD effect) {
} // namespace
// InterstitialDropTarget is like a ui::DropTarget implementation that
// WebDropTarget passes through to if an interstitial is showing. Rather than
// WebDragDest passes through to if an interstitial is showing. Rather than
// passing messages on to the renderer, we just check to see if there's a link
// in the drop data and handle links as navigations.
class InterstitialDropTarget {
......@@ -87,23 +86,19 @@ class InterstitialDropTarget {
DISALLOW_COPY_AND_ASSIGN(InterstitialDropTarget);
};
WebDropTarget::WebDropTarget(HWND source_hwnd, WebContents* web_contents)
WebDragDest::WebDragDest(HWND source_hwnd, WebContents* web_contents)
: ui::DropTarget(source_hwnd),
web_contents_(web_contents),
current_rvh_(NULL),
drag_cursor_(WebDragOperationNone),
interstitial_drop_target_(new InterstitialDropTarget(web_contents)),
delegate_(new WebDragBookmarkHandlerWin()) {
delegate_(NULL) {
}
WebDropTarget::~WebDropTarget() {
// TODO(jam): this will be owned by chrome when it moves, so no scoped
// pointer.
if (delegate_)
delete delegate_;
WebDragDest::~WebDragDest() {
}
DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
DWORD WebDragDest::OnDragEnter(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effects) {
......@@ -143,7 +138,7 @@ DWORD WebDropTarget::OnDragEnter(IDataObject* data_object,
return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
}
DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
DWORD WebDragDest::OnDragOver(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effects) {
......@@ -167,7 +162,7 @@ DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
}
void WebDropTarget::OnDragLeave(IDataObject* data_object) {
void WebDragDest::OnDragLeave(IDataObject* data_object) {
DCHECK(current_rvh_);
if (current_rvh_ != web_contents_->GetRenderViewHost())
return;
......@@ -182,7 +177,7 @@ void WebDropTarget::OnDragLeave(IDataObject* data_object) {
delegate_->OnDragLeave(data_object);
}
DWORD WebDropTarget::OnDrop(IDataObject* data_object,
DWORD WebDragDest::OnDrop(IDataObject* data_object,
DWORD key_state,
POINT cursor_position,
DWORD effect) {
......
......@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_DROP_TARGET_WIN_H_
#define CHROME_BROWSER_TAB_CONTENTS_WEB_DROP_TARGET_WIN_H_
#ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_WIN_H_
#define CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_WIN_H_
#pragma once
#include "base/memory/scoped_ptr.h"
#include "content/common/content_export.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
#include "ui/base/dragdrop/drop_target.h"
......@@ -21,12 +22,12 @@ class WebDragDestDelegate;
// A helper object that provides drop capabilities to a TabContents. The
// DropTarget handles drags that enter the region of the WebContents by
// passing on the events to the renderer.
class WebDropTarget : public ui::DropTarget {
class CONTENT_EXPORT WebDragDest : public ui::DropTarget {
public:
// Create a new WebDropTarget associating it with the given HWND and
// Create a new WebDragDest associating it with the given HWND and
// WebContents.
WebDropTarget(HWND source_hwnd, content::WebContents* contents);
virtual ~WebDropTarget();
WebDragDest(HWND source_hwnd, content::WebContents* contents);
virtual ~WebDragDest();
void set_drag_cursor(WebKit::WebDragOperation op) {
drag_cursor_ = op;
......@@ -74,7 +75,7 @@ class WebDropTarget : public ui::DropTarget {
// A delegate that can receive drag information about drag events.
content::WebDragDestDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(WebDropTarget);
DISALLOW_COPY_AND_ASSIGN(WebDragDest);
};
#endif // CHROME_BROWSER_TAB_CONTENTS_WEB_DROP_TARGET_WIN_H_
#endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_DEST_WIN_H_
......@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/tab_contents/web_drag_source_win.h"
#include "content/browser/tab_contents/web_drag_source_win.h"
#include "base/bind.h"
#include "chrome/browser/tab_contents/web_drag_utils_win.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/web_drag_utils_win.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
......
......@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_
#define CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_
#ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_
#define CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_
#pragma once
#include "base/basictypes.h"
#include "content/common/content_export.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/base/dragdrop/drag_source.h"
......@@ -23,7 +24,7 @@ class WebContents;
// by an active drag-drop operation as the user mouses over other drop targets
// on their system. This object tells Windows whether or not the drag should
// continue, and supplies the appropriate cursors.
class WebDragSource : public ui::DragSource,
class CONTENT_EXPORT WebDragSource : public ui::DragSource,
public content::NotificationObserver {
public:
// Create a new DragSource for a given HWND and WebContents.
......@@ -67,4 +68,4 @@ class WebDragSource : public ui::DragSource,
DISALLOW_COPY_AND_ASSIGN(WebDragSource);
};
#endif // CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_
#endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_WIN_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/tab_contents/web_drag_utils_win.h"
#include "content/browser/tab_contents/web_drag_utils_win.h"
#include <oleidl.h>
#include "base/logging.h"
......
......@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_UTILS_WIN_H_
#define CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_UTILS_WIN_H_
#ifndef CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_UTILS_WIN_H_
#define CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_UTILS_WIN_H_
#pragma once
#include "content/common/content_export.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
#include <windows.h>
......@@ -16,9 +17,9 @@ WebKit::WebDragOperation WinDragOpToWebDragOp(DWORD effect);
WebKit::WebDragOperationsMask WinDragOpMaskToWebDragOpMask(DWORD effects);
DWORD WebDragOpToWinDragOp(WebKit::WebDragOperation op);
DWORD WebDragOpMaskToWinDragOpMask(WebKit::WebDragOperationsMask ops);
CONTENT_EXPORT DWORD WebDragOpMaskToWinDragOpMask(
WebKit::WebDragOperationsMask ops);
} // namespace web_drag_utils_win
#endif // CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_UTILS_WIN_H_
#endif // CONTENT_BROWSER_TAB_CONTENTS_WEB_DRAG_UTILS_WIN_H_
......@@ -658,10 +658,16 @@
'browser/tab_contents/web_drag_dest_gtk.h',
'browser/tab_contents/web_drag_dest_mac.h',
'browser/tab_contents/web_drag_dest_mac.mm',
'browser/tab_contents/web_drag_dest_win.cc',
'browser/tab_contents/web_drag_dest_win.h',
'browser/tab_contents/web_drag_source_gtk.cc',
'browser/tab_contents/web_drag_source_gtk.h',
'browser/tab_contents/web_drag_source_mac.h',
'browser/tab_contents/web_drag_source_mac.mm',
'browser/tab_contents/web_drag_source_win.cc',
'browser/tab_contents/web_drag_source_win.h',
'browser/tab_contents/web_drag_utils_win.cc',
'browser/tab_contents/web_drag_utils_win.h',
'browser/trace_controller.cc',
'browser/trace_controller.h',
'browser/trace_message_filter.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment