OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/safe_browsing/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "chrome/browser/profiles/profile_io_data.h" | 37 #include "chrome/browser/profiles/profile_io_data.h" |
38 #include "chrome/browser/safe_browsing/srt_chrome_prompt_impl.h" | 38 #include "chrome/browser/safe_browsing/srt_chrome_prompt_impl.h" |
39 #include "chrome/browser/safe_browsing/srt_client_info_win.h" | 39 #include "chrome/browser/safe_browsing/srt_client_info_win.h" |
40 #include "chrome/browser/safe_browsing/srt_global_error_win.h" | 40 #include "chrome/browser/safe_browsing/srt_global_error_win.h" |
41 #include "chrome/browser/ui/browser_finder.h" | 41 #include "chrome/browser/ui/browser_finder.h" |
42 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
43 #include "chrome/browser/ui/browser_list_observer.h" | 43 #include "chrome/browser/ui/browser_list_observer.h" |
44 #include "chrome/browser/ui/global_error/global_error_service.h" | 44 #include "chrome/browser/ui/global_error/global_error_service.h" |
45 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 45 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "components/chrome_cleaner/public/constants/constants.h" |
47 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h" | 48 #include "components/chrome_cleaner/public/interfaces/chrome_prompt.mojom.h" |
48 #include "components/component_updater/pref_names.h" | 49 #include "components/component_updater/pref_names.h" |
49 #include "components/data_use_measurement/core/data_use_user_data.h" | 50 #include "components/data_use_measurement/core/data_use_user_data.h" |
50 #include "components/prefs/pref_service.h" | 51 #include "components/prefs/pref_service.h" |
51 #include "components/variations/net/variations_http_headers.h" | 52 #include "components/variations/net/variations_http_headers.h" |
52 #include "components/version_info/version_info.h" | 53 #include "components/version_info/version_info.h" |
53 #include "content/public/browser/browser_thread.h" | 54 #include "content/public/browser/browser_thread.h" |
54 #include "mojo/edk/embedder/connection_params.h" | 55 #include "mojo/edk/embedder/connection_params.h" |
55 #include "mojo/edk/embedder/pending_process_connection.h" | 56 #include "mojo/edk/embedder/pending_process_connection.h" |
56 #include "mojo/edk/embedder/platform_channel_pair.h" | 57 #include "mojo/edk/embedder/platform_channel_pair.h" |
57 #include "mojo/public/cpp/system/message_pipe.h" | 58 #include "mojo/public/cpp/system/message_pipe.h" |
58 #include "net/base/load_flags.h" | 59 #include "net/base/load_flags.h" |
59 #include "net/http/http_status_code.h" | 60 #include "net/http/http_status_code.h" |
60 #include "net/url_request/url_fetcher.h" | 61 #include "net/url_request/url_fetcher.h" |
61 #include "net/url_request/url_fetcher_delegate.h" | 62 #include "net/url_request/url_fetcher_delegate.h" |
62 #include "net/url_request/url_request_context_getter.h" | 63 #include "net/url_request/url_request_context_getter.h" |
63 | 64 |
64 using content::BrowserThread; | 65 using content::BrowserThread; |
65 | 66 |
66 namespace safe_browsing { | 67 namespace safe_browsing { |
67 | 68 |
68 // TODO(b/647763) Change the registry key to properly handle cases when the user | |
69 // runs Google Chrome stable alongside Google Chrome SxS. | |
70 const wchar_t kSoftwareRemovalToolRegistryKey[] = | |
71 L"Software\\Google\\Software Removal Tool"; | |
72 | |
73 const wchar_t kCleanerSubKey[] = L"Cleaner"; | |
74 | |
75 const wchar_t kEndTimeValueName[] = L"EndTime"; | |
76 const wchar_t kStartTimeValueName[] = L"StartTime"; | |
77 | |
78 const base::Feature kInBrowserCleanerUIFeature{ | 69 const base::Feature kInBrowserCleanerUIFeature{ |
79 "InBrowserCleanerUI", base::FEATURE_DISABLED_BY_DEFAULT}; | 70 "InBrowserCleanerUI", base::FEATURE_DISABLED_BY_DEFAULT}; |
80 | 71 |
81 const char kChromeMojoPipeTokenSwitch[] = "chrome-mojo-pipe-token"; | |
82 | |
83 namespace { | 72 namespace { |
84 | 73 |
85 // Used to send UMA information about missing start and end time registry | 74 // Used to send UMA information about missing start and end time registry |
86 // values for the reporter. Replicated in the histograms.xml file, so the order | 75 // values for the reporter. Replicated in the histograms.xml file, so the order |
87 // MUST NOT CHANGE. | 76 // MUST NOT CHANGE. |
88 enum SwReporterRunningTimeRegistryError { | 77 enum SwReporterRunningTimeRegistryError { |
89 REPORTER_RUNNING_TIME_ERROR_NO_ERROR = 0, | 78 REPORTER_RUNNING_TIME_ERROR_NO_ERROR = 0, |
90 REPORTER_RUNNING_TIME_ERROR_REGISTRY_KEY_INVALID = 1, | 79 REPORTER_RUNNING_TIME_ERROR_REGISTRY_KEY_INVALID = 1, |
91 REPORTER_RUNNING_TIME_ERROR_MISSING_START_TIME = 2, | 80 REPORTER_RUNNING_TIME_ERROR_MISSING_START_TIME = 2, |
92 REPORTER_RUNNING_TIME_ERROR_MISSING_END_TIME = 3, | 81 REPORTER_RUNNING_TIME_ERROR_MISSING_END_TIME = 3, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_NOT_FOUND = 2, | 130 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_NOT_FOUND = 2, |
142 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_OUT_OF_BOUNDS = 3, | 131 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_OUT_OF_BOUNDS = 3, |
143 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX, | 132 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX, |
144 }; | 133 }; |
145 | 134 |
146 const char kRunningTimeErrorMetricName[] = | 135 const char kRunningTimeErrorMetricName[] = |
147 "SoftwareReporter.RunningTimeRegistryError"; | 136 "SoftwareReporter.RunningTimeRegistryError"; |
148 | 137 |
149 SwReporterTestingDelegate* g_testing_delegate_ = nullptr; | 138 SwReporterTestingDelegate* g_testing_delegate_ = nullptr; |
150 | 139 |
151 const wchar_t kScanTimesSubKey[] = L"ScanTimes"; | |
152 const wchar_t kFoundUwsValueName[] = L"FoundUws"; | |
153 const wchar_t kMemoryUsedValueName[] = L"MemoryUsed"; | |
154 const wchar_t kLogsUploadResultValueName[] = L"LogsUploadResult"; | |
155 const wchar_t kExitCodeValueName[] = L"ExitCode"; | |
156 const wchar_t kEngineErrorCodeValueName[] = L"EngineErrorCode"; | |
157 | |
158 const char kFoundUwsMetricName[] = "SoftwareReporter.FoundUwS"; | 140 const char kFoundUwsMetricName[] = "SoftwareReporter.FoundUwS"; |
159 const char kFoundUwsReadErrorMetricName[] = | 141 const char kFoundUwsReadErrorMetricName[] = |
160 "SoftwareReporter.FoundUwSReadError"; | 142 "SoftwareReporter.FoundUwSReadError"; |
161 const char kScanTimesMetricName[] = "SoftwareReporter.UwSScanTimes"; | 143 const char kScanTimesMetricName[] = "SoftwareReporter.UwSScanTimes"; |
162 const char kMemoryUsedMetricName[] = "SoftwareReporter.MemoryUsed"; | 144 const char kMemoryUsedMetricName[] = "SoftwareReporter.MemoryUsed"; |
163 const char kStepMetricName[] = "SoftwareReporter.Step"; | 145 const char kStepMetricName[] = "SoftwareReporter.Step"; |
164 const char kLogsUploadEnabledMetricName[] = | 146 const char kLogsUploadEnabledMetricName[] = |
165 "SoftwareReporter.LogsUploadEnabled"; | 147 "SoftwareReporter.LogsUploadEnabled"; |
166 const char kLogsUploadResultMetricName[] = "SoftwareReporter.LogsUploadResult"; | 148 const char kLogsUploadResultMetricName[] = "SoftwareReporter.LogsUploadResult"; |
167 const char kLogsUploadResultRegistryErrorMetricName[] = | 149 const char kLogsUploadResultRegistryErrorMetricName[] = |
168 "SoftwareReporter.LogsUploadResultRegistryError"; | 150 "SoftwareReporter.LogsUploadResultRegistryError"; |
169 const char kExitCodeMetricName[] = "SoftwareReporter.ExitCodeFromRegistry"; | 151 const char kExitCodeMetricName[] = "SoftwareReporter.ExitCodeFromRegistry"; |
170 const char kEngineErrorCodeMetricName[] = "SoftwareReporter.EngineErrorCode"; | 152 const char kEngineErrorCodeMetricName[] = "SoftwareReporter.EngineErrorCode"; |
171 | 153 |
172 // The max value for histogram SoftwareReporter.LogsUploadResult, which is used | 154 // The max value for histogram SoftwareReporter.LogsUploadResult, which is used |
173 // to send UMA information about the result of Software Reporter's attempt to | 155 // to send UMA information about the result of Software Reporter's attempt to |
174 // upload logs, when logs are enabled. This value must be consistent with the | 156 // upload logs, when logs are enabled. This value must be consistent with the |
175 // SoftwareReporterLogsUploadResult enum defined in the histograms.xml file. | 157 // SoftwareReporterLogsUploadResult enum defined in the histograms.xml file. |
176 const int kSwReporterLogsUploadResultMax = 30; | 158 const int kSwReporterLogsUploadResultMax = 30; |
177 | 159 |
178 // Reports metrics about the software reporter via UMA (and sometimes Rappor). | 160 // Reports metrics about the software reporter via UMA (and sometimes Rappor). |
179 class UMAHistogramReporter { | 161 class UMAHistogramReporter { |
180 public: | 162 public: |
181 UMAHistogramReporter() : UMAHistogramReporter(std::string()) {} | 163 UMAHistogramReporter() : UMAHistogramReporter(std::string()) {} |
182 | 164 |
183 explicit UMAHistogramReporter(const std::string& suffix) | 165 explicit UMAHistogramReporter(const std::string& suffix) |
184 : suffix_(suffix), | 166 : suffix_(suffix), |
185 registry_key_(suffix.empty() ? kSoftwareRemovalToolRegistryKey | 167 registry_key_(suffix.empty() |
186 : base::StringPrintf( | 168 ? chrome_cleaner::kSoftwareRemovalToolRegistryKey |
187 L"%ls\\%ls", | 169 : base::StringPrintf( |
188 kSoftwareRemovalToolRegistryKey, | 170 L"%ls\\%ls", |
189 base::UTF8ToUTF16(suffix).c_str())) { | 171 chrome_cleaner::kSoftwareRemovalToolRegistryKey, |
190 } | 172 base::UTF8ToUTF16(suffix).c_str())) {} |
191 | 173 |
192 // Reports the software reporter tool's version via UMA. | 174 // Reports the software reporter tool's version via UMA. |
193 void ReportVersion(const base::Version& version) const { | 175 void ReportVersion(const base::Version& version) const { |
194 DCHECK(!version.components().empty()); | 176 DCHECK(!version.components().empty()); |
195 // The minor version is the 2nd last component of the version, | 177 // The minor version is the 2nd last component of the version, |
196 // or just the first component if there is only 1. | 178 // or just the first component if there is only 1. |
197 uint32_t minor_version = 0; | 179 uint32_t minor_version = 0; |
198 if (version.components().size() > 1) | 180 if (version.components().size() > 1) |
199 minor_version = version.components()[version.components().size() - 2]; | 181 minor_version = version.components()[version.components().size() - 2]; |
200 else | 182 else |
(...skipping 17 matching lines...) Expand all Loading... |
218 } | 200 } |
219 | 201 |
220 void ReportExitCode(int exit_code) const { | 202 void ReportExitCode(int exit_code) const { |
221 RecordSparseHistogram("SoftwareReporter.ExitCode", exit_code); | 203 RecordSparseHistogram("SoftwareReporter.ExitCode", exit_code); |
222 | 204 |
223 // Also report the exit code that the reporter writes to the registry. | 205 // Also report the exit code that the reporter writes to the registry. |
224 base::win::RegKey reporter_key; | 206 base::win::RegKey reporter_key; |
225 DWORD exit_code_in_registry; | 207 DWORD exit_code_in_registry; |
226 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 208 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
227 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || | 209 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || |
228 reporter_key.ReadValueDW(kExitCodeValueName, &exit_code_in_registry) != | 210 reporter_key.ReadValueDW(chrome_cleaner::kExitCodeValueName, |
229 ERROR_SUCCESS) { | 211 &exit_code_in_registry) != ERROR_SUCCESS) { |
230 return; | 212 return; |
231 } | 213 } |
232 | 214 |
233 RecordSparseHistogram(kExitCodeMetricName, exit_code_in_registry); | 215 RecordSparseHistogram(kExitCodeMetricName, exit_code_in_registry); |
234 reporter_key.DeleteValue(kExitCodeValueName); | 216 reporter_key.DeleteValue(chrome_cleaner::kExitCodeValueName); |
235 } | 217 } |
236 | 218 |
237 void ReportEngineErrorCode() const { | 219 void ReportEngineErrorCode() const { |
238 base::win::RegKey reporter_key; | 220 base::win::RegKey reporter_key; |
239 DWORD engine_error_code; | 221 DWORD engine_error_code; |
240 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 222 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
241 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || | 223 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || |
242 reporter_key.ReadValueDW(kEngineErrorCodeValueName, | 224 reporter_key.ReadValueDW(chrome_cleaner::kEngineErrorCodeValueName, |
243 &engine_error_code) != ERROR_SUCCESS) { | 225 &engine_error_code) != ERROR_SUCCESS) { |
244 return; | 226 return; |
245 } | 227 } |
246 | 228 |
247 RecordSparseHistogram(kEngineErrorCodeMetricName, engine_error_code); | 229 RecordSparseHistogram(kEngineErrorCodeMetricName, engine_error_code); |
248 reporter_key.DeleteValue(kEngineErrorCodeValueName); | 230 reporter_key.DeleteValue(chrome_cleaner::kEngineErrorCodeValueName); |
249 } | 231 } |
250 | 232 |
251 // Reports UwS found by the software reporter tool via UMA and RAPPOR. | 233 // Reports UwS found by the software reporter tool via UMA and RAPPOR. |
252 void ReportFoundUwS() const { | 234 void ReportFoundUwS() const { |
253 base::win::RegKey reporter_key; | 235 base::win::RegKey reporter_key; |
254 std::vector<base::string16> found_uws_strings; | 236 std::vector<base::string16> found_uws_strings; |
255 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 237 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
256 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || | 238 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || |
257 reporter_key.ReadValues(kFoundUwsValueName, &found_uws_strings) != | 239 reporter_key.ReadValues(chrome_cleaner::kFoundUwsValueName, |
258 ERROR_SUCCESS) { | 240 &found_uws_strings) != ERROR_SUCCESS) { |
259 return; | 241 return; |
260 } | 242 } |
261 | 243 |
262 bool parse_error = false; | 244 bool parse_error = false; |
263 for (const base::string16& uws_string : found_uws_strings) { | 245 for (const base::string16& uws_string : found_uws_strings) { |
264 // All UwS ids are expected to be integers. | 246 // All UwS ids are expected to be integers. |
265 uint32_t uws_id = 0; | 247 uint32_t uws_id = 0; |
266 if (base::StringToUint(uws_string, &uws_id)) { | 248 if (base::StringToUint(uws_string, &uws_id)) { |
267 RecordSparseHistogram(kFoundUwsMetricName, uws_id); | 249 RecordSparseHistogram(kFoundUwsMetricName, uws_id); |
268 } else { | 250 } else { |
269 parse_error = true; | 251 parse_error = true; |
270 } | 252 } |
271 } | 253 } |
272 | 254 |
273 // Clean up the old value. | 255 // Clean up the old value. |
274 reporter_key.DeleteValue(kFoundUwsValueName); | 256 reporter_key.DeleteValue(chrome_cleaner::kFoundUwsValueName); |
275 RecordBooleanHistogram(kFoundUwsReadErrorMetricName, parse_error); | 257 RecordBooleanHistogram(kFoundUwsReadErrorMetricName, parse_error); |
276 } | 258 } |
277 | 259 |
278 // Reports to UMA the memory usage of the software reporter tool as reported | 260 // Reports to UMA the memory usage of the software reporter tool as reported |
279 // by the tool itself in the Windows registry. | 261 // by the tool itself in the Windows registry. |
280 void ReportMemoryUsage() const { | 262 void ReportMemoryUsage() const { |
281 base::win::RegKey reporter_key; | 263 base::win::RegKey reporter_key; |
282 DWORD memory_used = 0; | 264 DWORD memory_used = 0; |
283 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 265 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
284 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || | 266 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || |
285 reporter_key.ReadValueDW(kMemoryUsedValueName, &memory_used) != | 267 reporter_key.ReadValueDW(chrome_cleaner::kMemoryUsedValueName, |
286 ERROR_SUCCESS) { | 268 &memory_used) != ERROR_SUCCESS) { |
287 return; | 269 return; |
288 } | 270 } |
289 RecordMemoryKBHistogram(kMemoryUsedMetricName, memory_used); | 271 RecordMemoryKBHistogram(kMemoryUsedMetricName, memory_used); |
290 reporter_key.DeleteValue(kMemoryUsedValueName); | 272 reporter_key.DeleteValue(chrome_cleaner::kMemoryUsedValueName); |
291 } | 273 } |
292 | 274 |
293 // Reports the SwReporter run time with UMA both as reported by the tool via | 275 // Reports the SwReporter run time with UMA both as reported by the tool via |
294 // the registry and as measured by |ReporterRunner|. | 276 // the registry and as measured by |ReporterRunner|. |
295 void ReportRuntime(const base::TimeDelta& reporter_running_time) const { | 277 void ReportRuntime(const base::TimeDelta& reporter_running_time) const { |
296 RecordLongTimesHistogram("SoftwareReporter.RunningTimeAccordingToChrome", | 278 RecordLongTimesHistogram("SoftwareReporter.RunningTimeAccordingToChrome", |
297 reporter_running_time); | 279 reporter_running_time); |
298 | 280 |
299 // TODO(b/641081): This should only have KEY_QUERY_VALUE and KEY_SET_VALUE. | 281 // TODO(b/641081): This should only have KEY_QUERY_VALUE and KEY_SET_VALUE. |
300 base::win::RegKey reporter_key; | 282 base::win::RegKey reporter_key; |
301 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 283 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
302 KEY_ALL_ACCESS) != ERROR_SUCCESS) { | 284 KEY_ALL_ACCESS) != ERROR_SUCCESS) { |
303 RecordEnumerationHistogram( | 285 RecordEnumerationHistogram( |
304 kRunningTimeErrorMetricName, | 286 kRunningTimeErrorMetricName, |
305 REPORTER_RUNNING_TIME_ERROR_REGISTRY_KEY_INVALID, | 287 REPORTER_RUNNING_TIME_ERROR_REGISTRY_KEY_INVALID, |
306 REPORTER_RUNNING_TIME_ERROR_MAX); | 288 REPORTER_RUNNING_TIME_ERROR_MAX); |
307 return; | 289 return; |
308 } | 290 } |
309 | 291 |
310 bool has_start_time = false; | 292 bool has_start_time = false; |
311 int64_t start_time_value = 0; | 293 int64_t start_time_value = 0; |
312 if (reporter_key.HasValue(kStartTimeValueName) && | 294 if (reporter_key.HasValue(chrome_cleaner::kStartTimeValueName) && |
313 reporter_key.ReadInt64(kStartTimeValueName, &start_time_value) == | 295 reporter_key.ReadInt64(chrome_cleaner::kStartTimeValueName, |
314 ERROR_SUCCESS) { | 296 &start_time_value) == ERROR_SUCCESS) { |
315 has_start_time = true; | 297 has_start_time = true; |
316 reporter_key.DeleteValue(kStartTimeValueName); | 298 reporter_key.DeleteValue(chrome_cleaner::kStartTimeValueName); |
317 } | 299 } |
318 | 300 |
319 bool has_end_time = false; | 301 bool has_end_time = false; |
320 int64_t end_time_value = 0; | 302 int64_t end_time_value = 0; |
321 if (reporter_key.HasValue(kEndTimeValueName) && | 303 if (reporter_key.HasValue(chrome_cleaner::kEndTimeValueName) && |
322 reporter_key.ReadInt64(kEndTimeValueName, &end_time_value) == | 304 reporter_key.ReadInt64(chrome_cleaner::kEndTimeValueName, |
323 ERROR_SUCCESS) { | 305 &end_time_value) == ERROR_SUCCESS) { |
324 has_end_time = true; | 306 has_end_time = true; |
325 reporter_key.DeleteValue(kEndTimeValueName); | 307 reporter_key.DeleteValue(chrome_cleaner::kEndTimeValueName); |
326 } | 308 } |
327 | 309 |
328 if (has_start_time && has_end_time) { | 310 if (has_start_time && has_end_time) { |
329 base::TimeDelta registry_run_time = | 311 base::TimeDelta registry_run_time = |
330 base::Time::FromInternalValue(end_time_value) - | 312 base::Time::FromInternalValue(end_time_value) - |
331 base::Time::FromInternalValue(start_time_value); | 313 base::Time::FromInternalValue(start_time_value); |
332 RecordLongTimesHistogram("SoftwareReporter.RunningTime", | 314 RecordLongTimesHistogram("SoftwareReporter.RunningTime", |
333 registry_run_time); | 315 registry_run_time); |
334 RecordEnumerationHistogram(kRunningTimeErrorMetricName, | 316 RecordEnumerationHistogram(kRunningTimeErrorMetricName, |
335 REPORTER_RUNNING_TIME_ERROR_NO_ERROR, | 317 REPORTER_RUNNING_TIME_ERROR_NO_ERROR, |
(...skipping 10 matching lines...) Expand all Loading... |
346 DCHECK(!has_end_time); | 328 DCHECK(!has_end_time); |
347 RecordEnumerationHistogram(kRunningTimeErrorMetricName, | 329 RecordEnumerationHistogram(kRunningTimeErrorMetricName, |
348 REPORTER_RUNNING_TIME_ERROR_MISSING_END_TIME, | 330 REPORTER_RUNNING_TIME_ERROR_MISSING_END_TIME, |
349 REPORTER_RUNNING_TIME_ERROR_MAX); | 331 REPORTER_RUNNING_TIME_ERROR_MAX); |
350 } | 332 } |
351 } | 333 } |
352 | 334 |
353 // Reports the UwS scan times of the software reporter tool via UMA. | 335 // Reports the UwS scan times of the software reporter tool via UMA. |
354 void ReportScanTimes() const { | 336 void ReportScanTimes() const { |
355 base::string16 scan_times_key_path = base::StringPrintf( | 337 base::string16 scan_times_key_path = base::StringPrintf( |
356 L"%ls\\%ls", registry_key_.c_str(), kScanTimesSubKey); | 338 L"%ls\\%ls", registry_key_.c_str(), chrome_cleaner::kScanTimesSubKey); |
357 // TODO(b/641081): This should only have KEY_QUERY_VALUE and KEY_SET_VALUE. | 339 // TODO(b/641081): This should only have KEY_QUERY_VALUE and KEY_SET_VALUE. |
358 base::win::RegKey scan_times_key; | 340 base::win::RegKey scan_times_key; |
359 if (scan_times_key.Open(HKEY_CURRENT_USER, scan_times_key_path.c_str(), | 341 if (scan_times_key.Open(HKEY_CURRENT_USER, scan_times_key_path.c_str(), |
360 KEY_ALL_ACCESS) != ERROR_SUCCESS) { | 342 KEY_ALL_ACCESS) != ERROR_SUCCESS) { |
361 return; | 343 return; |
362 } | 344 } |
363 | 345 |
364 base::string16 value_name; | 346 base::string16 value_name; |
365 int uws_id = 0; | 347 int uws_id = 0; |
366 int64_t raw_scan_time = 0; | 348 int64_t raw_scan_time = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
378 RecordSparseHistogramCount(kScanTimesMetricName, uws_id, | 360 RecordSparseHistogramCount(kScanTimesMetricName, uws_id, |
379 scan_time.InSeconds() + 1); | 361 scan_time.InSeconds() + 1); |
380 } | 362 } |
381 } | 363 } |
382 // Clean up by deleting the scan times key, which is a subkey of the main | 364 // Clean up by deleting the scan times key, which is a subkey of the main |
383 // reporter key. | 365 // reporter key. |
384 scan_times_key.Close(); | 366 scan_times_key.Close(); |
385 base::win::RegKey reporter_key; | 367 base::win::RegKey reporter_key; |
386 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 368 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
387 KEY_ENUMERATE_SUB_KEYS) == ERROR_SUCCESS) { | 369 KEY_ENUMERATE_SUB_KEYS) == ERROR_SUCCESS) { |
388 reporter_key.DeleteKey(kScanTimesSubKey); | 370 reporter_key.DeleteKey(chrome_cleaner::kScanTimesSubKey); |
389 } | 371 } |
390 } | 372 } |
391 | 373 |
392 void RecordReporterStep(SwReporterUmaValue value) { | 374 void RecordReporterStep(SwReporterUmaValue value) { |
393 RecordEnumerationHistogram(kStepMetricName, value, SW_REPORTER_MAX); | 375 RecordEnumerationHistogram(kStepMetricName, value, SW_REPORTER_MAX); |
394 } | 376 } |
395 | 377 |
396 void RecordLogsUploadEnabled(SwReporterLogsUploadsEnabled value) { | 378 void RecordLogsUploadEnabled(SwReporterLogsUploadsEnabled value) { |
397 RecordEnumerationHistogram(kLogsUploadEnabledMetricName, value, | 379 RecordEnumerationHistogram(kLogsUploadEnabledMetricName, value, |
398 REPORTER_LOGS_UPLOADS_MAX); | 380 REPORTER_LOGS_UPLOADS_MAX); |
399 } | 381 } |
400 | 382 |
401 void RecordLogsUploadResult() { | 383 void RecordLogsUploadResult() { |
402 base::win::RegKey reporter_key; | 384 base::win::RegKey reporter_key; |
403 DWORD logs_upload_result = 0; | 385 DWORD logs_upload_result = 0; |
404 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 386 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
405 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS) { | 387 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS) { |
406 RecordEnumerationHistogram( | 388 RecordEnumerationHistogram( |
407 kLogsUploadResultRegistryErrorMetricName, | 389 kLogsUploadResultRegistryErrorMetricName, |
408 REPORTER_LOGS_UPLOAD_RESULT_ERROR_REGISTRY_KEY_INVALID, | 390 REPORTER_LOGS_UPLOAD_RESULT_ERROR_REGISTRY_KEY_INVALID, |
409 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); | 391 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); |
410 return; | 392 return; |
411 } | 393 } |
412 | 394 |
413 if (reporter_key.ReadValueDW(kLogsUploadResultValueName, | 395 if (reporter_key.ReadValueDW(chrome_cleaner::kLogsUploadResultValueName, |
414 &logs_upload_result) != ERROR_SUCCESS) { | 396 &logs_upload_result) != ERROR_SUCCESS) { |
415 RecordEnumerationHistogram( | 397 RecordEnumerationHistogram( |
416 kLogsUploadResultRegistryErrorMetricName, | 398 kLogsUploadResultRegistryErrorMetricName, |
417 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_NOT_FOUND, | 399 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_NOT_FOUND, |
418 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); | 400 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); |
419 return; | 401 return; |
420 } | 402 } |
421 | 403 |
422 if (logs_upload_result >= kSwReporterLogsUploadResultMax) { | 404 if (logs_upload_result >= kSwReporterLogsUploadResultMax) { |
423 RecordEnumerationHistogram( | 405 RecordEnumerationHistogram( |
424 kLogsUploadResultRegistryErrorMetricName, | 406 kLogsUploadResultRegistryErrorMetricName, |
425 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_OUT_OF_BOUNDS, | 407 REPORTER_LOGS_UPLOAD_RESULT_ERROR_VALUE_OUT_OF_BOUNDS, |
426 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); | 408 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); |
427 return; | 409 return; |
428 } | 410 } |
429 | 411 |
430 RecordEnumerationHistogram(kLogsUploadResultMetricName, | 412 RecordEnumerationHistogram(kLogsUploadResultMetricName, |
431 static_cast<Sample>(logs_upload_result), | 413 static_cast<Sample>(logs_upload_result), |
432 kSwReporterLogsUploadResultMax); | 414 kSwReporterLogsUploadResultMax); |
433 reporter_key.DeleteValue(kLogsUploadResultValueName); | 415 reporter_key.DeleteValue(chrome_cleaner::kLogsUploadResultValueName); |
434 RecordEnumerationHistogram(kLogsUploadResultRegistryErrorMetricName, | 416 RecordEnumerationHistogram(kLogsUploadResultRegistryErrorMetricName, |
435 REPORTER_LOGS_UPLOAD_RESULT_ERROR_NO_ERROR, | 417 REPORTER_LOGS_UPLOAD_RESULT_ERROR_NO_ERROR, |
436 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); | 418 REPORTER_LOGS_UPLOAD_RESULT_ERROR_MAX); |
437 } | 419 } |
438 | 420 |
439 private: | 421 private: |
440 using Sample = base::HistogramBase::Sample; | 422 using Sample = base::HistogramBase::Sample; |
441 | 423 |
442 static constexpr base::HistogramBase::Flags kUmaHistogramFlag = | 424 static constexpr base::HistogramBase::Flags kUmaHistogramFlag = |
443 base::HistogramBase::kUmaTargetedHistogramFlag; | 425 base::HistogramBase::kUmaTargetedHistogramFlag; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 } | 641 } |
660 } | 642 } |
661 | 643 |
662 base::Process SwReporterProcess::LaunchConnectedReporterProcess() { | 644 base::Process SwReporterProcess::LaunchConnectedReporterProcess() { |
663 DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)); | 645 DCHECK(base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)); |
664 | 646 |
665 mojo::edk::PendingProcessConnection pending_process_connection; | 647 mojo::edk::PendingProcessConnection pending_process_connection; |
666 std::string mojo_pipe_token; | 648 std::string mojo_pipe_token; |
667 mojo::ScopedMessagePipeHandle mojo_pipe = | 649 mojo::ScopedMessagePipeHandle mojo_pipe = |
668 pending_process_connection.CreateMessagePipe(&mojo_pipe_token); | 650 pending_process_connection.CreateMessagePipe(&mojo_pipe_token); |
669 invocation_.command_line.AppendSwitchASCII(kChromeMojoPipeTokenSwitch, | 651 invocation_.command_line.AppendSwitchASCII( |
670 mojo_pipe_token); | 652 chrome_cleaner::kChromeMojoPipeTokenSwitch, mojo_pipe_token); |
671 | 653 |
672 mojo::edk::PlatformChannelPair channel; | 654 mojo::edk::PlatformChannelPair channel; |
673 base::HandlesToInheritVector handles_to_inherit; | 655 base::HandlesToInheritVector handles_to_inherit; |
674 channel.PrepareToPassClientHandleToChildProcess(&invocation_.command_line, | 656 channel.PrepareToPassClientHandleToChildProcess(&invocation_.command_line, |
675 &handles_to_inherit); | 657 &handles_to_inherit); |
676 | 658 |
677 base::LaunchOptions launch_options; | 659 base::LaunchOptions launch_options; |
678 launch_options.handles_to_inherit = &handles_to_inherit; | 660 launch_options.handles_to_inherit = &handles_to_inherit; |
679 base::Process reporter_process = | 661 base::Process reporter_process = |
680 LaunchReporterProcess(invocation_, launch_options); | 662 LaunchReporterProcess(invocation_, launch_options); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 return; | 980 return; |
999 } | 981 } |
1000 | 982 |
1001 if (!IsInSRTPromptFieldTrialGroups()) { | 983 if (!IsInSRTPromptFieldTrialGroups()) { |
1002 // Knowing about disabled field trial is more important than reporter not | 984 // Knowing about disabled field trial is more important than reporter not |
1003 // finding anything to remove, so check this case first. | 985 // finding anything to remove, so check this case first. |
1004 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_FIELD_TRIAL); | 986 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_FIELD_TRIAL); |
1005 return; | 987 return; |
1006 } | 988 } |
1007 | 989 |
1008 if (exit_code != kSwReporterPostRebootCleanupNeeded && | 990 if (exit_code != chrome_cleaner::kSwReporterPostRebootCleanupNeeded && |
1009 exit_code != kSwReporterCleanupNeeded) { | 991 exit_code != chrome_cleaner::kSwReporterCleanupNeeded) { |
1010 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); | 992 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); |
1011 return; | 993 return; |
1012 } | 994 } |
1013 | 995 |
1014 // Find the last active browser, which may be NULL, in which case we need | 996 // Find the last active browser, which may be NULL, in which case we need |
1015 // to wait for one to be available. We can't use other ways of finding a | 997 // to wait for one to be available. We can't use other ways of finding a |
1016 // browser because we don't have a profile. And we need a browser to get to | 998 // browser because we don't have a profile. And we need a browser to get to |
1017 // a profile, which we need, to tell whether we should prompt or not. | 999 // a profile, which we need, to tell whether we should prompt or not. |
1018 // TODO(mad): crbug.com/503269, investigate whether we should change how we | 1000 // TODO(mad): crbug.com/503269, investigate whether we should change how we |
1019 // decide when it's time to download the SRT and when to display the prompt. | 1001 // decide when it's time to download the SRT and when to display the prompt. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 // Set the local state value before the first attempt to run the | 1102 // Set the local state value before the first attempt to run the |
1121 // reporter, because we only want to upload logs once in the window | 1103 // reporter, because we only want to upload logs once in the window |
1122 // defined by |kDaysBetweenReporterLogsSent|. If we set with other local | 1104 // defined by |kDaysBetweenReporterLogsSent|. If we set with other local |
1123 // state values after the reporter runs, we could send logs again too | 1105 // state values after the reporter runs, we could send logs again too |
1124 // quickly (for example, if Chrome stops before the reporter finishes). | 1106 // quickly (for example, if Chrome stops before the reporter finishes). |
1125 local_state->SetInt64(prefs::kSwReporterLastTimeSentReport, | 1107 local_state->SetInt64(prefs::kSwReporterLastTimeSentReport, |
1126 Now().ToInternalValue()); | 1108 Now().ToInternalValue()); |
1127 } | 1109 } |
1128 | 1110 |
1129 if (ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()) | 1111 if (ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()) |
1130 next_invocation->command_line.AppendSwitch(kEnableCrashReporting); | 1112 next_invocation->command_line.AppendSwitch( |
| 1113 chrome_cleaner::kEnableCrashReporting); |
1131 } | 1114 } |
1132 | 1115 |
1133 // Adds switches to be sent to the Software Reporter when the user opted into | 1116 // Adds switches to be sent to the Software Reporter when the user opted into |
1134 // extended Safe Browsing reporting and is not incognito. | 1117 // extended Safe Browsing reporting and is not incognito. |
1135 void AddSwitchesForExtendedReportingUser(SwReporterInvocation* invocation) { | 1118 void AddSwitchesForExtendedReportingUser(SwReporterInvocation* invocation) { |
1136 invocation->command_line.AppendSwitch(kExtendedSafeBrowsingEnabledSwitch); | 1119 invocation->command_line.AppendSwitch( |
| 1120 chrome_cleaner::kExtendedSafeBrowsingEnabledSwitch); |
1137 invocation->command_line.AppendSwitchASCII( | 1121 invocation->command_line.AppendSwitchASCII( |
1138 kChromeVersionSwitch, version_info::GetVersionNumber()); | 1122 chrome_cleaner::kChromeVersionSwitch, version_info::GetVersionNumber()); |
1139 invocation->command_line.AppendSwitchNative( | 1123 invocation->command_line.AppendSwitchNative( |
1140 kChromeChannelSwitch, base::IntToString16(ChannelAsInt())); | 1124 chrome_cleaner::kChromeChannelSwitch, |
| 1125 base::IntToString16(ChannelAsInt())); |
1141 } | 1126 } |
1142 | 1127 |
1143 bool first_run_ = true; | 1128 bool first_run_ = true; |
1144 | 1129 |
1145 // The queue of invocations that are currently running. | 1130 // The queue of invocations that are currently running. |
1146 SwReporterQueue current_invocations_; | 1131 SwReporterQueue current_invocations_; |
1147 | 1132 |
1148 // The invocations to run next time the SwReporter is run. | 1133 // The invocations to run next time the SwReporter is run. |
1149 SwReporterQueue pending_invocations_; | 1134 SwReporterQueue pending_invocations_; |
1150 | 1135 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 DCHECK(!invocations.empty()); | 1198 DCHECK(!invocations.empty()); |
1214 DCHECK(version.IsValid()); | 1199 DCHECK(version.IsValid()); |
1215 ReporterRunner::ScheduleInvocations(invocations, version); | 1200 ReporterRunner::ScheduleInvocations(invocations, version); |
1216 } | 1201 } |
1217 | 1202 |
1218 bool ReporterFoundUws() { | 1203 bool ReporterFoundUws() { |
1219 PrefService* local_state = g_browser_process->local_state(); | 1204 PrefService* local_state = g_browser_process->local_state(); |
1220 if (!local_state) | 1205 if (!local_state) |
1221 return false; | 1206 return false; |
1222 int exit_code = local_state->GetInteger(prefs::kSwReporterLastExitCode); | 1207 int exit_code = local_state->GetInteger(prefs::kSwReporterLastExitCode); |
1223 return exit_code == kSwReporterCleanupNeeded; | 1208 return exit_code == chrome_cleaner::kSwReporterCleanupNeeded; |
1224 } | 1209 } |
1225 | 1210 |
1226 bool UserHasRunCleaner() { | 1211 bool UserHasRunCleaner() { |
1227 base::string16 cleaner_key_path(kSoftwareRemovalToolRegistryKey); | 1212 base::string16 cleaner_key_path( |
1228 cleaner_key_path.append(L"\\").append(kCleanerSubKey); | 1213 chrome_cleaner::kSoftwareRemovalToolRegistryKey); |
| 1214 cleaner_key_path.append(L"\\").append( |
| 1215 chrome_cleaner::kCleanerSuffixRegistryKey); |
1229 | 1216 |
1230 base::win::RegKey srt_cleaner_key; | 1217 base::win::RegKey srt_cleaner_key; |
1231 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), | 1218 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), |
1232 KEY_QUERY_VALUE) == ERROR_SUCCESS && | 1219 KEY_QUERY_VALUE) == ERROR_SUCCESS && |
1233 srt_cleaner_key.GetValueCount() > 0; | 1220 srt_cleaner_key.GetValueCount() > 0; |
1234 } | 1221 } |
1235 | 1222 |
1236 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { | 1223 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { |
1237 g_testing_delegate_ = delegate; | 1224 g_testing_delegate_ = delegate; |
1238 } | 1225 } |
1239 | 1226 |
1240 } // namespace safe_browsing | 1227 } // namespace safe_browsing |
OLD | NEW |