| 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_win.h" | 5 #include "chrome/browser/google/google_update_win.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <objbase.h> | 9 #include <objbase.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 IID_PPV_ARGS(&class_factory)); | 186 IID_PPV_ARGS(&class_factory)); |
| 187 } else { | 187 } else { |
| 188 // With older versions of GoogleUpdate, a system-level update requires Admin | 188 // With older versions of GoogleUpdate, a system-level update requires Admin |
| 189 // privileges. Elevate while instantiating the MachineClass. | 189 // privileges. Elevate while instantiating the MachineClass. |
| 190 hresult = CoGetClassObjectAsAdmin(elevation_window, google_update_clsid, | 190 hresult = CoGetClassObjectAsAdmin(elevation_window, google_update_clsid, |
| 191 IID_PPV_ARGS(&class_factory)); | 191 IID_PPV_ARGS(&class_factory)); |
| 192 } | 192 } |
| 193 if (FAILED(hresult)) | 193 if (FAILED(hresult)) |
| 194 return hresult; | 194 return hresult; |
| 195 | 195 |
| 196 ConfigureProxyBlanket(class_factory.get()); | 196 ConfigureProxyBlanket(class_factory.Get()); |
| 197 | 197 |
| 198 return class_factory->CreateInstance(nullptr, IID_PPV_ARGS(google_update)); | 198 return class_factory->CreateInstance(nullptr, IID_PPV_ARGS(google_update)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // UpdateCheckDriver ----------------------------------------------------------- | 201 // UpdateCheckDriver ----------------------------------------------------------- |
| 202 | 202 |
| 203 // A driver that is created and destroyed on the caller's thread and drives | 203 // A driver that is created and destroyed on the caller's thread and drives |
| 204 // Google Update on another. | 204 // Google Update on another. |
| 205 class UpdateCheckDriver { | 205 class UpdateCheckDriver { |
| 206 public: | 206 public: |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 return E_FAIL; | 508 return E_FAIL; |
| 509 | 509 |
| 510 hresult = CreateGoogleUpdate3WebClass(system_level_install_, | 510 hresult = CreateGoogleUpdate3WebClass(system_level_install_, |
| 511 install_update_if_possible_, | 511 install_update_if_possible_, |
| 512 elevation_window_, &google_update_); | 512 elevation_window_, &google_update_); |
| 513 if (FAILED(hresult)) { | 513 if (FAILED(hresult)) { |
| 514 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; | 514 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND; |
| 515 return hresult; | 515 return hresult; |
| 516 } | 516 } |
| 517 | 517 |
| 518 ConfigureProxyBlanket(google_update_.get()); | 518 ConfigureProxyBlanket(google_update_.Get()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 // The class was created, so all subsequent errors are reported as: | 521 // The class was created, so all subsequent errors are reported as: |
| 522 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR; | 522 *error_code = GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR; |
| 523 | 523 |
| 524 // Create an app bundle. | 524 // Create an app bundle. |
| 525 if (!app_bundle_) { | 525 if (!app_bundle_) { |
| 526 base::win::ScopedComPtr<IAppBundleWeb> app_bundle; | 526 base::win::ScopedComPtr<IAppBundleWeb> app_bundle; |
| 527 base::win::ScopedComPtr<IDispatch> dispatch; | 527 base::win::ScopedComPtr<IDispatch> dispatch; |
| 528 hresult = google_update_->createAppBundleWeb(dispatch.Receive()); | 528 hresult = google_update_->createAppBundleWeb(dispatch.Receive()); |
| 529 if (FAILED(hresult)) | 529 if (FAILED(hresult)) |
| 530 return hresult; | 530 return hresult; |
| 531 hresult = dispatch.QueryInterface(app_bundle.Receive()); | 531 hresult = dispatch.QueryInterface(app_bundle.Receive()); |
| 532 if (FAILED(hresult)) | 532 if (FAILED(hresult)) |
| 533 return hresult; | 533 return hresult; |
| 534 dispatch.Reset(); | 534 dispatch.Reset(); |
| 535 | 535 |
| 536 ConfigureProxyBlanket(app_bundle.get()); | 536 ConfigureProxyBlanket(app_bundle.Get()); |
| 537 | 537 |
| 538 if (!locale_.empty()) { | 538 if (!locale_.empty()) { |
| 539 // Ignore the result of this since, while setting the display language is | 539 // Ignore the result of this since, while setting the display language is |
| 540 // nice to have, a failure to do so does not affect the likelihood that | 540 // nice to have, a failure to do so does not affect the likelihood that |
| 541 // the update check and/or install will succeed. | 541 // the update check and/or install will succeed. |
| 542 app_bundle->put_displayLanguage( | 542 app_bundle->put_displayLanguage( |
| 543 base::win::ScopedBstr(base::UTF8ToUTF16(locale_).c_str())); | 543 base::win::ScopedBstr(base::UTF8ToUTF16(locale_).c_str())); |
| 544 } | 544 } |
| 545 | 545 |
| 546 hresult = app_bundle->initialize(); | 546 hresult = app_bundle->initialize(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 571 // this point onward result in it being released. | 571 // this point onward result in it being released. |
| 572 base::win::ScopedComPtr<IAppBundleWeb> app_bundle; | 572 base::win::ScopedComPtr<IAppBundleWeb> app_bundle; |
| 573 app_bundle.swap(app_bundle_); | 573 app_bundle.swap(app_bundle_); |
| 574 hresult = app_bundle->get_appWeb(0, dispatch.Receive()); | 574 hresult = app_bundle->get_appWeb(0, dispatch.Receive()); |
| 575 if (FAILED(hresult)) | 575 if (FAILED(hresult)) |
| 576 return hresult; | 576 return hresult; |
| 577 base::win::ScopedComPtr<IAppWeb> app; | 577 base::win::ScopedComPtr<IAppWeb> app; |
| 578 hresult = dispatch.QueryInterface(app.Receive()); | 578 hresult = dispatch.QueryInterface(app.Receive()); |
| 579 if (FAILED(hresult)) | 579 if (FAILED(hresult)) |
| 580 return hresult; | 580 return hresult; |
| 581 ConfigureProxyBlanket(app.get()); | 581 ConfigureProxyBlanket(app.Get()); |
| 582 hresult = app_bundle->checkForUpdate(); | 582 hresult = app_bundle->checkForUpdate(); |
| 583 if (FAILED(hresult)) | 583 if (FAILED(hresult)) |
| 584 return hresult; | 584 return hresult; |
| 585 app_bundle_.swap(app_bundle); | 585 app_bundle_.swap(app_bundle); |
| 586 app_.swap(app); | 586 app_.swap(app); |
| 587 } | 587 } |
| 588 | 588 |
| 589 return hresult; | 589 return hresult; |
| 590 } | 590 } |
| 591 | 591 |
| 592 bool UpdateCheckDriver::GetCurrentState( | 592 bool UpdateCheckDriver::GetCurrentState( |
| 593 base::win::ScopedComPtr<ICurrentState>* current_state, | 593 base::win::ScopedComPtr<ICurrentState>* current_state, |
| 594 CurrentState* state_value, | 594 CurrentState* state_value, |
| 595 HRESULT* hresult) const { | 595 HRESULT* hresult) const { |
| 596 base::win::ScopedComPtr<IDispatch> dispatch; | 596 base::win::ScopedComPtr<IDispatch> dispatch; |
| 597 *hresult = app_->get_currentState(dispatch.Receive()); | 597 *hresult = app_->get_currentState(dispatch.Receive()); |
| 598 if (FAILED(*hresult)) | 598 if (FAILED(*hresult)) |
| 599 return false; | 599 return false; |
| 600 *hresult = dispatch.QueryInterface(current_state->Receive()); | 600 *hresult = dispatch.QueryInterface(current_state->Receive()); |
| 601 if (FAILED(*hresult)) | 601 if (FAILED(*hresult)) |
| 602 return false; | 602 return false; |
| 603 ConfigureProxyBlanket(current_state->get()); | 603 ConfigureProxyBlanket(current_state->Get()); |
| 604 LONG value = 0; | 604 LONG value = 0; |
| 605 *hresult = (*current_state)->get_stateValue(&value); | 605 *hresult = (*current_state)->get_stateValue(&value); |
| 606 if (FAILED(*hresult)) | 606 if (FAILED(*hresult)) |
| 607 return false; | 607 return false; |
| 608 *state_value = static_cast<CurrentState>(value); | 608 *state_value = static_cast<CurrentState>(value); |
| 609 return true; | 609 return true; |
| 610 } | 610 } |
| 611 | 611 |
| 612 bool UpdateCheckDriver::IsErrorState( | 612 bool UpdateCheckDriver::IsErrorState( |
| 613 const base::win::ScopedComPtr<ICurrentState>& current_state, | 613 const base::win::ScopedComPtr<ICurrentState>& current_state, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 const GoogleUpdate3ClassFactory& google_update_factory) { | 883 const GoogleUpdate3ClassFactory& google_update_factory) { |
| 884 if (g_google_update_factory) { | 884 if (g_google_update_factory) { |
| 885 delete g_google_update_factory; | 885 delete g_google_update_factory; |
| 886 g_google_update_factory = nullptr; | 886 g_google_update_factory = nullptr; |
| 887 } | 887 } |
| 888 if (!google_update_factory.is_null()) { | 888 if (!google_update_factory.is_null()) { |
| 889 g_google_update_factory = | 889 g_google_update_factory = |
| 890 new GoogleUpdate3ClassFactory(google_update_factory); | 890 new GoogleUpdate3ClassFactory(google_update_factory); |
| 891 } | 891 } |
| 892 } | 892 } |
| OLD | NEW |