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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 KEY_CREATE_SUB_KEY | KEY_SET_VALUE); | 34 KEY_CREATE_SUB_KEY | KEY_SET_VALUE); |
35 return (client_state.Valid() && | 35 return (client_state.Valid() && |
36 client_state.WriteValue( | 36 client_state.WriteValue( |
37 google_update::kRegVersionField, L"1.2.3.4") == ERROR_SUCCESS); | 37 google_update::kRegVersionField, L"1.2.3.4") == ERROR_SUCCESS); |
38 } | 38 } |
39 | 39 |
40 bool SetLastRunTime(HKEY hive, int64 last_run_time) { | 40 bool SetLastRunTime(HKEY hive, int64 last_run_time) { |
41 return SetLastRunTimeString(hive, base::Int64ToString16(last_run_time)); | 41 return SetLastRunTimeString(hive, base::Int64ToString16(last_run_time)); |
42 } | 42 } |
43 | 43 |
44 bool SetLastRunTimeString(HKEY hive, const string16& last_run_time_string) { | 44 bool SetLastRunTimeString(HKEY hive, |
| 45 const base::string16& last_run_time_string) { |
45 const wchar_t* base_path = | 46 const wchar_t* base_path = |
46 (hive == HKEY_LOCAL_MACHINE) ? | 47 (hive == HKEY_LOCAL_MACHINE) ? |
47 google_update::kRegPathClientStateMedium : | 48 google_update::kRegPathClientStateMedium : |
48 google_update::kRegPathClientState; | 49 google_update::kRegPathClientState; |
49 std::wstring path(base_path); | 50 std::wstring path(base_path); |
50 path += L"\\"; | 51 path += L"\\"; |
51 path += google_update::kChromeUpgradeCode; | 52 path += google_update::kChromeUpgradeCode; |
52 | 53 |
53 RegKey client_state(hive, path.c_str(), KEY_SET_VALUE); | 54 RegKey client_state(hive, path.c_str(), KEY_SET_VALUE); |
54 return (client_state.Valid() && | 55 return (client_state.Valid() && |
55 client_state.WriteValue( | 56 client_state.WriteValue( |
56 google_update::kRegLastRunTimeField, | 57 google_update::kRegLastRunTimeField, |
57 last_run_time_string.c_str()) == ERROR_SUCCESS); | 58 last_run_time_string.c_str()) == ERROR_SUCCESS); |
58 } | 59 } |
59 | 60 |
60 bool HasExperimentLabels(HKEY hive) { | 61 bool HasExperimentLabels(HKEY hive) { |
61 string16 client_state_path(google_update::kRegPathClientState); | 62 base::string16 client_state_path(google_update::kRegPathClientState); |
62 client_state_path.push_back(L'\\'); | 63 client_state_path.push_back(L'\\'); |
63 client_state_path.append(google_update::kChromeUpgradeCode); | 64 client_state_path.append(google_update::kChromeUpgradeCode); |
64 | 65 |
65 RegKey client_state_key(hive, | 66 RegKey client_state_key(hive, |
66 client_state_path.c_str(), | 67 client_state_path.c_str(), |
67 KEY_QUERY_VALUE); | 68 KEY_QUERY_VALUE); |
68 return client_state_key.Valid() && | 69 return client_state_key.Valid() && |
69 client_state_key.HasValue(google_update::kExperimentLabels); | 70 client_state_key.HasValue(google_update::kExperimentLabels); |
70 } | 71 } |
71 | 72 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER, | 201 EXPECT_TRUE(SetLastRunTime(HKEY_CURRENT_USER, |
201 hkcu_last_run.ToInternalValue())); | 202 hkcu_last_run.ToInternalValue())); |
202 | 203 |
203 EXPECT_TRUE(ReactivateChrome(L"GAGA", | 204 EXPECT_TRUE(ReactivateChrome(L"GAGA", |
204 GCAPI_INVOKED_STANDARD_SHELL, | 205 GCAPI_INVOKED_STANDARD_SHELL, |
205 &error)); | 206 &error)); |
206 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); | 207 EXPECT_EQ(L"GAGA", GetReactivationString(HKEY_CURRENT_USER)); |
207 | 208 |
208 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER)); | 209 EXPECT_TRUE(HasExperimentLabels(HKEY_CURRENT_USER)); |
209 } | 210 } |
OLD | NEW |