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 HasBeenReactivatedByBrandCodes( |
|
robertshield
2012/03/15 03:52:32
change this method's name to "HasBeenReactivated"
mgraboski
2012/03/22 00:33:25
Done.
| |
| 29 const std::vector<std::wstring>& brand_codes) { | 29 const std::vector<std::wstring>& brand_codes) { |
| 30 bool success = false; | 30 bool success = false; |
| 31 | 31 |
| 32 RegKey reactivation_key(HKEY_CURRENT_USER, | 32 RegKey reactivation_key(HKEY_CURRENT_USER, |
| 33 GetReactivationHistoryKeyPath().c_str(), | 33 GetReactivationHistoryKeyPath().c_str(), |
| 34 KEY_QUERY_VALUE); | 34 KEY_QUERY_VALUE); |
| 35 if (reactivation_key.Valid()) { | 35 if (reactivation_key.Valid()) { |
| 36 std::vector<std::wstring>::const_iterator brand_iter(brand_codes.begin()); | 36 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 } | 37 } |
| 44 | 38 |
| 45 return success; | 39 return success; |
| 46 } | 40 } |
| 47 | 41 |
| 48 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) { | 42 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) { |
| 49 bool success = false; | 43 bool success = false; |
| 50 | 44 |
| 51 // This function currently only should be run in a non-elevated shell, | 45 // 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. | 46 // so we return "true" if it is being invoked from an elevated shell. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 73 if (reactivation_key.Valid()) { | 67 if (reactivation_key.Valid()) { |
| 74 int64 timestamp = Time::Now().ToInternalValue(); | 68 int64 timestamp = Time::Now().ToInternalValue(); |
| 75 reactivation_key.WriteValue(brand_code.c_str(), | 69 reactivation_key.WriteValue(brand_code.c_str(), |
| 76 ×tamp, | 70 ×tamp, |
| 77 sizeof(timestamp), | 71 sizeof(timestamp), |
| 78 REG_QWORD); | 72 REG_QWORD); |
| 79 } | 73 } |
| 80 } | 74 } |
| 81 | 75 |
| 82 return success; | 76 return success; |
| 83 } | 77 } |
| OLD | NEW |