1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/wm/public/scoped_drag_drop_disabler.h"
7 #include "ui/aura/window.h"
8 #include "ui/wm/public/drag_drop_client.h"
13 class NopDragDropClient
: public DragDropClient
{
15 ~NopDragDropClient() override
{}
16 int StartDragAndDrop(const ui::OSExchangeData
& data
,
17 aura::Window
* root_window
,
18 aura::Window
* source_window
,
19 const gfx::Point
& screen_location
,
21 ui::DragDropTypes::DragEventSource source
) override
{
24 void DragUpdate(aura::Window
* target
,
25 const ui::LocatedEvent
& event
) override
{}
26 void Drop(aura::Window
* target
, const ui::LocatedEvent
& event
) override
{}
27 void DragCancel() override
{}
28 bool IsDragDropInProgress() override
{
33 ScopedDragDropDisabler::ScopedDragDropDisabler(Window
* window
)
35 old_client_(GetDragDropClient(window
)),
36 new_client_(new NopDragDropClient()) {
37 SetDragDropClient(window_
, new_client_
.get());
38 window_
->AddObserver(this);
41 ScopedDragDropDisabler::~ScopedDragDropDisabler() {
43 window_
->RemoveObserver(this);
44 SetDragDropClient(window_
, old_client_
);
48 void ScopedDragDropDisabler::OnWindowDestroyed(Window
* window
) {
49 CHECK_EQ(window_
, window
);