Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Side by Side Diff: chrome/installer/gcapi/gcapi_reactivation.cc

Issue 9704022: This patch modifies some aspects of GCAPI in support of the new Chrome reactivation functions. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
31
32 RegKey reactivation_key(HKEY_CURRENT_USER, 29 RegKey reactivation_key(HKEY_CURRENT_USER,
33 GetReactivationHistoryKeyPath().c_str(), 30 GetReactivationHistoryKeyPath().c_str(),
34 KEY_QUERY_VALUE); 31 KEY_QUERY_VALUE);
35 if (reactivation_key.Valid()) {
36 std::vector<std::wstring>::const_iterator brand_iter(brand_codes.begin());
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 }
44 32
45 return success; 33 return reactivation_key.Valid();
46 } 34 }
47 35
48 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) { 36 bool SetReactivationBrandCode(const std::wstring& brand_code, int shell_mode) {
49 bool success = false; 37 bool success = false;
50 38
51 // This function currently only should be run in a non-elevated shell, 39 // 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. 40 // so we return "true" if it is being invoked from an elevated shell.
53 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION) 41 if (shell_mode == GCAPI_INVOKED_UAC_ELEVATION)
54 return true; 42 return true;
55 43
(...skipping 17 matching lines...) Expand all
73 if (reactivation_key.Valid()) { 61 if (reactivation_key.Valid()) {
74 int64 timestamp = Time::Now().ToInternalValue(); 62 int64 timestamp = Time::Now().ToInternalValue();
75 reactivation_key.WriteValue(brand_code.c_str(), 63 reactivation_key.WriteValue(brand_code.c_str(),
76 &timestamp, 64 &timestamp,
77 sizeof(timestamp), 65 sizeof(timestamp),
78 REG_QWORD); 66 REG_QWORD);
79 } 67 }
80 } 68 }
81 69
82 return success; 70 return success;
83 } 71 }
72
OLDNEW
« no previous file with comments | « chrome/installer/gcapi/gcapi_reactivation.h ('k') | chrome/installer/gcapi/gcapi_reactivation_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698