summaryrefslogtreecommitdiffstats
path: root/ui/wm/public/scoped_drag_drop_disabler.h
blob: 4f708eede559f988107ab1b7b9f33ee254439fa9 (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
// 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.

#ifndef UI_WM_PUBLIC_SCOPED_DRAG_DROP_DISABLER_H_
#define UI_WM_PUBLIC_SCOPED_DRAG_DROP_DISABLER_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/window_observer.h"

namespace aura {
class Window;

namespace client {
class DragDropClient;

// ScopedDragDropDisabler is used to temporarily replace the drag'n'drop client
// for a window with a "no-op" client. Upon construction, it installs a new
// client on the window, and upon destruction, it restores the previous one.
class AURA_EXPORT ScopedDragDropDisabler : public WindowObserver {
 public:
  explicit ScopedDragDropDisabler(Window* window);
  ~ScopedDragDropDisabler() override;

 private:
  // WindowObserver:
  void OnWindowDestroyed(Window* window) override;

  Window* window_;
  DragDropClient* old_client_;
  scoped_ptr<DragDropClient> new_client_;

  DISALLOW_COPY_AND_ASSIGN(ScopedDragDropDisabler);
};

}  // namespace client
}  // namespace aura

#endif  // UI_WM_PUBLIC_SCOPED_DRAG_DROP_DISABLER_H_