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/installer/gcapi/gcapi_reactivation.h" | 5 #include "chrome/installer/gcapi/gcapi_reactivation.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "base/win/registry.h" | 8 #include "base/win/registry.h" |
| 9 #include "chrome/installer/util/google_update_constants.h" | 9 #include "chrome/installer/util/google_update_constants.h" |
| 10 #include "chrome/installer/gcapi/gcapi.h" | |
| 10 | 11 |
| 11 using base::Time; | 12 using base::Time; |
| 12 using base::win::RegKey; | 13 using base::win::RegKey; |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 const wchar_t kReactivationHistoryKey[] = L"reactivation"; | 16 const wchar_t kReactivationHistoryKey[] = L"reactivation"; |
| 16 | 17 |
| 17 std::wstring GetReactivationHistoryKeyPath() { | 18 std::wstring GetReactivationHistoryKeyPath() { |
| 18 std::wstring reactivation_path(google_update::kRegPathClientState); | 19 std::wstring reactivation_path(google_update::kRegPathClientState); |
| 19 reactivation_path += L"\\"; | 20 reactivation_path += L"\\"; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 37 if (reactivation_key.HasValue(brand_iter->c_str())) { | 38 if (reactivation_key.HasValue(brand_iter->c_str())) { |
| 38 success = true; | 39 success = true; |
| 39 break; | 40 break; |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 return success; | 45 return success; |
| 45 } | 46 } |
| 46 | 47 |
| 47 bool SetReactivationBrandCode(const std::wstring& brand_code) { | 48 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) { |
| 48 bool success = false; | 49 bool success = false; |
| 49 | 50 |
| 51 // This function currently only should be run in a non-elevated shell, | |
| 52 // so we return "true" if it is being invoked from an elevated shell. | |
| 53 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION) { | |
| 54 return true; | |
| 55 } | |
|
Roger Tawa OOO till Jul 10th
2012/02/24 21:46:59
no need for { and }
robertshield
2012/02/24 22:21:40
Done.
| |
| 56 | |
| 50 std::wstring path(google_update::kRegPathClientState); | 57 std::wstring path(google_update::kRegPathClientState); |
| 51 path += L"\\"; | 58 path += L"\\"; |
| 52 path += google_update::kChromeUpgradeCode; | 59 path += google_update::kChromeUpgradeCode; |
| 53 | 60 |
| 54 RegKey client_state_key(HKEY_CURRENT_USER, path.c_str(), KEY_SET_VALUE); | 61 RegKey client_state_key(HKEY_CURRENT_USER, path.c_str(), KEY_SET_VALUE); |
| 55 if (client_state_key.Valid()) { | 62 if (client_state_key.Valid()) { |
| 56 success = client_state_key.WriteValue( | 63 success = client_state_key.WriteValue( |
| 57 google_update::kRegRLZReactivationBrandField, | 64 google_update::kRegRLZReactivationBrandField, |
| 58 brand_code.c_str()) == ERROR_SUCCESS; | 65 brand_code.c_str()) == ERROR_SUCCESS; |
| 59 } | 66 } |
| 60 | 67 |
| 61 if (success) { | 68 if (success) { |
| 62 // Store this brand code in the reactivation history. Store it with a | 69 // Store this brand code in the reactivation history. Store it with a |
| 63 // a currently un-used timestamp for future proofing. | 70 // a currently un-used timestamp for future proofing. |
| 64 RegKey reactivation_key(HKEY_CURRENT_USER, | 71 RegKey reactivation_key(HKEY_CURRENT_USER, |
| 65 GetReactivationHistoryKeyPath().c_str(), | 72 GetReactivationHistoryKeyPath().c_str(), |
| 66 KEY_WRITE); | 73 KEY_WRITE); |
| 67 if (reactivation_key.Valid()) { | 74 if (reactivation_key.Valid()) { |
| 68 int64 timestamp = Time::Now().ToInternalValue(); | 75 int64 timestamp = Time::Now().ToInternalValue(); |
| 69 reactivation_key.WriteValue(brand_code.c_str(), | 76 reactivation_key.WriteValue(brand_code.c_str(), |
| 70 ×tamp, | 77 ×tamp, |
| 71 sizeof(timestamp), | 78 sizeof(timestamp), |
| 72 REG_QWORD); | 79 REG_QWORD); |
| 73 } | 80 } |
| 74 } | 81 } |
| 75 | 82 |
| 76 return success; | 83 return success; |
| 77 } | 84 } |
| OLD | NEW |