blob: aaeb56df05167c7d8b7e71247a3c1001c40c29f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2015 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.
#include "ui/wm/public/scoped_drag_drop_disabler.h"
#include "ui/aura/window.h"
#include "ui/wm/public/drag_drop_client.h"
namespace aura {
namespace client {
class NopDragDropClient : public DragDropClient {
public:
~NopDragDropClient() override {}
int StartDragAndDrop(const ui::OSExchangeData& data,
aura::Window* root_window,
aura::Window* source_window,
const gfx::Point& screen_location,
int operation,
ui::DragDropTypes::DragEventSource source) override {
return 0;
}
void DragUpdate(aura::Window* target,
const ui::LocatedEvent& event) override {}
void Drop(aura::Window* target, const ui::LocatedEvent& event) override {}
void DragCancel() override {}
bool IsDragDropInProgress() override {
return false;
}
};
ScopedDragDropDisabler::ScopedDragDropDisabler(Window* window)
: window_(window),
old_client_(GetDragDropClient(window)),
new_client_(new NopDragDropClient()) {
SetDragDropClient(window_, new_client_.get());
window_->AddObserver(this);
}
ScopedDragDropDisabler::~ScopedDragDropDisabler() {
if (window_) {
window_->RemoveObserver(this);
SetDragDropClient(window_, old_client_);
}
}
void ScopedDragDropDisabler::OnWindowDestroyed(Window* window) {
CHECK_EQ(window_, window);
window_ = NULL;
new_client_.reset();
}
} // namespace client
} // namespace aura
|