 Chromium Code Reviews
 Chromium Code Reviews Issue 1964283002:
  MacViews: Implemented Drag & Drop  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1964283002:
  MacViews: Implemented Drag & Drop  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: ui/views/cocoa/drag_drop_client_mac.h | 
| diff --git a/ui/views/cocoa/drag_drop_client_mac.h b/ui/views/cocoa/drag_drop_client_mac.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..362261436292f7f14557007928fe82c89310c544 | 
| --- /dev/null | 
| +++ b/ui/views/cocoa/drag_drop_client_mac.h | 
| @@ -0,0 +1,101 @@ | 
| +// Copyright 2016 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef UI_VIEWS_COCOA_DRAG_DROP_CLIENT_MAC_H_ | 
| +#define UI_VIEWS_COCOA_DRAG_DROP_CLIENT_MAC_H_ | 
| + | 
| +#import <Cocoa/Cocoa.h> | 
| + | 
| +#include <memory> | 
| +#include <vector> | 
| 
tapted
2016/05/31 11:49:58
remove? (seems unused)
 
spqchan
2016/05/31 23:06:12
Done.
 | 
| + | 
| +#import "base/mac/scoped_nsobject.h" | 
| +#include "base/macros.h" | 
| +#include "ui/base/dragdrop/drag_drop_types.h" | 
| +#include "ui/views/views_export.h" | 
| +#include "ui/views/widget/drop_helper.h" | 
| 
tapted
2016/05/31 11:49:58
remove? (forward declare should work - see below).
 
spqchan
2016/05/31 23:06:12
Done.
 | 
| + | 
| +class DropHelper; | 
| 
tapted
2016/05/31 11:49:58
should this be in namespace views {?
 
spqchan
2016/05/31 23:06:12
Done.
 | 
| + | 
| +// This class acts as a bridge between NSPasteboardItem and OSExchangeData by | 
| +// implementing NSPasteboardItemDataProvider and writing data from | 
| +// OSExchangeData into the pasteboard. | 
| +VIEWS_EXPORT | 
| +@interface CocoaDragDropDataProvider : NSObject<NSPasteboardItemDataProvider> | 
| + | 
| 
tapted
2016/05/31 11:49:58
nit: remove blank line
 
spqchan
2016/05/31 23:06:12
Done.
 | 
| +- (id)initWithData:(const ui::OSExchangeData&)data; | 
| + | 
| 
tapted
2016/05/31 11:49:58
nit: remove blank line
 
spqchan
2016/05/31 23:06:12
Done.
 | 
| +@end | 
| + | 
| +namespace gfx { | 
| +class Point; | 
| +} | 
| + | 
| +namespace ui { | 
| +class OSExchangeData; | 
| +} | 
| + | 
| +namespace views { | 
| +namespace test { | 
| +class CocoaDragDropTest; | 
| +} | 
| + | 
| +class BridgedNativeWidget; | 
| + | 
| +// Implements drag and drop on MacViews. This class acts as a bridge between | 
| +// the Views and native system's drag and drop. This class mimics | 
| +// DesktopDragDropClientAuraX11. | 
| +class VIEWS_EXPORT DragDropClientMac { | 
| + public: | 
| + explicit DragDropClientMac(BridgedNativeWidget* view); | 
| + ~DragDropClientMac(); | 
| + | 
| + // Initiates a drag and drop session. Returns the drag operation that was | 
| + // applied at the end of the drag drop session. | 
| + void StartDragAndDrop(View* view, | 
| + const ui::OSExchangeData& data, | 
| + const gfx::Point& location, | 
| + int operation, | 
| + ui::DragDropTypes::DragEventSource source); | 
| + | 
| + // Called when mouse is dragged during a drag and drop. | 
| + NSDragOperation DragUpdate(id<NSDraggingInfo>); | 
| + | 
| + // Called when mouse is released during a drag and drop. | 
| + NSDragOperation Drop(id<NSDraggingInfo> sender); | 
| + | 
| + // Called when the drag and drop session has ended. | 
| + void EndDrag(); | 
| + | 
| + // Calls when the the views::View bridged by the content view is set or | 
| + // cleared. | 
| + void SetRootView(View* view); | 
| + | 
| + private: | 
| + friend class test::CocoaDragDropTest; | 
| + | 
| + // Converts the given NSPoint to the coordinate system in Views. | 
| + gfx::Point LocationInView(NSPoint point) const; | 
| + | 
| + // Provides the data for the drag and drop session. | 
| + base::scoped_nsobject<CocoaDragDropDataProvider> data_source_; | 
| + | 
| + // Used to handle drag and drop with Views. | 
| + std::unique_ptr<DropHelper> drop_helper_; | 
| + | 
| + // The drag and drop operation. | 
| + int operation_; | 
| + | 
| + // The source of the drag. | 
| + View* view_; | 
| 
tapted
2016/05/31 11:49:58
This seems unused -- can we remove it? In fact nei
 
spqchan
2016/05/31 23:06:12
Done.
 | 
| + | 
| + // The bridge between the content view and the drag drop client. | 
| + BridgedNativeWidget* bridge_; // Weak. Owns |this|. | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(DragDropClientMac); | 
| +}; | 
| + | 
| +} // namespace views | 
| + | 
| +#endif // UI_VIEWS_COCOA_DRAG_DROP_CLIENT_MAC_H_ |