| 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/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/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/scoped_comptr_win.h" | |
| 14 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 15 #include "base/task.h" | 14 #include "base/task.h" |
| 16 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 17 #include "base/win/registry.h" | 16 #include "base/win/registry.h" |
| 17 #include "base/win/scoped_comptr.h" |
| 18 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
| 19 #include "chrome/installer/util/browser_distribution.h" | 19 #include "chrome/installer/util/browser_distribution.h" |
| 20 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
| 21 #include "chrome/installer/util/helper.h" | 21 #include "chrome/installer/util/helper.h" |
| 22 #include "chrome/installer/util/install_util.h" | 22 #include "chrome/installer/util/install_util.h" |
| 23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
| 24 #include "google_update_idl_i.c" |
| 24 #include "views/window/window.h" | 25 #include "views/window/window.h" |
| 25 #include "google_update_idl_i.c" | |
| 26 | 26 |
| 27 using views::Window; | 27 using views::Window; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // The registry location of the Google Update policies. | 31 // The registry location of the Google Update policies. |
| 32 const wchar_t kGUPolicyRegistrySubKey[] = | 32 const wchar_t kGUPolicyRegistrySubKey[] = |
| 33 L"SOFTWARE\\Policies\\Google\\Update"; | 33 L"SOFTWARE\\Policies\\Google\\Update"; |
| 34 const wchar_t kGUPolicyGlobalValue[] = L"UpdateDefault"; | 34 const wchar_t kGUPolicyGlobalValue[] = L"UpdateDefault"; |
| 35 const wchar_t kGUPolicyAppValuePrefix[] = L"Update"; | 35 const wchar_t kGUPolicyAppValuePrefix[] = L"Update"; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 private: | 229 private: |
| 230 // The status/result of the Google Update operation. | 230 // The status/result of the Google Update operation. |
| 231 GoogleUpdateUpgradeResult result_; | 231 GoogleUpdateUpgradeResult result_; |
| 232 | 232 |
| 233 // The version string Google Update found. | 233 // The version string Google Update found. |
| 234 std::wstring new_version_; | 234 std::wstring new_version_; |
| 235 | 235 |
| 236 // Allows us control the upgrade process to a small degree. After OnComplete | 236 // Allows us control the upgrade process to a small degree. After OnComplete |
| 237 // has been called, this object can not be used. | 237 // has been called, this object can not be used. |
| 238 ScopedComPtr<IProgressWndEvents> event_sink_; | 238 base::win::ScopedComPtr<IProgressWndEvents> event_sink_; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 //////////////////////////////////////////////////////////////////////////////// | 241 //////////////////////////////////////////////////////////////////////////////// |
| 242 // GoogleUpdate, public: | 242 // GoogleUpdate, public: |
| 243 | 243 |
| 244 GoogleUpdate::GoogleUpdate() | 244 GoogleUpdate::GoogleUpdate() |
| 245 : listener_(NULL) { | 245 : listener_(NULL) { |
| 246 } | 246 } |
| 247 | 247 |
| 248 GoogleUpdate::~GoogleUpdate() { | 248 GoogleUpdate::~GoogleUpdate() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 285 } |
| 286 | 286 |
| 287 CComObject<GoogleUpdateJobObserver>* job_observer; | 287 CComObject<GoogleUpdateJobObserver>* job_observer; |
| 288 HRESULT hr = | 288 HRESULT hr = |
| 289 CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer); | 289 CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer); |
| 290 if (hr != S_OK) { | 290 if (hr != S_OK) { |
| 291 return ReportFailure(hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, | 291 return ReportFailure(hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, |
| 292 main_loop); | 292 main_loop); |
| 293 } | 293 } |
| 294 | 294 |
| 295 ScopedComPtr<IJobObserver> job_holder(job_observer); | 295 base::win::ScopedComPtr<IJobObserver> job_holder(job_observer); |
| 296 | 296 |
| 297 ScopedComPtr<IGoogleUpdate> on_demand; | 297 base::win::ScopedComPtr<IGoogleUpdate> on_demand; |
| 298 | 298 |
| 299 bool system_level = false; | 299 bool system_level = false; |
| 300 | 300 |
| 301 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str())) { | 301 if (InstallUtil::IsPerUserInstall(chrome_exe.c_str())) { |
| 302 hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); | 302 hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); |
| 303 } else { | 303 } else { |
| 304 // The Update operation needs Admin privileges for writing | 304 // The Update operation needs Admin privileges for writing |
| 305 // to %ProgramFiles%. On Vista we need to elevate before instantiating | 305 // to %ProgramFiles%. On Vista we need to elevate before instantiating |
| 306 // the updater instance. | 306 // the updater instance. |
| 307 if (!install_if_newer) { | 307 if (!install_if_newer) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 369 } |
| 370 | 370 |
| 371 bool GoogleUpdate::ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, | 371 bool GoogleUpdate::ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, |
| 372 MessageLoop* main_loop) { | 372 MessageLoop* main_loop) { |
| 373 NOTREACHED() << "Communication with Google Update failed: " << hr | 373 NOTREACHED() << "Communication with Google Update failed: " << hr |
| 374 << " error: " << error_code; | 374 << " error: " << error_code; |
| 375 main_loop->PostTask(FROM_HERE, NewRunnableMethod(this, | 375 main_loop->PostTask(FROM_HERE, NewRunnableMethod(this, |
| 376 &GoogleUpdate::ReportResults, UPGRADE_ERROR, error_code)); | 376 &GoogleUpdate::ReportResults, UPGRADE_ERROR, error_code)); |
| 377 return false; | 377 return false; |
| 378 } | 378 } |
| OLD | NEW |