Commit 8e37fbee authored by sky's avatar sky Committed by Commit bot

Removes aura::Window::set_user_data()

It overlaps with properties, and properties add type safety.

BUG=none
TEST=none
R=ben@chromium.org

Review-Url: https://codereview.chromium.org/2610203002
Cr-Commit-Position: refs/heads/master@{#441474}
parent 9a7c0efc
......@@ -59,7 +59,6 @@ Window::Window(WindowDelegate* delegate, std::unique_ptr<WindowPort> port)
visible_(false),
id_(kInitialId),
transparent_(false),
user_data_(nullptr),
ignore_events_(false),
// Don't notify newly added observers during notification. This causes
// problems for code that adds an observer as part of an observer
......
......@@ -135,10 +135,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void set_host(WindowTreeHost* host) { host_ = host; }
bool IsRootWindow() const { return !!host_; }
// The Window does not own this object.
void set_user_data(void* user_data) { user_data_ = user_data; }
void* user_data() const { return user_data_; }
// Changes the visibility of the window.
void Show();
void Hide();
......@@ -507,8 +503,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
std::unique_ptr<LayoutManager> layout_manager_;
std::unique_ptr<ui::EventTargeter> targeter_;
void* user_data_;
// Makes the window pass all events through to any windows behind it.
bool ignore_events_;
......
......@@ -25,6 +25,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_property.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/ui_base_types.h"
......@@ -69,10 +70,16 @@
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
#endif
DECLARE_WINDOW_PROPERTY_TYPE(views::internal::NativeWidgetPrivate*)
namespace views {
namespace {
DEFINE_WINDOW_PROPERTY_KEY(internal::NativeWidgetPrivate*,
kNativeWidgetPrivateKey,
nullptr);
void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) {
window->SetProperty(aura::client::kRestoreBoundsKey, new gfx::Rect(bounds));
}
......@@ -110,7 +117,7 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate,
void NativeWidgetAura::RegisterNativeWidgetForWindow(
internal::NativeWidgetPrivate* native_widget,
aura::Window* window) {
window->set_user_data(native_widget);
window->SetProperty(kNativeWidgetPrivateKey, native_widget);
}
// static
......@@ -1103,15 +1110,13 @@ NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
// static
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
gfx::NativeView native_view) {
// Cast must match type supplied to RegisterNativeWidgetForWindow().
return reinterpret_cast<NativeWidgetPrivate*>(native_view->user_data());
return native_view->GetProperty(kNativeWidgetPrivateKey);
}
// static
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) {
// Cast must match type supplied to RegisterNativeWidgetForWindow().
return reinterpret_cast<NativeWidgetPrivate*>(native_window->user_data());
return native_window->GetProperty(kNativeWidgetPrivateKey);
}
// static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment