| 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 29 matching lines...) Expand all Loading... |
| 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/component_updater/pref_names.h" | 47 #include "components/component_updater/pref_names.h" |
| 48 #include "components/data_use_measurement/core/data_use_user_data.h" | 48 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 49 #include "components/prefs/pref_service.h" | 49 #include "components/prefs/pref_service.h" |
| 50 #include "components/rappor/rappor_service_impl.h" | |
| 51 #include "components/variations/net/variations_http_headers.h" | 50 #include "components/variations/net/variations_http_headers.h" |
| 52 #include "components/version_info/version_info.h" | 51 #include "components/version_info/version_info.h" |
| 53 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 54 #include "net/base/load_flags.h" | 53 #include "net/base/load_flags.h" |
| 55 #include "net/http/http_status_code.h" | 54 #include "net/http/http_status_code.h" |
| 56 #include "net/url_request/url_fetcher.h" | 55 #include "net/url_request/url_fetcher.h" |
| 57 #include "net/url_request/url_fetcher_delegate.h" | 56 #include "net/url_request/url_fetcher_delegate.h" |
| 58 #include "net/url_request/url_request_context_getter.h" | 57 #include "net/url_request/url_request_context_getter.h" |
| 59 | 58 |
| 60 using content::BrowserThread; | 59 using content::BrowserThread; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 reporter_key.ReadValueDW(kEngineErrorCodeValueName, | 232 reporter_key.ReadValueDW(kEngineErrorCodeValueName, |
| 234 &engine_error_code) != ERROR_SUCCESS) { | 233 &engine_error_code) != ERROR_SUCCESS) { |
| 235 return; | 234 return; |
| 236 } | 235 } |
| 237 | 236 |
| 238 RecordSparseHistogram(kEngineErrorCodeMetricName, engine_error_code); | 237 RecordSparseHistogram(kEngineErrorCodeMetricName, engine_error_code); |
| 239 reporter_key.DeleteValue(kEngineErrorCodeValueName); | 238 reporter_key.DeleteValue(kEngineErrorCodeValueName); |
| 240 } | 239 } |
| 241 | 240 |
| 242 // Reports UwS found by the software reporter tool via UMA and RAPPOR. | 241 // Reports UwS found by the software reporter tool via UMA and RAPPOR. |
| 243 void ReportFoundUwS(bool use_rappor) const { | 242 void ReportFoundUwS() const { |
| 244 base::win::RegKey reporter_key; | 243 base::win::RegKey reporter_key; |
| 245 std::vector<base::string16> found_uws_strings; | 244 std::vector<base::string16> found_uws_strings; |
| 246 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), | 245 if (reporter_key.Open(HKEY_CURRENT_USER, registry_key_.c_str(), |
| 247 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || | 246 KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS || |
| 248 reporter_key.ReadValues(kFoundUwsValueName, &found_uws_strings) != | 247 reporter_key.ReadValues(kFoundUwsValueName, &found_uws_strings) != |
| 249 ERROR_SUCCESS) { | 248 ERROR_SUCCESS) { |
| 250 return; | 249 return; |
| 251 } | 250 } |
| 252 | 251 |
| 253 rappor::RapporServiceImpl* rappor_service = nullptr; | |
| 254 if (use_rappor) | |
| 255 rappor_service = g_browser_process->rappor_service(); | |
| 256 | |
| 257 bool parse_error = false; | 252 bool parse_error = false; |
| 258 for (const base::string16& uws_string : found_uws_strings) { | 253 for (const base::string16& uws_string : found_uws_strings) { |
| 259 // All UwS ids are expected to be integers. | 254 // All UwS ids are expected to be integers. |
| 260 uint32_t uws_id = 0; | 255 uint32_t uws_id = 0; |
| 261 if (base::StringToUint(uws_string, &uws_id)) { | 256 if (base::StringToUint(uws_string, &uws_id)) { |
| 262 RecordSparseHistogram(kFoundUwsMetricName, uws_id); | 257 RecordSparseHistogram(kFoundUwsMetricName, uws_id); |
| 263 if (rappor_service) { | |
| 264 rappor_service->RecordSampleString(kFoundUwsMetricName, | |
| 265 rappor::COARSE_RAPPOR_TYPE, | |
| 266 base::UTF16ToUTF8(uws_string)); | |
| 267 } | |
| 268 } else { | 258 } else { |
| 269 parse_error = true; | 259 parse_error = true; |
| 270 } | 260 } |
| 271 } | 261 } |
| 272 | 262 |
| 273 // Clean up the old value. | 263 // Clean up the old value. |
| 274 reporter_key.DeleteValue(kFoundUwsValueName); | 264 reporter_key.DeleteValue(kFoundUwsValueName); |
| 275 RecordBooleanHistogram(kFoundUwsReadErrorMetricName, parse_error); | 265 RecordBooleanHistogram(kFoundUwsReadErrorMetricName, parse_error); |
| 276 } | 266 } |
| 277 | 267 |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 // If the reporter failed to launch, do not process the results. (The exit | 806 // If the reporter failed to launch, do not process the results. (The exit |
| 817 // code itself doesn't need to be logged in this case because | 807 // code itself doesn't need to be logged in this case because |
| 818 // SW_REPORTER_FAILED_TO_START is logged in |LaunchAndWaitForExit|.) | 808 // SW_REPORTER_FAILED_TO_START is logged in |LaunchAndWaitForExit|.) |
| 819 if (exit_code == kReporterFailureExitCode) | 809 if (exit_code == kReporterFailureExitCode) |
| 820 return; | 810 return; |
| 821 | 811 |
| 822 UMAHistogramReporter uma(finished_invocation.suffix); | 812 UMAHistogramReporter uma(finished_invocation.suffix); |
| 823 uma.ReportVersion(version); | 813 uma.ReportVersion(version); |
| 824 uma.ReportExitCode(exit_code); | 814 uma.ReportExitCode(exit_code); |
| 825 uma.ReportEngineErrorCode(); | 815 uma.ReportEngineErrorCode(); |
| 826 uma.ReportFoundUwS(finished_invocation.BehaviourIsSupported( | 816 uma.ReportFoundUwS(); |
| 827 SwReporterInvocation::BEHAVIOUR_LOG_TO_RAPPOR)); | |
| 828 | 817 |
| 829 PrefService* local_state = g_browser_process->local_state(); | 818 PrefService* local_state = g_browser_process->local_state(); |
| 830 if (local_state) { | 819 if (local_state) { |
| 831 if (finished_invocation.BehaviourIsSupported( | 820 if (finished_invocation.BehaviourIsSupported( |
| 832 SwReporterInvocation::BEHAVIOUR_LOG_EXIT_CODE_TO_PREFS)) { | 821 SwReporterInvocation::BEHAVIOUR_LOG_EXIT_CODE_TO_PREFS)) { |
| 833 local_state->SetInteger(prefs::kSwReporterLastExitCode, exit_code); | 822 local_state->SetInteger(prefs::kSwReporterLastExitCode, exit_code); |
| 834 } | 823 } |
| 835 local_state->SetInt64(prefs::kSwReporterLastTimeTriggered, | 824 local_state->SetInt64(prefs::kSwReporterLastTimeTriggered, |
| 836 now.ToInternalValue()); | 825 now.ToInternalValue()); |
| 837 } | 826 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), | 1068 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), |
| 1080 KEY_QUERY_VALUE) == ERROR_SUCCESS && | 1069 KEY_QUERY_VALUE) == ERROR_SUCCESS && |
| 1081 srt_cleaner_key.GetValueCount() > 0; | 1070 srt_cleaner_key.GetValueCount() > 0; |
| 1082 } | 1071 } |
| 1083 | 1072 |
| 1084 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { | 1073 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { |
| 1085 g_testing_delegate_ = delegate; | 1074 g_testing_delegate_ = delegate; |
| 1086 } | 1075 } |
| 1087 | 1076 |
| 1088 } // namespace safe_browsing | 1077 } // namespace safe_browsing |
| OLD | NEW |