summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/login/ui/login_display_host_impl.cc4
-rw-r--r--chrome/browser/chromeos/login/ui/login_display_host_impl.h5
-rw-r--r--ui/aura/BUILD.gn2
-rw-r--r--ui/aura/aura.gyp2
-rw-r--r--ui/wm/public/scoped_drag_drop_disabler.cc55
-rw-r--r--ui/wm/public/scoped_drag_drop_disabler.h40
6 files changed, 108 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc
index 4cd0452..38b426a 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/ui/login_display_host_impl.cc
@@ -373,6 +373,10 @@ LoginDisplayHostImpl::LoginDisplayHostImpl(const gfx::Rect& background_bounds)
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
manager->Initialize(chromeos::SOUND_STARTUP,
bundle.GetRawDataResource(IDR_SOUND_STARTUP_WAV));
+
+ // Disable Drag'n'Drop for the login session.
+ scoped_drag_drop_disabler_.reset(new aura::client::ScopedDragDropDisabler(
+ ash::Shell::GetPrimaryRootWindow()));
}
LoginDisplayHostImpl::~LoginDisplayHostImpl() {
diff --git a/chrome/browser/chromeos/login/ui/login_display_host_impl.h b/chrome/browser/chromeos/login/ui/login_display_host_impl.h
index f12b77d..00624fd 100644
--- a/chrome/browser/chromeos/login/ui/login_display_host_impl.h
+++ b/chrome/browser/chromeos/login/ui/login_display_host_impl.h
@@ -29,6 +29,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/keyboard/keyboard_controller_observer.h"
#include "ui/views/widget/widget_removals_observer.h"
+#include "ui/wm/public/scoped_drag_drop_disabler.h"
class PrefService;
@@ -311,6 +312,10 @@ class LoginDisplayHostImpl : public LoginDisplayHost,
// True if the host is showing a new version of OOBE screen.
bool is_new_oobe_;
+ // Keeps a copy of the old Drag'n'Drop client, so that it would be disabled
+ // during a login session and restored afterwards.
+ scoped_ptr<aura::client::ScopedDragDropDisabler> scoped_drag_drop_disabler_;
+
base::WeakPtrFactory<LoginDisplayHostImpl> pointer_factory_;
base::WeakPtrFactory<LoginDisplayHostImpl> animation_weak_ptr_factory_;
diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn
index 83e65f0..dfcad8a 100644
--- a/ui/aura/BUILD.gn
+++ b/ui/aura/BUILD.gn
@@ -21,6 +21,8 @@ component("aura") {
"../wm/public/drag_drop_client.h",
"../wm/public/drag_drop_delegate.cc",
"../wm/public/drag_drop_delegate.h",
+ "../wm/public/scoped_drag_drop_disabler.cc",
+ "../wm/public/scoped_drag_drop_disabler.h",
"../wm/public/scoped_tooltip_disabler.cc",
"../wm/public/scoped_tooltip_disabler.h",
"../wm/public/tooltip_client.cc",
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 1385482..34a2e521 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -43,6 +43,8 @@
'../wm/public/drag_drop_client.h',
'../wm/public/drag_drop_delegate.cc',
'../wm/public/drag_drop_delegate.h',
+ '../wm/public/scoped_drag_drop_disabler.cc',
+ '../wm/public/scoped_drag_drop_disabler.h',
'../wm/public/scoped_tooltip_disabler.cc',
'../wm/public/scoped_tooltip_disabler.h',
'../wm/public/tooltip_client.cc',
diff --git a/ui/wm/public/scoped_drag_drop_disabler.cc b/ui/wm/public/scoped_drag_drop_disabler.cc
new file mode 100644
index 0000000..aaeb56d
--- /dev/null
+++ b/ui/wm/public/scoped_drag_drop_disabler.cc
@@ -0,0 +1,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
diff --git a/ui/wm/public/scoped_drag_drop_disabler.h b/ui/wm/public/scoped_drag_drop_disabler.h
new file mode 100644
index 0000000..4f708ee
--- /dev/null
+++ b/ui/wm/public/scoped_drag_drop_disabler.h
@@ -0,0 +1,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_