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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 UPGRADE_ERROR, error_code, string16())); | 263 UPGRADE_ERROR, error_code, string16())); |
264 return; | 264 return; |
265 } | 265 } |
266 | 266 |
267 CComObject<GoogleUpdateJobObserver>* job_observer; | 267 CComObject<GoogleUpdateJobObserver>* job_observer; |
268 HRESULT hr = | 268 HRESULT hr = |
269 CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer); | 269 CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer); |
270 if (hr != S_OK) { | 270 if (hr != S_OK) { |
271 // Most of the error messages come straight from Google Update. This one is | 271 // Most of the error messages come straight from Google Update. This one is |
272 // deemed worthy enough to also warrant its own error. | 272 // deemed worthy enough to also warrant its own error. |
273 string16 error_code = base::StringPrintf(L"0x%x", hr); | 273 GoogleUpdateErrorCode error = GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED; |
| 274 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); |
274 ReportFailure( | 275 ReportFailure( |
275 hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, | 276 hr, error, |
276 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_COCREATE_FAILED, | 277 l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, |
277 error_code), | 278 error_code), |
278 main_loop); | 279 main_loop); |
279 return; | 280 return; |
280 } | 281 } |
281 | 282 |
282 base::win::ScopedComPtr<IJobObserver> job_holder(job_observer); | 283 base::win::ScopedComPtr<IJobObserver> job_holder(job_observer); |
283 | 284 |
284 base::win::ScopedComPtr<IGoogleUpdate> on_demand; | 285 base::win::ScopedComPtr<IGoogleUpdate> on_demand; |
285 | 286 |
286 bool system_level = false; | 287 bool system_level = false; |
287 | 288 |
(...skipping 12 matching lines...) Expand all Loading... |
300 } | 301 } |
301 | 302 |
302 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, | 303 hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, |
303 IID_IGoogleUpdate, foreground_hwnd, | 304 IID_IGoogleUpdate, foreground_hwnd, |
304 reinterpret_cast<void**>(on_demand.Receive())); | 305 reinterpret_cast<void**>(on_demand.Receive())); |
305 } | 306 } |
306 system_level = true; | 307 system_level = true; |
307 } | 308 } |
308 | 309 |
309 if (hr != S_OK) { | 310 if (hr != S_OK) { |
310 ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, | 311 GoogleUpdateErrorCode error = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; |
311 string16(), main_loop); | 312 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); |
| 313 if (system_level) |
| 314 error_code += L" -- system level"; |
| 315 ReportFailure(hr, error, |
| 316 l10n_util::GetStringFUTF16( |
| 317 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, |
| 318 error_code), |
| 319 main_loop); |
312 return; | 320 return; |
313 } | 321 } |
314 | 322 |
315 string16 app_guid = installer::GetAppGuidForUpdates(system_level); | 323 string16 app_guid = installer::GetAppGuidForUpdates(system_level); |
316 DCHECK(!app_guid.empty()); | 324 DCHECK(!app_guid.empty()); |
317 | 325 |
318 if (!install_if_newer) | 326 if (!install_if_newer) |
319 hr = on_demand->CheckForUpdate(app_guid.c_str(), job_observer); | 327 hr = on_demand->CheckForUpdate(app_guid.c_str(), job_observer); |
320 else | 328 else |
321 hr = on_demand->Update(app_guid.c_str(), job_observer); | 329 hr = on_demand->Update(app_guid.c_str(), job_observer); |
322 | 330 |
323 if (hr != S_OK) { | 331 if (hr != S_OK) { |
324 ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, | 332 GoogleUpdateErrorCode error = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR; |
325 string16(), main_loop); | 333 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); |
| 334 ReportFailure(hr, error, |
| 335 l10n_util::GetStringFUTF16( |
| 336 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, |
| 337 error_code), |
| 338 main_loop); |
326 return; | 339 return; |
327 } | 340 } |
328 | 341 |
329 // We need to spin the message loop while Google Update is running so that it | 342 // We need to spin the message loop while Google Update is running so that it |
330 // can report back to us through GoogleUpdateJobObserver. This message loop | 343 // can report back to us through GoogleUpdateJobObserver. This message loop |
331 // will terminate once Google Update sends us the completion status | 344 // will terminate once Google Update sends us the completion status |
332 // (success/error). See OnComplete(). | 345 // (success/error). See OnComplete(). |
333 MessageLoop::current()->Run(); | 346 MessageLoop::current()->Run(); |
334 | 347 |
335 GoogleUpdateUpgradeResult results; | 348 GoogleUpdateUpgradeResult results; |
336 hr = job_observer->GetResult(&results); | 349 hr = job_observer->GetResult(&results); |
| 350 |
337 if (hr != S_OK) { | 351 if (hr != S_OK) { |
338 ReportFailure(hr, GOOGLE_UPDATE_GET_RESULT_CALL_FAILED, | 352 GoogleUpdateErrorCode error = GOOGLE_UPDATE_GET_RESULT_CALL_FAILED; |
339 string16(), main_loop); | 353 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); |
| 354 ReportFailure(hr, error, |
| 355 l10n_util::GetStringFUTF16( |
| 356 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, |
| 357 error_code), |
| 358 main_loop); |
340 return; | 359 return; |
341 } | 360 } |
342 | 361 |
343 if (results == UPGRADE_ERROR) { | 362 if (results == UPGRADE_ERROR) { |
344 string16 error_message; | 363 string16 error_message; |
345 job_observer->GetErrorMessage(&error_message); | 364 job_observer->GetErrorMessage(&error_message); |
346 ReportFailure(hr, GOOGLE_UPDATE_ERROR_UPDATING, error_message, main_loop); | 365 ReportFailure(hr, GOOGLE_UPDATE_ERROR_UPDATING, error_message, main_loop); |
347 return; | 366 return; |
348 } | 367 } |
349 | 368 |
350 hr = job_observer->GetVersionInfo(&version_available_); | 369 hr = job_observer->GetVersionInfo(&version_available_); |
351 if (hr != S_OK) { | 370 if (hr != S_OK) { |
352 ReportFailure(hr, GOOGLE_UPDATE_GET_VERSION_INFO_FAILED, | 371 GoogleUpdateErrorCode error = GOOGLE_UPDATE_GET_VERSION_INFO_FAILED; |
353 string16(), main_loop); | 372 string16 error_code = base::StringPrintf(L"%d: 0x%x", error, hr); |
| 373 ReportFailure(hr, error, |
| 374 l10n_util::GetStringFUTF16( |
| 375 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, |
| 376 error_code), |
| 377 main_loop); |
354 return; | 378 return; |
355 } | 379 } |
356 | 380 |
357 main_loop->PostTask( | 381 main_loop->PostTask( |
358 FROM_HERE, | 382 FROM_HERE, |
359 base::Bind(&GoogleUpdate::ReportResults, this, | 383 base::Bind(&GoogleUpdate::ReportResults, this, |
360 results, GOOGLE_UPDATE_NO_ERROR, string16())); | 384 results, GOOGLE_UPDATE_NO_ERROR, string16())); |
361 job_holder = NULL; | 385 job_holder = NULL; |
362 on_demand = NULL; | 386 on_demand = NULL; |
363 } | 387 } |
(...skipping 16 matching lines...) Expand all Loading... |
380 MessageLoop* main_loop) { | 404 MessageLoop* main_loop) { |
381 NOTREACHED() << "Communication with Google Update failed: " << hr | 405 NOTREACHED() << "Communication with Google Update failed: " << hr |
382 << " error: " << error_code | 406 << " error: " << error_code |
383 << ", message: " << error_message.c_str(); | 407 << ", message: " << error_message.c_str(); |
384 main_loop->PostTask( | 408 main_loop->PostTask( |
385 FROM_HERE, | 409 FROM_HERE, |
386 base::Bind(&GoogleUpdate::ReportResults, this, | 410 base::Bind(&GoogleUpdate::ReportResults, this, |
387 UPGRADE_ERROR, error_code, error_message)); | 411 UPGRADE_ERROR, error_code, error_message)); |
388 return false; | 412 return false; |
389 } | 413 } |
OLD | NEW |