summaryrefslogtreecommitdiffstats
path: root/chrome/browser/process_singleton_win.cc
diff options
context:
space:
mode:
authorrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-03 15:57:53 +0000
committerrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-03 15:57:53 +0000
commit175a7a296b06339ee76d59fd8a98507b59aa2187 (patch)
tree66bc8cd9dd376252e266b6e7621f6a439f04128a /chrome/browser/process_singleton_win.cc
parent537a1e191f7666d12c486a4054abd661b6c1d3a1 (diff)
downloadchromium_src-175a7a296b06339ee76d59fd8a98507b59aa2187.zip
chromium_src-175a7a296b06339ee76d59fd8a98507b59aa2187.tar.gz
chromium_src-175a7a296b06339ee76d59fd8a98507b59aa2187.tar.bz2
Fix multiple instances of first run dialog appearing when Chrome is started again while a first run dialog is visible. Also cause the original first run dialog to come to foreground.
BUG=http://crbug.com/10765 Review URL: http://codereview.chromium.org/99281 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15170 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/process_singleton_win.cc')
-rw-r--r--chrome/browser/process_singleton_win.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc
index c34a4d1..b3ce8f7 100644
--- a/chrome/browser/process_singleton_win.cc
+++ b/chrome/browser/process_singleton_win.cc
@@ -35,7 +35,7 @@ BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) {
// Look for a Chrome instance that uses the same profile directory.
ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir)
- : window_(NULL), locked_(false) {
+ : window_(NULL), locked_(false), foreground_window_(NULL) {
// FindWindoEx and Create() should be one atomic operation in order to not
// have a race condition.
remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass,
@@ -160,17 +160,23 @@ void ProcessSingleton::Create() {
}
LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
+ // If locked, it means we are not ready to process this message because
+ // we are probably in a first run critical phase. We must do this before
+ // doing the IsShuttingDown() check since that returns true during first run
+ // (since g_browser_process hasn't been AddRefModule()d yet).
+ if (locked_) {
+ // Attempt to place ourselves in the foreground / flash the task bar.
+ if (IsWindow(foreground_window_))
+ SetForegroundWindow(foreground_window_);
+ return TRUE;
+ }
+
// Ignore the request if the browser process is already in shutdown path.
if (!g_browser_process || g_browser_process->IsShuttingDown()) {
LOG(WARNING) << "Not handling WM_COPYDATA as browser is shutting down";
return FALSE;
}
- // If locked, it means we are not ready to process this message because
- // we are probably in a first run critical phase.
- if (locked_)
- return TRUE;
-
// We should have enough room for the shortest command (min_message_size)
// and also be a multiple of wchar_t bytes. The shortest command
// possible is L"START\0\0" (empty current directory and command line).
@@ -249,7 +255,7 @@ LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) {
}
LRESULT CALLBACK ProcessSingleton::WndProc(HWND hwnd, UINT message,
- WPARAM wparam, LPARAM lparam) {
+ WPARAM wparam, LPARAM lparam) {
switch (message) {
case WM_COPYDATA:
return OnCopyData(reinterpret_cast<HWND>(wparam),