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 #include "chrome/installer/gcapi/gcapi.h" |
| 11 | 11 |
| 12 using base::Time; | 12 using base::Time; |
| 13 using base::win::RegKey; | 13 using base::win::RegKey; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const wchar_t kReactivationHistoryKey[] = L"reactivation"; | 16 const wchar_t kReactivationHistoryKey[] = L"reactivation"; |
| 17 | 17 |
| 18 std::wstring GetReactivationHistoryKeyPath() { | 18 std::wstring GetReactivationHistoryKeyPath() { |
| 19 std::wstring reactivation_path(google_update::kRegPathClientState); | 19 std::wstring reactivation_path(google_update::kRegPathClientState); |
| 20 reactivation_path += L"\\"; | 20 reactivation_path += L"\\"; |
| 21 reactivation_path += google_update::kChromeUpgradeCode; | 21 reactivation_path += google_update::kChromeUpgradeCode; |
| 22 reactivation_path += L"\\"; | 22 reactivation_path += L"\\"; |
| 23 reactivation_path += kReactivationHistoryKey; | 23 reactivation_path += kReactivationHistoryKey; |
| 24 return reactivation_path; | 24 return reactivation_path; |
| 25 } | 25 } |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 bool HasBeenReactivatedByBrandCodes( | 28 bool HasBeenReactivated() { |
| 29 const std::vector<std::wstring>& brand_codes) { | |
| 30 bool success = false; | 29 bool success = false; |
|
robertshield
2012/03/23 17:52:16
delete this line
mgraboski
2012/03/23 21:40:35
Done.
| |
| 31 | 30 |
| 32 RegKey reactivation_key(HKEY_CURRENT_USER, | 31 RegKey reactivation_key(HKEY_CURRENT_USER, |
| 33 GetReactivationHistoryKeyPath().c_str(), | 32 GetReactivationHistoryKeyPath().c_str(), |
| 34 KEY_QUERY_VALUE); | 33 KEY_QUERY_VALUE); |
| 35 if (reactivation_key.Valid()) { | 34 if (reactivation_key.Valid()) { |
| 36 std::vector<std::wstring>::const_iterator brand_iter(brand_codes.begin()); | 35 success = true; |
| 37 for (; brand_iter != brand_codes.end(); ++brand_iter) { | |
| 38 if (reactivation_key.HasValue(brand_iter->c_str())) { | |
| 39 success = true; | |
| 40 break; | |
| 41 } | |
| 42 } | |
| 43 } | 36 } |
| 44 | 37 |
| 45 return success; | 38 return success; |
|
robertshield
2012/03/23 17:52:16
change the above four lines to:
return reactivatio
mgraboski
2012/03/23 21:40:35
Done.
| |
| 46 } | 39 } |
| 47 | 40 |
| 48 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) { | 41 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) { |
| 49 bool success = false; | 42 bool success = false; |
| 50 | 43 |
| 51 // This function currently only should be run in a non-elevated shell, | 44 // 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. | 45 // so we return "true" if it is being invoked from an elevated shell. |
| 53 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION) | 46 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION) |
| 54 return true; | 47 return true; |
| 55 | 48 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 73 if (reactivation_key.Valid()) { | 66 if (reactivation_key.Valid()) { |
| 74 int64 timestamp = Time::Now().ToInternalValue(); | 67 int64 timestamp = Time::Now().ToInternalValue(); |
| 75 reactivation_key.WriteValue(brand_code.c_str(), | 68 reactivation_key.WriteValue(brand_code.c_str(), |
| 76 ×tamp, | 69 ×tamp, |
| 77 sizeof(timestamp), | 70 sizeof(timestamp), |
| 78 REG_QWORD); | 71 REG_QWORD); |
| 79 } | 72 } |
| 80 } | 73 } |
| 81 | 74 |
| 82 return success; | 75 return success; |
| 83 } | 76 } |
| 77 | |
| OLD | NEW |