Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Unified Diff: views/widget/native_widget_aura.cc

Issue 8450018: First shot at implementing drag&drop for Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added missing test file Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/aura_shell/drag_drop_controller.cc ('K') | « views/widget/native_widget_aura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/native_widget_aura.cc
diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc
index 8da5452a3bda5237fb9ef22eab9ea92d92fbd19f..0316b5669bf6adde47dcd6fdea9f9e6a4af26aa3 100644
--- a/views/widget/native_widget_aura.cc
+++ b/views/widget/native_widget_aura.cc
@@ -5,17 +5,21 @@
#include "views/widget/native_widget_aura.h"
#include "base/bind.h"
+#include "base/string_util.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/desktop.h"
#include "ui/aura/desktop_observer.h"
#include "ui/aura/event.h"
#include "ui/aura/window.h"
#include "ui/aura/window_types.h"
+#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/font.h"
#include "ui/gfx/screen.h"
+#include "views/widget/drop_helper.h"
#include "views/widget/native_widget_delegate.h"
#include "views/widget/tooltip_manager_views.h"
@@ -93,6 +97,7 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
can_activate_(true),
cursor_(gfx::kNullCursor) {
+ window_->set_drag_drop_delegate(this);
}
NativeWidgetAura::~NativeWidgetAura() {
@@ -148,12 +153,13 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
// TODO(beng): do this some other way.
delegate_->OnNativeWidgetSizeChanged(params.bounds.size());
can_activate_ = params.can_activate;
+ DCHECK(GetWidget()->GetRootView());
if (params.type != Widget::InitParams::TYPE_TOOLTIP && !params.child) {
- DCHECK(GetWidget()->GetRootView());
views::TooltipManagerViews* manager = new views::TooltipManagerViews(
GetWidget()->GetRootView());
tooltip_manager_.reset(manager);
}
+ drop_helper_.reset(new DropHelper(GetWidget()->GetRootView()));
}
NonClientFrameView* NativeWidgetAura::CreateNonClientFrameView() {
@@ -464,8 +470,8 @@ bool NativeWidgetAura::IsAccessibleWidget() const {
void NativeWidgetAura::RunShellDrag(View* view,
const ui::OSExchangeData& data,
int operation) {
- // http://crbug.com/97845
- NOTIMPLEMENTED();
+ aura::Desktop::GetInstance()->drag_drop_client()->StartDragAndDrop(
+ data, operation);
}
void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) {
@@ -633,6 +639,37 @@ void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) {
delegate_->OnNativeWidgetVisibilityChanged(visible);
}
+bool NativeWidgetAura::CanDrop(const aura::DropTargetEvent& event) {
+ DCHECK(drop_helper_.get() != NULL);
+ View* view = drop_helper_->target_view();
+ if (view)
+ return view->CanDrop(event.data());
+ return false;
+}
+
+void NativeWidgetAura::OnDragEntered(const aura::DropTargetEvent& event) {
+ DCHECK(drop_helper_.get() != NULL);
+ drop_helper_->OnDragOver(event.data(), event.location(),
+ event.source_operations());
+}
+
+int NativeWidgetAura::OnDragUpdated(const aura::DropTargetEvent& event) {
+ DCHECK(drop_helper_.get() != NULL);
+ return drop_helper_->OnDragOver(event.data(), event.location(),
+ event.source_operations());
+}
+
+void NativeWidgetAura::OnDragExited() {
+ DCHECK(drop_helper_.get() != NULL);
+ drop_helper_->OnDragExit();
+}
+
+int NativeWidgetAura::OnPerformDrop(const aura::DropTargetEvent& event) {
+ DCHECK(drop_helper_.get() != NULL);
+ return drop_helper_->OnDrop(event.data(), event.location(),
+ event.source_operations());
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, public:
« ui/aura_shell/drag_drop_controller.cc ('K') | « views/widget/native_widget_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698