OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/process_singleton.h" | 5 #include "chrome/browser/process_singleton.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/win/hwnd_util.h" | |
9 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
11 #include "base/file_path.h" | 10 #include "base/file_path.h" |
12 #include "base/path_service.h" | 11 #include "base/path_service.h" |
13 #include "base/process_util.h" | 12 #include "base/process_util.h" |
14 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
15 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
16 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/extensions/extensions_startup.h" | 16 #include "chrome/browser/extensions/extensions_startup.h" |
18 #include "chrome/browser/platform_util.h" | 17 #include "chrome/browser/platform_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
21 #include "chrome/browser/ui/browser_init.h" | 20 #include "chrome/browser/ui/browser_init.h" |
22 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/result_codes.h" | 24 #include "chrome/common/result_codes.h" |
26 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "ui/base/win/hwnd_util.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Checks the visibility of the enumerated window and signals once a visible | 31 // Checks the visibility of the enumerated window and signals once a visible |
32 // window has been found. | 32 // window has been found. |
33 BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { | 33 BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { |
34 bool* result = reinterpret_cast<bool*>(param); | 34 bool* result = reinterpret_cast<bool*>(param); |
35 *result = IsWindowVisible(window) != 0; | 35 *result = IsWindowVisible(window) != 0; |
36 // Stops enumeration if a visible window has been found. | 36 // Stops enumeration if a visible window has been found. |
37 return !*result; | 37 return !*result; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 FilePath user_data_dir; | 188 FilePath user_data_dir; |
189 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 189 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
190 | 190 |
191 // Set the window's title to the path of our user data directory so other | 191 // Set the window's title to the path of our user data directory so other |
192 // Chrome instances can decide if they should forward to us or not. | 192 // Chrome instances can decide if they should forward to us or not. |
193 window_ = CreateWindow(chrome::kMessageWindowClass, | 193 window_ = CreateWindow(chrome::kMessageWindowClass, |
194 user_data_dir.value().c_str(), | 194 user_data_dir.value().c_str(), |
195 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, 0); | 195 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, 0); |
196 DCHECK(window_); | 196 DCHECK(window_); |
197 | 197 |
198 app::win::SetWindowUserData(window_, this); | 198 ui::SetWindowUserData(window_, this); |
199 return true; | 199 return true; |
200 } | 200 } |
201 | 201 |
202 void ProcessSingleton::Cleanup() { | 202 void ProcessSingleton::Cleanup() { |
203 } | 203 } |
204 | 204 |
205 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { | 205 LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { |
206 // If locked, it means we are not ready to process this message because | 206 // If locked, it means we are not ready to process this message because |
207 // we are probably in a first run critical phase. | 207 // we are probably in a first run critical phase. |
208 if (locked_) { | 208 if (locked_) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 switch (message) { | 305 switch (message) { |
306 case WM_COPYDATA: | 306 case WM_COPYDATA: |
307 return OnCopyData(reinterpret_cast<HWND>(wparam), | 307 return OnCopyData(reinterpret_cast<HWND>(wparam), |
308 reinterpret_cast<COPYDATASTRUCT*>(lparam)); | 308 reinterpret_cast<COPYDATASTRUCT*>(lparam)); |
309 default: | 309 default: |
310 break; | 310 break; |
311 } | 311 } |
312 | 312 |
313 return ::DefWindowProc(hwnd, message, wparam, lparam); | 313 return ::DefWindowProc(hwnd, message, wparam, lparam); |
314 } | 314 } |
OLD | NEW |