forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrag_drop_delegate.h
57 lines (43 loc) · 1.81 KB
/
drag_drop_delegate.h
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
56
57
// Copyright 2018 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 SERVICES_WS_DRAG_DROP_DELEGATE_H_
#define SERVICES_WS_DRAG_DROP_DELEGATE_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "services/ws/ids.h"
#include "services/ws/public/mojom/window_tree.mojom.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/base/dragdrop/drag_drop_types.h"
namespace ws {
// A delegate to forward drag and drop events to a remote client window via
// mojom::WindowTreeClient.
class DragDropDelegate : public aura::client::DragDropDelegate {
public:
DragDropDelegate(mojom::WindowTreeClient* window_tree_client,
aura::Window* window,
Id transport_window_id);
~DragDropDelegate() override;
// aura::client::DragDropDelegate:
void OnDragEntered(const ui::DropTargetEvent& event) override;
int OnDragUpdated(const ui::DropTargetEvent& event) override;
void OnDragExited() override;
int OnPerformDrop(const ui::DropTargetEvent& event) override;
private:
void StartDrag(const ui::DropTargetEvent& event);
void EndDrag();
// Callback invoked to update |last_drag_operations_|.
void UpdateDragOperations(uint32_t drag_operations);
mojom::WindowTreeClient* const tree_client_;
aura::Window* const window_;
const Id transport_window_id_;
// Whether a drag is over |window_|.
bool in_drag_ = false;
// Cached drag operations as a workaround to return drag operations for
// synchronous OnDragUpdated.
uint32_t last_drag_operations_ = ui::DragDropTypes::DRAG_NONE;
base::WeakPtrFactory<DragDropDelegate> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(DragDropDelegate);
};
} // namespace ws
#endif // SERVICES_WS_DRAG_DROP_DELEGATE_H_