[email protected] | b90d7e80 | 2011-01-09 16:32:20 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 7c47ae3e | 2009-02-18 00:34:21 | [diff] [blame] | 5 | #include "chrome/browser/process_singleton.h" |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 6 | |
[email protected] | a92b864 | 2009-05-05 23:38:56 | [diff] [blame] | 7 | #include "app/l10n_util.h" |
[email protected] | fff369b8 | 2010-12-30 15:38:47 | [diff] [blame] | 8 | #include "app/win/hwnd_util.h" |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 9 | #include "base/base_paths.h" |
| 10 | #include "base/command_line.h" |
[email protected] | f805fe8 | 2010-08-03 22:47:10 | [diff] [blame] | 11 | #include "base/file_path.h" |
[email protected] | 9e9b6e8e | 2009-12-02 08:45:01 | [diff] [blame] | 12 | #include "base/path_service.h" |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 13 | #include "base/process_util.h" |
[email protected] | 0f26d7b | 2011-01-05 19:10:44 | [diff] [blame] | 14 | #include "base/utf_string_conversions.h" |
[email protected] | b90d7e80 | 2011-01-09 16:32:20 | [diff] [blame^] | 15 | #include "base/win/scoped_handle.h" |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 16 | #include "chrome/browser/browser_process.h" |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 17 | #include "chrome/browser/extensions/extensions_startup.h" |
[email protected] | e313f3b1 | 2010-06-25 21:29:10 | [diff] [blame] | 18 | #include "chrome/browser/platform_util.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 19 | #include "chrome/browser/profiles/profile.h" |
| 20 | #include "chrome/browser/profiles/profile_manager.h" |
[email protected] | f700280 | 2010-11-12 19:50:28 | [diff] [blame] | 21 | #include "chrome/browser/ui/browser_init.h" |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 22 | #include "chrome/common/chrome_constants.h" |
| 23 | #include "chrome/common/chrome_paths.h" |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 24 | #include "chrome/common/chrome_switches.h" |
[email protected] | 74d1bb0 | 2009-03-03 00:41:23 | [diff] [blame] | 25 | #include "chrome/common/result_codes.h" |
[email protected] | 34ac8f3 | 2009-02-22 23:03:27 | [diff] [blame] | 26 | #include "grit/chromium_strings.h" |
| 27 | #include "grit/generated_resources.h" |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 28 | |
| 29 | namespace { |
| 30 | |
[email protected] | f891fb3 | 2009-04-08 00:20:32 | [diff] [blame] | 31 | // Checks the visibility of the enumerated window and signals once a visible |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 32 | // window has been found. |
| 33 | BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { |
| 34 | bool* result = reinterpret_cast<bool*>(param); |
| 35 | *result = IsWindowVisible(window) != 0; |
| 36 | // Stops enumeration if a visible window has been found. |
| 37 | return !*result; |
| 38 | } |
| 39 | |
| 40 | } // namespace |
| 41 | |
[email protected] | f891fb3 | 2009-04-08 00:20:32 | [diff] [blame] | 42 | // Look for a Chrome instance that uses the same profile directory. |
[email protected] | 7c47ae3e | 2009-02-18 00:34:21 | [diff] [blame] | 43 | ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) |
[email protected] | 175a7a2 | 2009-05-03 15:57:53 | [diff] [blame] | 44 | : window_(NULL), locked_(false), foreground_window_(NULL) { |
[email protected] | bbef41f0 | 2010-03-04 16:16:19 | [diff] [blame] | 45 | std::wstring user_data_dir_str(user_data_dir.ToWStringHack()); |
| 46 | remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, |
| 47 | chrome::kMessageWindowClass, |
| 48 | user_data_dir_str.c_str()); |
| 49 | if (!remote_window_) { |
| 50 | // Make sure we will be the one and only process creating the window. |
| 51 | // We use a named Mutex since we are protecting against multi-process |
| 52 | // access. As documented, it's clearer to NOT request ownership on creation |
| 53 | // since it isn't guaranteed we will get it. It is better to create it |
| 54 | // without ownership and explicitly get the ownership afterward. |
[email protected] | e132804b | 2010-12-22 12:48:25 | [diff] [blame] | 55 | std::wstring mutex_name(L"Local\\ChromeProcessSingletonStartup!"); |
[email protected] | b90d7e80 | 2011-01-09 16:32:20 | [diff] [blame^] | 56 | base::win::ScopedHandle only_me( |
| 57 | CreateMutex(NULL, FALSE, mutex_name.c_str())); |
[email protected] | bbef41f0 | 2010-03-04 16:16:19 | [diff] [blame] | 58 | DCHECK(only_me.Get() != NULL) << "GetLastError = " << GetLastError(); |
| 59 | |
| 60 | // This is how we acquire the mutex (as opposed to the initial ownership). |
| 61 | DWORD result = WaitForSingleObject(only_me, INFINITE); |
| 62 | DCHECK(result == WAIT_OBJECT_0) << "Result = " << result << |
| 63 | "GetLastError = " << GetLastError(); |
| 64 | |
| 65 | // We now own the mutex so we are the only process that can create the |
| 66 | // window at this time, but we must still check if someone created it |
| 67 | // between the time where we looked for it above and the time the mutex |
| 68 | // was given to us. |
| 69 | remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, |
| 70 | chrome::kMessageWindowClass, |
| 71 | user_data_dir_str.c_str()); |
| 72 | if (!remote_window_) |
| 73 | Create(); |
| 74 | BOOL success = ReleaseMutex(only_me); |
| 75 | DCHECK(success) << "GetLastError = " << GetLastError(); |
| 76 | } |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 77 | } |
| 78 | |
[email protected] | 7c47ae3e | 2009-02-18 00:34:21 | [diff] [blame] | 79 | ProcessSingleton::~ProcessSingleton() { |
[email protected] | aef15bd | 2009-04-27 20:51:51 | [diff] [blame] | 80 | if (window_) { |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 81 | DestroyWindow(window_); |
[email protected] | aef15bd | 2009-04-27 20:51:51 | [diff] [blame] | 82 | UnregisterClass(chrome::kMessageWindowClass, GetModuleHandle(NULL)); |
| 83 | } |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 84 | } |
| 85 | |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 86 | ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 87 | if (!remote_window_) |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 88 | return PROCESS_NONE; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 89 | |
| 90 | // Found another window, send our command line to it |
| 91 | // format is "START\0<<<current directory>>>\0<<<commandline>>>". |
| 92 | std::wstring to_send(L"START\0", 6); // want the NULL in the string. |
[email protected] | b969648 | 2010-11-30 23:56:18 | [diff] [blame] | 93 | FilePath cur_dir; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 94 | if (!PathService::Get(base::DIR_CURRENT, &cur_dir)) |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 95 | return PROCESS_NONE; |
[email protected] | b969648 | 2010-11-30 23:56:18 | [diff] [blame] | 96 | to_send.append(cur_dir.value()); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 97 | to_send.append(L"\0", 1); // Null separator. |
| 98 | to_send.append(GetCommandLineW()); |
| 99 | to_send.append(L"\0", 1); // Null separator. |
| 100 | |
| 101 | // Allow the current running browser window making itself the foreground |
| 102 | // window (otherwise it will just flash in the taskbar). |
| 103 | DWORD process_id = 0; |
| 104 | DWORD thread_id = GetWindowThreadProcessId(remote_window_, &process_id); |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 105 | // It is possible that the process owning this window may have died by now. |
| 106 | if (!thread_id || !process_id) { |
| 107 | remote_window_ = NULL; |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 108 | return PROCESS_NONE; |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 109 | } |
| 110 | |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 111 | AllowSetForegroundWindow(process_id); |
| 112 | |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 113 | COPYDATASTRUCT cds; |
| 114 | cds.dwData = 0; |
| 115 | cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t)); |
| 116 | cds.lpData = const_cast<wchar_t*>(to_send.c_str()); |
| 117 | DWORD_PTR result = 0; |
| 118 | if (SendMessageTimeout(remote_window_, |
| 119 | WM_COPYDATA, |
| 120 | NULL, |
| 121 | reinterpret_cast<LPARAM>(&cds), |
| 122 | SMTO_ABORTIFHUNG, |
[email protected] | 8b08cbd | 2009-08-04 05:34:19 | [diff] [blame] | 123 | kTimeoutInSeconds * 1000, |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 124 | &result)) { |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 125 | // It is possible that the process owning this window may have died by now. |
| 126 | if (!result) { |
| 127 | remote_window_ = NULL; |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 128 | return PROCESS_NONE; |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 129 | } |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 130 | return PROCESS_NOTIFIED; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 131 | } |
| 132 | |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 133 | // It is possible that the process owning this window may have died by now. |
| 134 | if (!IsWindow(remote_window_)) { |
| 135 | remote_window_ = NULL; |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 136 | return PROCESS_NONE; |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 137 | } |
| 138 | |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 139 | // The window is hung. Scan for every window to find a visible one. |
| 140 | bool visible_window = false; |
| 141 | EnumThreadWindows(thread_id, |
| 142 | &BrowserWindowEnumeration, |
| 143 | reinterpret_cast<LPARAM>(&visible_window)); |
| 144 | |
| 145 | // If there is a visible browser window, ask the user before killing it. |
| 146 | if (visible_window) { |
[email protected] | 0f26d7b | 2011-01-05 19:10:44 | [diff] [blame] | 147 | std::wstring text = |
| 148 | UTF16ToWide(l10n_util::GetStringUTF16(IDS_BROWSER_HUNGBROWSER_MESSAGE)); |
| 149 | std::wstring caption = |
| 150 | UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
[email protected] | e313f3b1 | 2010-06-25 21:29:10 | [diff] [blame] | 151 | if (!platform_util::SimpleYesNoBox(NULL, caption, text)) { |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 152 | // The user denied. Quit silently. |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 153 | return PROCESS_NOTIFIED; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 154 | } |
| 155 | } |
| 156 | |
| 157 | // Time to take action. Kill the browser process. |
[email protected] | cd4fd15 | 2009-02-09 19:28:41 | [diff] [blame] | 158 | base::KillProcessById(process_id, ResultCodes::HUNG, true); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 159 | remote_window_ = NULL; |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 160 | return PROCESS_NONE; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 161 | } |
| 162 | |
[email protected] | 4a44bc3 | 2010-05-28 22:22:44 | [diff] [blame] | 163 | ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate() { |
| 164 | NotifyResult result = NotifyOtherProcess(); |
| 165 | if (result != PROCESS_NONE) |
| 166 | return result; |
| 167 | return Create() ? PROCESS_NONE : PROFILE_IN_USE; |
| 168 | } |
| 169 | |
[email protected] | f891fb3 | 2009-04-08 00:20:32 | [diff] [blame] | 170 | // For windows, there is no need to call Create() since the call is made in |
| 171 | // the constructor but to avoid having more platform specific code in |
| 172 | // browser_main.cc we tolerate a second call which will do nothing. |
[email protected] | 4dd4224 | 2010-04-07 02:21:15 | [diff] [blame] | 173 | bool ProcessSingleton::Create() { |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 174 | DCHECK(!remote_window_); |
[email protected] | f891fb3 | 2009-04-08 00:20:32 | [diff] [blame] | 175 | if (window_) |
[email protected] | 4dd4224 | 2010-04-07 02:21:15 | [diff] [blame] | 176 | return true; |
[email protected] | f891fb3 | 2009-04-08 00:20:32 | [diff] [blame] | 177 | |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 178 | HINSTANCE hinst = GetModuleHandle(NULL); |
| 179 | |
| 180 | WNDCLASSEX wc = {0}; |
| 181 | wc.cbSize = sizeof(wc); |
[email protected] | 7c47ae3e | 2009-02-18 00:34:21 | [diff] [blame] | 182 | wc.lpfnWndProc = ProcessSingleton::WndProcStatic; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 183 | wc.hInstance = hinst; |
| 184 | wc.lpszClassName = chrome::kMessageWindowClass; |
[email protected] | aef15bd | 2009-04-27 20:51:51 | [diff] [blame] | 185 | ATOM clazz = RegisterClassEx(&wc); |
| 186 | DCHECK(clazz); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 187 | |
[email protected] | ef5ff1b | 2009-09-09 20:00:13 | [diff] [blame] | 188 | FilePath user_data_dir; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 189 | PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 190 | |
| 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. |
[email protected] | ef5ff1b | 2009-09-09 20:00:13 | [diff] [blame] | 193 | window_ = CreateWindow(chrome::kMessageWindowClass, |
| 194 | user_data_dir.value().c_str(), |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 195 | 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, 0); |
| 196 | DCHECK(window_); |
| 197 | |
[email protected] | fff369b8 | 2010-12-30 15:38:47 | [diff] [blame] | 198 | app::win::SetWindowUserData(window_, this); |
[email protected] | 4dd4224 | 2010-04-07 02:21:15 | [diff] [blame] | 199 | return true; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 200 | } |
| 201 | |
[email protected] | 9f20a6d0 | 2009-08-21 01:18:37 | [diff] [blame] | 202 | void ProcessSingleton::Cleanup() { |
| 203 | } |
| 204 | |
[email protected] | 7c47ae3e | 2009-02-18 00:34:21 | [diff] [blame] | 205 | LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { |
[email protected] | 175a7a2 | 2009-05-03 15:57:53 | [diff] [blame] | 206 | // If locked, it means we are not ready to process this message because |
[email protected] | afd20c02 | 2010-06-10 00:48:20 | [diff] [blame] | 207 | // we are probably in a first run critical phase. |
[email protected] | 175a7a2 | 2009-05-03 15:57:53 | [diff] [blame] | 208 | if (locked_) { |
| 209 | // Attempt to place ourselves in the foreground / flash the task bar. |
| 210 | if (IsWindow(foreground_window_)) |
| 211 | SetForegroundWindow(foreground_window_); |
| 212 | return TRUE; |
| 213 | } |
| 214 | |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 215 | // Ignore the request if the browser process is already in shutdown path. |
[email protected] | 0815b6d | 2009-02-11 00:39:37 | [diff] [blame] | 216 | if (!g_browser_process || g_browser_process->IsShuttingDown()) { |
| 217 | LOG(WARNING) << "Not handling WM_COPYDATA as browser is shutting down"; |
| 218 | return FALSE; |
| 219 | } |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 220 | |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 221 | // We should have enough room for the shortest command (min_message_size) |
[email protected] | 366ffe5 | 2009-04-24 22:02:23 | [diff] [blame] | 222 | // and also be a multiple of wchar_t bytes. The shortest command |
| 223 | // possible is L"START\0\0" (empty current directory and command line). |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 224 | static const int min_message_size = 7; |
[email protected] | 366ffe5 | 2009-04-24 22:02:23 | [diff] [blame] | 225 | if (cds->cbData < min_message_size * sizeof(wchar_t) || |
| 226 | cds->cbData % sizeof(wchar_t) != 0) { |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 227 | LOG(WARNING) << "Invalid WM_COPYDATA, length = " << cds->cbData; |
| 228 | return TRUE; |
| 229 | } |
| 230 | |
| 231 | // We split the string into 4 parts on NULLs. |
[email protected] | 366ffe5 | 2009-04-24 22:02:23 | [diff] [blame] | 232 | DCHECK(cds->lpData); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 233 | const std::wstring msg(static_cast<wchar_t*>(cds->lpData), |
| 234 | cds->cbData / sizeof(wchar_t)); |
| 235 | const std::wstring::size_type first_null = msg.find_first_of(L'\0'); |
| 236 | if (first_null == 0 || first_null == std::wstring::npos) { |
| 237 | // no NULL byte, don't know what to do |
| 238 | LOG(WARNING) << "Invalid WM_COPYDATA, length = " << msg.length() << |
| 239 | ", first null = " << first_null; |
| 240 | return TRUE; |
| 241 | } |
| 242 | |
| 243 | // Decode the command, which is everything until the first NULL. |
| 244 | if (msg.substr(0, first_null) == L"START") { |
| 245 | // Another instance is starting parse the command line & do what it would |
| 246 | // have done. |
[email protected] | 8e96e50 | 2010-10-21 20:57:12 | [diff] [blame] | 247 | VLOG(1) << "Handling STARTUP request from another process"; |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 248 | const std::wstring::size_type second_null = |
| 249 | msg.find_first_of(L'\0', first_null + 1); |
| 250 | if (second_null == std::wstring::npos || |
| 251 | first_null == msg.length() - 1 || second_null == msg.length()) { |
| 252 | LOG(WARNING) << "Invalid format for start command, we need a string in 4 " |
| 253 | "parts separated by NULLs"; |
| 254 | return TRUE; |
| 255 | } |
| 256 | |
| 257 | // Get current directory. |
[email protected] | f805fe8 | 2010-08-03 22:47:10 | [diff] [blame] | 258 | const FilePath cur_dir(msg.substr(first_null + 1, |
| 259 | second_null - first_null)); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 260 | |
| 261 | const std::wstring::size_type third_null = |
| 262 | msg.find_first_of(L'\0', second_null + 1); |
| 263 | if (third_null == std::wstring::npos || |
| 264 | third_null == msg.length()) { |
| 265 | LOG(WARNING) << "Invalid format for start command, we need a string in 4 " |
| 266 | "parts separated by NULLs"; |
| 267 | } |
| 268 | |
| 269 | // Get command line. |
| 270 | const std::wstring cmd_line = |
| 271 | msg.substr(second_null + 1, third_null - second_null); |
| 272 | |
[email protected] | 51343d5a | 2009-10-26 22:39:33 | [diff] [blame] | 273 | CommandLine parsed_command_line = CommandLine::FromString(cmd_line); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 274 | PrefService* prefs = g_browser_process->local_state(); |
| 275 | DCHECK(prefs); |
| 276 | |
[email protected] | ddf8a4b0 | 2010-03-22 23:08:30 | [diff] [blame] | 277 | Profile* profile = ProfileManager::GetDefaultProfile(); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 278 | if (!profile) { |
| 279 | // We should only be able to get here if the profile already exists and |
| 280 | // has been created. |
| 281 | NOTREACHED(); |
| 282 | return TRUE; |
| 283 | } |
[email protected] | 0303f31c | 2009-02-02 06:42:05 | [diff] [blame] | 284 | |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 285 | // Handle the --uninstall-extension startup action. This needs to done here |
| 286 | // in the process that is running with the target profile, otherwise the |
| 287 | // uninstall will fail to unload and remove all components. |
| 288 | if (parsed_command_line.HasSwitch(switches::kUninstallExtension)) { |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 289 | ExtensionsStartupUtil ext_startup_util; |
| 290 | ext_startup_util.UninstallExtension(parsed_command_line, profile); |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 291 | return TRUE; |
| 292 | } |
| 293 | |
[email protected] | 0303f31c | 2009-02-02 06:42:05 | [diff] [blame] | 294 | // Run the browser startup sequence again, with the command line of the |
| 295 | // signalling process. |
[email protected] | 7c27203a | 2009-03-10 21:55:21 | [diff] [blame] | 296 | BrowserInit::ProcessCommandLine(parsed_command_line, cur_dir, false, |
[email protected] | 0303f31c | 2009-02-02 06:42:05 | [diff] [blame] | 297 | profile, NULL); |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 298 | return TRUE; |
| 299 | } |
| 300 | return TRUE; |
| 301 | } |
| 302 | |
[email protected] | 7c47ae3e | 2009-02-18 00:34:21 | [diff] [blame] | 303 | LRESULT CALLBACK ProcessSingleton::WndProc(HWND hwnd, UINT message, |
[email protected] | 175a7a2 | 2009-05-03 15:57:53 | [diff] [blame] | 304 | WPARAM wparam, LPARAM lparam) { |
[email protected] | fc14cef | 2009-01-27 22:17:29 | [diff] [blame] | 305 | switch (message) { |
| 306 | case WM_COPYDATA: |
| 307 | return OnCopyData(reinterpret_cast<HWND>(wparam), |
| 308 | reinterpret_cast<COPYDATASTRUCT*>(lparam)); |
| 309 | default: |
| 310 | break; |
| 311 | } |
| 312 | |
| 313 | return ::DefWindowProc(hwnd, message, wparam, lparam); |
| 314 | } |