summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_helper_main.cc
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 18:23:30 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-08 18:23:30 +0000
commit9283f2789927383ece6aedbd948a645164c35c53 (patch)
treeeb3bf03f6bc5b408695523fdab142a30d0b6383f /chrome_frame/chrome_frame_helper_main.cc
parent0f4899dc496e611d72f9171e29918c3b464b5147 (diff)
downloadchromium_src-9283f2789927383ece6aedbd948a645164c35c53.zip
chromium_src-9283f2789927383ece6aedbd948a645164c35c53.tar.gz
chromium_src-9283f2789927383ece6aedbd948a645164c35c53.tar.bz2
Cause the chrome frame helper process to attempt to close down all other chrome frame helper processes on launch (after setting its own hook).
BUG=53127 TEST=You can't start more than one medium/low integrity chrome_frame_helper.exe per desktop. Review URL: http://codereview.chromium.org/3371002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_helper_main.cc')
-rw-r--r--chrome_frame/chrome_frame_helper_main.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_helper_main.cc b/chrome_frame/chrome_frame_helper_main.cc
index 5582261..0b6bc73 100644
--- a/chrome_frame/chrome_frame_helper_main.cc
+++ b/chrome_frame/chrome_frame_helper_main.cc
@@ -70,12 +70,44 @@ class HookDllLoader {
PROC stop_proc_;
};
+// Checks the window title and then class of hwnd. If they match with that
+// of a chrome_frame_helper.exe window, then add it to the list of windows
+// pointed to by lparam.
+BOOL CALLBACK CloseHelperWindowsEnumProc(HWND hwnd, LPARAM lparam) {
+ _ASSERTE(lparam != 0);
+
+ wchar_t title_buffer[MAX_PATH] = {0};
+ if (GetWindowText(hwnd, title_buffer, MAX_PATH)) {
+ if (lstrcmpiW(title_buffer, kChromeFrameHelperWindowName) == 0) {
+ wchar_t class_buffer[MAX_PATH] = {0};
+ if (GetClassName(hwnd, class_buffer, MAX_PATH)) {
+ if (lstrcmpiW(class_buffer, kChromeFrameHelperWindowClassName) == 0) {
+ if (hwnd != reinterpret_cast<HWND>(lparam)) {
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ }
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+// Enumerates all top level windows, looking for those that look like a
+// Chrome Frame helper window. It then closes all of them except for
+// except_me.
+void CloseAllHelperWindowsApartFrom(HWND except_me) {
+ EnumWindows(CloseHelperWindowsEnumProc, reinterpret_cast<LPARAM>(except_me));
+}
LRESULT CALLBACK ChromeFrameHelperWndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
switch (message) {
+ case WM_CREATE:
+ CloseAllHelperWindowsApartFrom(hwnd);
+ break;
case WM_DESTROY:
PostQuitMessage(0);
break;