summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 07:12:22 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 07:12:22 +0000
commit16f17f5edd89d6b6a41709a9946a0183f5754c35 (patch)
tree1f887f3366390790c28f7b6b92a77f64994e48e6 /chrome/browser
parentb9a4ea7fbdc54868b60d50bc5fade451718dec23 (diff)
downloadchromium_src-16f17f5edd89d6b6a41709a9946a0183f5754c35.zip
chromium_src-16f17f5edd89d6b6a41709a9946a0183f5754c35.tar.gz
chromium_src-16f17f5edd89d6b6a41709a9946a0183f5754c35.tar.bz2
Chrome/win: Show preview images when dragging images.
BUG=11457 TEST=Go to google.com, drag logo around. Should be attached to cursor. Review URL: http://codereview.chromium.org/2870026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_drag_win.cc27
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_drag_win.h14
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc3
3 files changed, 31 insertions, 13 deletions
diff --git a/chrome/browser/views/tab_contents/tab_contents_drag_win.cc b/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
index 37bebf5..f1e22da 100644
--- a/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_drag_win.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/views/tab_contents/tab_contents_view_win.h"
#include "chrome/common/url_constants.h"
#include "net/base/net_util.h"
+#include "views/drag_utils.h"
#include "webkit/glue/webdropdata.h"
using WebKit::WebDragOperationsMask;
@@ -108,7 +109,9 @@ TabContentsDragWin::~TabContentsDragWin() {
}
void TabContentsDragWin::StartDragging(const WebDropData& drop_data,
- WebDragOperationsMask ops) {
+ WebDragOperationsMask ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
drag_source_ = new WebDragSource(view_->GetNativeView(),
@@ -119,7 +122,7 @@ void TabContentsDragWin::StartDragging(const WebDropData& drop_data,
// If it is not drag-out, do the drag-and-drop in the current UI thread.
if (drop_data.download_metadata.empty()) {
- DoDragging(drop_data, ops, page_url, page_encoding);
+ DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset);
EndDragging(false);
return;
}
@@ -141,7 +144,9 @@ void TabContentsDragWin::StartDragging(const WebDropData& drop_data,
drop_data,
ops,
page_url,
- page_encoding));
+ page_encoding,
+ image,
+ image_offset));
}
// Install a hook procedure to monitor the messages so that we can forward
@@ -163,10 +168,12 @@ void TabContentsDragWin::StartBackgroundDragging(
const WebDropData& drop_data,
WebDragOperationsMask ops,
const GURL& page_url,
- const std::string& page_encoding) {
+ const std::string& page_encoding,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
drag_drop_thread_id_ = PlatformThread::CurrentId();
- DoDragging(drop_data, ops, page_url, page_encoding);
+ DoDragging(drop_data, ops, page_url, page_encoding, image, image_offset);
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this, &TabContentsDragWin::EndDragging, true));
@@ -260,11 +267,11 @@ void TabContentsDragWin::PrepareDragForUrl(const WebDropData& drop_data,
void TabContentsDragWin::DoDragging(const WebDropData& drop_data,
WebDragOperationsMask ops,
const GURL& page_url,
- const std::string& page_encoding) {
+ const std::string& page_encoding,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
OSExchangeData data;
- // TODO(tc): Generate an appropriate drag image.
-
if (!drop_data.download_metadata.empty()) {
PrepareDragForDownload(drop_data, &data, page_url, page_encoding);
@@ -284,6 +291,10 @@ void TabContentsDragWin::DoDragging(const WebDropData& drop_data,
data.SetString(drop_data.plain_text);
}
+ // Set drag image.
+ drag_utils::SetDragImageOnDataObject(
+ image, gfx::Size(image.width(), image.height()), image_offset, &data);
+
// Keep a local reference to drag_source_ in case that EndDragging is called
// before DoDragDrop returns.
scoped_refptr<WebDragSource> drag_source(drag_source_);
diff --git a/chrome/browser/views/tab_contents/tab_contents_drag_win.h b/chrome/browser/views/tab_contents/tab_contents_drag_win.h
index 36f7068..bfa2b12 100644
--- a/chrome/browser/views/tab_contents/tab_contents_drag_win.h
+++ b/chrome/browser/views/tab_contents/tab_contents_drag_win.h
@@ -9,6 +9,8 @@
#include "base/platform_thread.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "gfx/point.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
class DragDropThread;
@@ -30,7 +32,9 @@ class TabContentsDragWin
// Called on UI thread.
void StartDragging(const WebDropData& drop_data,
- WebKit::WebDragOperationsMask ops);
+ WebKit::WebDragOperationsMask ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset);
void CancelDrag();
// DataObjectImpl::Observer implementation.
@@ -50,13 +54,17 @@ class TabContentsDragWin
void DoDragging(const WebDropData& drop_data,
WebKit::WebDragOperationsMask ops,
const GURL& page_url,
- const std::string& page_encoding);
+ const std::string& page_encoding,
+ const SkBitmap& image,
+ const gfx::Point& image_offset);
// Called on drag-and-drop thread.
void StartBackgroundDragging(const WebDropData& drop_data,
WebKit::WebDragOperationsMask ops,
const GURL& page_url,
- const std::string& page_encoding);
+ const std::string& page_encoding,
+ const SkBitmap& image,
+ const gfx::Point& image_offset);
// Called on UI thread.
void EndDragging(bool restore_suspended_state);
void CloseThread();
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index 0774fea..6c70040 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -129,8 +129,7 @@ void TabContentsViewWin::StartDragging(const WebDropData& drop_data,
const SkBitmap& image,
const gfx::Point& image_offset) {
drag_handler_ = new TabContentsDragWin(this);
- // TODO(estade): make use of |image| and |image_offset|.
- drag_handler_->StartDragging(drop_data, ops);
+ drag_handler_->StartDragging(drop_data, ops, image, image_offset);
}
void TabContentsViewWin::EndDragging() {