Remove wpr.archive_info dependancy on page to avoid circular dependancies.
[chromium-blink-merge.git] / ui / wm / public / scoped_drag_drop_disabler.cc
blobaaeb56df05167c7d8b7e71247a3c1001c40c29f9
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"
10 namespace aura {
11 namespace client {
13 class NopDragDropClient : public DragDropClient {
14 public:
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,
20 int operation,
21 ui::DragDropTypes::DragEventSource source) override {
22 return 0;
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 {
29 return false;
33 ScopedDragDropDisabler::ScopedDragDropDisabler(Window* window)
34 : 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() {
42 if (window_) {
43 window_->RemoveObserver(this);
44 SetDragDropClient(window_, old_client_);
48 void ScopedDragDropDisabler::OnWindowDestroyed(Window* window) {
49 CHECK_EQ(window_, window);
50 window_ = NULL;
51 new_client_.reset();
54 } // namespace client
55 } // namespace aura