diff options
-rw-r--r-- | app/win/window_impl.cc | 10 | ||||
-rw-r--r-- | app/win/window_impl.h | 3 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 5 |
3 files changed, 18 insertions, 0 deletions
diff --git a/app/win/window_impl.cc b/app/win/window_impl.cc index 9668f82..5488434 100644 --- a/app/win/window_impl.cc +++ b/app/win/window_impl.cc @@ -152,6 +152,16 @@ HICON WindowImpl::GetDefaultWindowIcon() const { return NULL; } +// static +bool WindowImpl::IsWindowImpl(HWND hwnd) { + wchar_t tmp[128]; + if (!::GetClassName(hwnd, tmp, 128)) + return false; + + std::wstring class_name(tmp); + return class_name.find(kBaseClassName) == 0; +} + LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { LRESULT result = 0; diff --git a/app/win/window_impl.h b/app/win/window_impl.h index ad1fc87..67f3bf7 100644 --- a/app/win/window_impl.h +++ b/app/win/window_impl.h @@ -70,6 +70,9 @@ class WindowImpl : public MessageMapInterface { } UINT initial_class_style() const { return class_style_; } + // Returns true if the specified |hwnd| is a WindowImpl. + static bool IsWindowImpl(HWND hwnd); + protected: // Handles the WndProc callback for this object. virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param); diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index c88e218..2b4c649 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -65,6 +65,11 @@ WidgetWin::~WidgetWin() { // static WidgetWin* WidgetWin::GetWidget(HWND hwnd) { + // TODO(jcivelli): http://crbug.com/44499 We need a way to test that hwnd is + // associated with a WidgetWin (it might be a pure + // WindowImpl). + if (!WindowImpl::IsWindowImpl(hwnd)) + return NULL; return reinterpret_cast<WidgetWin*>(win_util::GetWindowUserData(hwnd)); } |