Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/google/google_update.h" | 5 #include "chrome/browser/google/google_update.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 //////////////////////////////////////////////////////////////////////////////// | 228 //////////////////////////////////////////////////////////////////////////////// |
| 229 // GoogleUpdate, public: | 229 // GoogleUpdate, public: |
| 230 | 230 |
| 231 GoogleUpdate::GoogleUpdate() | 231 GoogleUpdate::GoogleUpdate() |
| 232 : listener_(NULL) { | 232 : listener_(NULL) { |
| 233 } | 233 } |
| 234 | 234 |
| 235 GoogleUpdate::~GoogleUpdate() { | 235 GoogleUpdate::~GoogleUpdate() { |
| 236 } | 236 } |
| 237 | 237 |
| 238 void GoogleUpdate::CheckForUpdate(bool install_if_newer, | 238 void GoogleUpdate::CheckForUpdate(bool install_if_newer) { |
| 239 views::Widget* window) { | |
| 240 // We need to shunt this request over to InitiateGoogleUpdateCheck and have | 239 // We need to shunt this request over to InitiateGoogleUpdateCheck and have |
| 241 // it run in the file thread. | 240 // it run in the file thread. |
| 242 BrowserThread::PostTask( | 241 BrowserThread::PostTask( |
| 243 BrowserThread::FILE, FROM_HERE, | 242 BrowserThread::FILE, FROM_HERE, |
| 244 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this, | 243 base::Bind(&GoogleUpdate::InitiateGoogleUpdateCheck, this, |
| 245 install_if_newer, window, MessageLoop::current())); | 244 install_if_newer, MessageLoop::current())); |
| 246 } | 245 } |
| 247 | 246 |
| 248 //////////////////////////////////////////////////////////////////////////////// | 247 //////////////////////////////////////////////////////////////////////////////// |
| 249 // GoogleUpdate, private: | 248 // GoogleUpdate, private: |
| 250 | 249 |
| 251 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, | 250 void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, |
| 252 views::Widget* window, | |
| 253 MessageLoop* main_loop) { | 251 MessageLoop* main_loop) { |
| 254 FilePath chrome_exe; | 252 FilePath chrome_exe; |
| 255 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) | 253 if (!PathService::Get(base::DIR_EXE, &chrome_exe)) |
| 256 NOTREACHED(); | 254 NOTREACHED(); |
| 257 | 255 |
| 258 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe); | 256 GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe); |
| 259 if (error_code != GOOGLE_UPDATE_NO_ERROR) { | 257 if (error_code != GOOGLE_UPDATE_NO_ERROR) { |
| 260 main_loop->PostTask( | 258 main_loop->PostTask( |
| 261 FROM_HERE, | 259 FROM_HERE, |
| 262 base::Bind(&GoogleUpdate::ReportResults, this, | 260 base::Bind(&GoogleUpdate::ReportResults, this, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 288 | 286 |
| 289 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { | 287 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { |
| 290 hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); | 288 hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); |
| 291 } else { | 289 } else { |
| 292 // The Update operation needs Admin privileges for writing | 290 // The Update operation needs Admin privileges for writing |
| 293 // to %ProgramFiles%. On Vista we need to elevate before instantiating | 291 // to %ProgramFiles%. On Vista we need to elevate before instantiating |
| 294 // the updater instance. | 292 // the updater instance. |
| 295 if (!install_if_newer) { | 293 if (!install_if_newer) { |
| 296 hr = on_demand.CreateInstance(CLSID_OnDemandMachineAppsClass); | 294 hr = on_demand.CreateInstance(CLSID_OnDemandMachineAppsClass); |
| 297 } else { | 295 } else { |
| 298 HWND foreground_hwnd = NULL; | |
| 299 if (window != NULL) { | |
| 300 foreground_hwnd = window->GetNativeWindow(); | |
| 301 } | |
| 302 | |
| 303 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, | 296 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, |
| 304 IID_IGoogleUpdate, foreground_hwnd, | 297 IID_IGoogleUpdate, GetForegroundWindow(), |
|
Ben Goodger (Google)
2012/07/09 22:28:01
Will this always return the foreground-most window
MAD
2012/07/10 00:20:09
Yes, but I think that's OK, it's just that the ele
| |
| 305 reinterpret_cast<void**>(on_demand.Receive())); | 298 reinterpret_cast<void**>(on_demand.Receive())); |
| 306 } | 299 } |
| 307 system_level = true; | 300 system_level = true; |
| 308 } | 301 } |
| 309 | 302 |
| 310 if (hr != S_OK) { | 303 if (hr != S_OK) { |
| 311 GoogleUpdateErrorCode error = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; | 304 GoogleUpdateErrorCode error = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; |
| 312 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); | 305 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); |
| 313 if (system_level) | 306 if (system_level) |
| 314 error_code += L" -- system level"; | 307 error_code += L" -- system level"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 MessageLoop* main_loop) { | 397 MessageLoop* main_loop) { |
| 405 NOTREACHED() << "Communication with Google Update failed: " << hr | 398 NOTREACHED() << "Communication with Google Update failed: " << hr |
| 406 << " error: " << error_code | 399 << " error: " << error_code |
| 407 << ", message: " << error_message.c_str(); | 400 << ", message: " << error_message.c_str(); |
| 408 main_loop->PostTask( | 401 main_loop->PostTask( |
| 409 FROM_HERE, | 402 FROM_HERE, |
| 410 base::Bind(&GoogleUpdate::ReportResults, this, | 403 base::Bind(&GoogleUpdate::ReportResults, this, |
| 411 UPGRADE_ERROR, error_code, error_message)); | 404 UPGRADE_ERROR, error_code, error_message)); |
| 412 return false; | 405 return false; |
| 413 } | 406 } |
| OLD | NEW |