summaryrefslogtreecommitdiffstats
path: root/ui/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 19:56:02 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 19:56:02 +0000
commit0646c51b5cfe8cf356617eca9bf2f91e8e01d776 (patch)
treee9547e19a5bb7a3682653ca079b980b8e49fa6e0 /ui/views/widget
parentcf9aca16a5771d0e1c065ff1ddd347e09fc6eac5 (diff)
downloadchromium_src-0646c51b5cfe8cf356617eca9bf2f91e8e01d776.zip
chromium_src-0646c51b5cfe8cf356617eca9bf2f91e8e01d776.tar.gz
chromium_src-0646c51b5cfe8cf356617eca9bf2f91e8e01d776.tar.bz2
Makes NativeWidgetAura and DesktopNWA set user_data using same type
Right now this works because both classes have NativeWidgetPrivate as their first superclass, but that is fragile. This makes both register using the same function so that the type is enforced. BUG=none TEST=none R=pkotwicz@chromium.org Review URL: https://chromiumcodereview.appspot.com/22793013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/widget')
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc3
-rw-r--r--ui/views/widget/native_widget_aura.cc11
-rw-r--r--ui/views/widget/native_widget_aura.h6
3 files changed, 18 insertions, 2 deletions
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index ce9c6d0..859decc 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -37,6 +37,7 @@
#include "ui/views/ime/input_method_bridge.h"
#include "ui/views/widget/desktop_aura/desktop_root_window_host.h"
#include "ui/views/widget/drop_helper.h"
+#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/native_widget_aura_window_observer.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager_aura.h"
@@ -231,7 +232,7 @@ void DesktopNativeWidgetAura::InitNativeWidget(
const Widget::InitParams& params) {
ownership_ = params.ownership;
- window_->set_user_data(this);
+ NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_);
window_->SetType(GetAuraWindowTypeForWidgetType(params.type));
window_->SetTransparent(true);
window_->Init(params.layer_type);
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 8a80068..4ca1bba 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -95,6 +95,13 @@ gfx::Font NativeWidgetAura::GetWindowTitleFont() {
#endif
}
+// static
+void NativeWidgetAura::RegisterNativeWidgetForWindow(
+ internal::NativeWidgetPrivate* native_widget,
+ aura::Window* window) {
+ window->set_user_data(native_widget);
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, internal::NativeWidgetPrivate implementation:
@@ -105,7 +112,7 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
ownership_ = params.ownership;
- window_->set_user_data(this);
+ RegisterNativeWidgetForWindow(this, window_);
window_->SetType(GetAuraWindowTypeForWidgetType(params.type));
window_->SetProperty(aura::client::kShowStateKey, params.show_state);
if (params.type == Widget::InitParams::TYPE_BUBBLE)
@@ -1023,12 +1030,14 @@ 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());
}
// static
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) {
+ // Cast must match type supplied to RegisterNativeWidgetForWindow().
return reinterpret_cast<NativeWidgetPrivate*>(native_window->user_data());
}
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index 6e736a5..b14da5c 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -46,6 +46,12 @@ class VIEWS_EXPORT NativeWidgetAura
// NativeWidgetWin.
static gfx::Font GetWindowTitleFont();
+ // Called internally by NativeWidgetAura and DesktopNativeWidgetAura to
+ // associate |native_widget| with |window|.
+ static void RegisterNativeWidgetForWindow(
+ internal::NativeWidgetPrivate* native_widget,
+ aura::Window* window);
+
// Overridden from internal::NativeWidgetPrivate:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;