diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 21:58:18 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 21:58:18 +0000 |
commit | 8c3dc79bc13ba84f418d3c135e1bf296a3e29722 (patch) | |
tree | 32eb9688d500a90eb74a7c4f8cb5a97e507dd0fc /views | |
parent | abaccb2cb8cff8138e5ea9daf420645e5852c9eb (diff) | |
download | chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.zip chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.gz chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.bz2 |
Refactors OSExchangeData for easier portability.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/164401
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/menu/chrome_menu.cc | 11 | ||||
-rw-r--r-- | views/drag_utils_win.cc | 8 | ||||
-rw-r--r-- | views/view_win.cc | 8 | ||||
-rw-r--r-- | views/widget/drop_target_win.cc | 7 |
4 files changed, 20 insertions, 14 deletions
diff --git a/views/controls/menu/chrome_menu.cc b/views/controls/menu/chrome_menu.cc index 1bd7b53..351e082 100644 --- a/views/controls/menu/chrome_menu.cc +++ b/views/controls/menu/chrome_menu.cc @@ -13,6 +13,7 @@ #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/os_exchange_data.h" +#include "app/os_exchange_data_provider_win.h" #include "base/base_drag_source.h" #include "base/gfx/native_theme.h" #include "base/message_loop.h" @@ -892,6 +893,8 @@ void SubmenuView::PaintChildren(gfx::Canvas* canvas) { PaintDropIndicator(canvas, drop_item_, drop_position_); } +// TODO(sky): need to add support for new dnd methods for Linux. + bool SubmenuView::CanDrop(const OSExchangeData& data) { DCHECK(GetMenuItem()->GetMenuController()); return GetMenuItem()->GetMenuController()->CanDrop(this, data); @@ -1835,17 +1838,17 @@ void MenuController::OnMouseDragged(SubmenuView* source, gfx::Canvas canvas(item->width(), item->height(), false); item->Paint(&canvas, true); - scoped_refptr<OSExchangeData> data(new OSExchangeData); - item->GetDelegate()->WriteDragData(item, data.get()); + OSExchangeData data; + item->GetDelegate()->WriteDragData(item, &data); drag_utils::SetDragImageOnDataObject(canvas, item->width(), item->height(), press_loc.x(), - press_loc.y(), data); + press_loc.y(), &data); scoped_refptr<BaseDragSource> drag_source(new BaseDragSource); int drag_ops = item->GetDelegate()->GetDragOperations(item); DWORD effects; StopScrolling(); - DoDragDrop(data, drag_source, + DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source, DragDropTypes::DragOperationToDropEffect(drag_ops), &effects); if (GetActiveInstance() == this) { diff --git a/views/drag_utils_win.cc b/views/drag_utils_win.cc index ed01386..b2d35f2 100644 --- a/views/drag_utils_win.cc +++ b/views/drag_utils_win.cc @@ -10,6 +10,7 @@ #include "app/gfx/canvas.h" #include "app/os_exchange_data.h" +#include "app/os_exchange_data_provider_win.h" #include "base/gfx/gdi_util.h" namespace drag_utils { @@ -69,10 +70,9 @@ void SetDragImageOnDataObject(const gfx::Canvas& canvas, HBITMAP bitmap = CreateBitmapFromCanvas(canvas, width, height); // Attach 'bitmap' to the data_object. - SetDragImageOnDataObject(bitmap, width, height, - cursor_x_offset, - cursor_y_offset, - data_object); + SetDragImageOnDataObject( + bitmap, width, height, cursor_x_offset, cursor_y_offset, + OSExchangeDataProviderWin::GetIDataObject(*data_object)); } } // namespace drag_utils diff --git a/views/view_win.cc b/views/view_win.cc index bf265f9..f0d71c4 100644 --- a/views/view_win.cc +++ b/views/view_win.cc @@ -8,6 +8,7 @@ #include "app/gfx/canvas.h" #include "app/gfx/path.h" #include "app/os_exchange_data.h" +#include "app/os_exchange_data_provider_win.h" #include "base/scoped_handle.h" #include "base/string_util.h" #include "views/accessibility/view_accessibility_wrapper.h" @@ -22,13 +23,14 @@ void View::DoDrag(const MouseEvent& e, int press_x, int press_y) { if (drag_operations == DragDropTypes::DRAG_NONE) return; - scoped_refptr<OSExchangeData> data = new OSExchangeData; - WriteDragData(press_x, press_y, data.get()); + OSExchangeData data; + WriteDragData(press_x, press_y, &data); // Message the RootView to do the drag and drop. That way if we're removed // the RootView can detect it and avoid calling us back. RootView* root_view = GetRootView(); - root_view->StartDragForViewFromMouseEvent(this, data, drag_operations); + root_view->StartDragForViewFromMouseEvent( + this, OSExchangeDataProviderWin::GetIDataObject(data), drag_operations); } ViewAccessibilityWrapper* View::GetViewAccessibilityWrapper() { diff --git a/views/widget/drop_target_win.cc b/views/widget/drop_target_win.cc index 69800ca..7a90a64 100644 --- a/views/widget/drop_target_win.cc +++ b/views/widget/drop_target_win.cc @@ -6,6 +6,7 @@ #include "app/drag_drop_types.h" #include "app/os_exchange_data.h" +#include "app/os_exchange_data_provider_win.h" #include "base/gfx/point.h" #include "views/widget/root_view.h" #include "views/widget/widget.h" @@ -30,9 +31,9 @@ DWORD DropTargetWin::OnDragOver(IDataObject* data_object, DWORD effect) { gfx::Point root_view_location(cursor_position.x, cursor_position.y); View::ConvertPointToView(NULL, helper_.root_view(), &root_view_location); + OSExchangeData data(new OSExchangeDataProviderWin(data_object)); int drop_operation = - helper_.OnDragOver(OSExchangeData(data_object), - root_view_location, + helper_.OnDragOver(data, root_view_location, DragDropTypes::DropEffectToDragOperation(effect)); return DragDropTypes::DragOperationToDropEffect(drop_operation); } @@ -48,7 +49,7 @@ DWORD DropTargetWin::OnDrop(IDataObject* data_object, gfx::Point root_view_location(cursor_position.x, cursor_position.y); View::ConvertPointToView(NULL, helper_.root_view(), &root_view_location); - OSExchangeData data(data_object); + OSExchangeData data(new OSExchangeDataProviderWin(data_object)); int drop_operation = DragDropTypes::DropEffectToDragOperation(effect); drop_operation = helper_.OnDragOver(data, root_view_location, drop_operation); |