summaryrefslogtreecommitdiffstats
path: root/app/win
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 16:07:03 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 16:07:03 +0000
commitd0b683b69c926467468b4ca0b93d670317f7a2dc (patch)
tree08f5f8fc3cf6bc03b057311e496536a0584b5d9a /app/win
parent523623c62f291467769fbb3c0e7fd5c1709b4da1 (diff)
downloadchromium_src-d0b683b69c926467468b4ca0b93d670317f7a2dc.zip
chromium_src-d0b683b69c926467468b4ca0b93d670317f7a2dc.tar.gz
chromium_src-d0b683b69c926467468b4ca0b93d670317f7a2dc.tar.bz2
A crasher would sometimes happen when opening a selet file dialog
(such as when loading an unpacled extension). This is because we would reinterpret cast the user data of the HWND to a WidgetWin, and in that case the Windows dialog has a user-data that we did not set. This CL checks that the HWND is at least a WindowImpl before attempting to retrieve the WidgetWin, ensuring we won't mess with windows we did not create directly. BUG=44312 TEST=Open the extension page. Move the focus by pressing TAB to the "Load unpacked extension..." button. Press ENTER many times quickly so it opens/closes the "Select dir" dialog. It should not crash. Review URL: http://codereview.chromium.org/2124009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/win')
-rw-r--r--app/win/window_impl.cc10
-rw-r--r--app/win/window_impl.h3
2 files changed, 13 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);