OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <limits> | 11 #include <limits> |
12 #include <map> | 12 #include <map> |
13 #include <set> | 13 #include <set> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/containers/adapters.h" | 19 #include "base/containers/adapters.h" |
20 #include "base/feature_list.h" | 20 #include "base/feature_list.h" |
21 #include "base/files/file_util.h" | 21 #include "base/files/file_util.h" |
22 #include "base/guid.h" | 22 #include "base/guid.h" |
23 #include "base/logging.h" | 23 #include "base/logging.h" |
24 #include "base/memory/ptr_util.h" | 24 #include "base/memory/ptr_util.h" |
25 #include "base/message_loop/message_loop.h" | 25 #include "base/message_loop/message_loop.h" |
| 26 #include "base/metrics/histogram_macros.h" |
26 #include "base/path_service.h" | 27 #include "base/path_service.h" |
27 #include "base/strings/string16.h" | 28 #include "base/strings/string16.h" |
28 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
29 #include "base/strings/string_piece.h" | 30 #include "base/strings/string_piece.h" |
30 #include "base/strings/string_split.h" | 31 #include "base/strings/string_split.h" |
31 #include "base/strings/string_util.h" | 32 #include "base/strings/string_util.h" |
32 #include "base/strings/utf_string_conversions.h" | 33 #include "base/strings/utf_string_conversions.h" |
33 #include "base/threading/sequenced_worker_pool.h" | 34 #include "base/threading/sequenced_worker_pool.h" |
34 #include "base/threading/thread_restrictions.h" | 35 #include "base/threading/thread_restrictions.h" |
35 #include "build/build_config.h" | 36 #include "build/build_config.h" |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 | 1292 |
1292 int AutofillManager::GetProfilesForCreditCardUpload( | 1293 int AutofillManager::GetProfilesForCreditCardUpload( |
1293 const CreditCard& card, | 1294 const CreditCard& card, |
1294 std::vector<AutofillProfile>* profiles, | 1295 std::vector<AutofillProfile>* profiles, |
1295 std::string* rappor_metric_name) const { | 1296 std::string* rappor_metric_name) const { |
1296 std::vector<AutofillProfile> candidate_profiles; | 1297 std::vector<AutofillProfile> candidate_profiles; |
1297 const base::Time now = AutofillClock::Now(); | 1298 const base::Time now = AutofillClock::Now(); |
1298 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); | 1299 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); |
1299 int upload_decision_metrics = 0; | 1300 int upload_decision_metrics = 0; |
1300 bool has_profile = false; | 1301 bool has_profile = false; |
| 1302 bool has_modified_profile = false; |
1301 | 1303 |
1302 // First, collect all of the addresses used recently. | 1304 // First, collect all of the addresses used recently. |
1303 for (AutofillProfile* profile : personal_data_->GetProfiles()) { | 1305 for (AutofillProfile* profile : personal_data_->GetProfiles()) { |
1304 has_profile = true; | 1306 has_profile = true; |
1305 if ((now - profile->use_date()) < fifteen_minutes || | 1307 if ((now - profile->modification_date()) < fifteen_minutes) { |
1306 (now - profile->modification_date()) < fifteen_minutes) { | 1308 has_modified_profile = true; |
| 1309 candidate_profiles.push_back(*profile); |
| 1310 } else if ((now - profile->use_date()) < fifteen_minutes) { |
1307 candidate_profiles.push_back(*profile); | 1311 candidate_profiles.push_back(*profile); |
1308 } | 1312 } |
1309 } | 1313 } |
| 1314 |
1310 if (candidate_profiles.empty()) { | 1315 if (candidate_profiles.empty()) { |
1311 upload_decision_metrics |= | 1316 upload_decision_metrics |= |
1312 has_profile | 1317 has_profile |
1313 ? AutofillMetrics::UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS | 1318 ? AutofillMetrics::UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS |
1314 : AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS_PROFILE; | 1319 : AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS_PROFILE; |
1315 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; | 1320 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; |
1316 } | 1321 } |
1317 | 1322 |
1318 // If any of the names on the card or the addresses don't match the | 1323 // If any of the names on the card or the addresses don't match the |
1319 // candidate set is invalid. This matches the rules for name matching applied | 1324 // candidate set is invalid. This matches the rules for name matching applied |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 } | 1387 } |
1383 } | 1388 } |
1384 } | 1389 } |
1385 } | 1390 } |
1386 | 1391 |
1387 // If none of the candidate addresses have a zip, the candidate set is | 1392 // If none of the candidate addresses have a zip, the candidate set is |
1388 // invalid. | 1393 // invalid. |
1389 if (verified_zip.empty() && !candidate_profiles.empty()) | 1394 if (verified_zip.empty() && !candidate_profiles.empty()) |
1390 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; | 1395 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; |
1391 | 1396 |
1392 if (!upload_decision_metrics) | 1397 if (!upload_decision_metrics) { |
1393 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); | 1398 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); |
1394 | 1399 if (!has_modified_profile) |
| 1400 for (const AutofillProfile& profile : candidate_profiles) |
| 1401 UMA_HISTOGRAM_COUNTS_1000( |
| 1402 "Autofill.DaysSincePreviousUseAtSubmission.Profile", |
| 1403 (profile.use_date() - profile.previous_use_date()).InDays()); |
| 1404 } |
1395 return upload_decision_metrics; | 1405 return upload_decision_metrics; |
1396 } | 1406 } |
1397 | 1407 |
1398 void AutofillManager::CollectRapporSample( | 1408 void AutofillManager::CollectRapporSample( |
1399 const GURL& source_url, | 1409 const GURL& source_url, |
1400 const std::string& metric_name) const { | 1410 const std::string& metric_name) const { |
1401 if (source_url.is_valid() && client_->GetRapporServiceImpl()) { | 1411 if (source_url.is_valid() && client_->GetRapporServiceImpl()) { |
1402 rappor::SampleDomainAndRegistryFromGURL(client_->GetRapporServiceImpl(), | 1412 rappor::SampleDomainAndRegistryFromGURL(client_->GetRapporServiceImpl(), |
1403 metric_name, source_url); | 1413 metric_name, source_url); |
1404 } | 1414 } |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 #endif // ENABLE_FORM_DEBUG_DUMP | 2260 #endif // ENABLE_FORM_DEBUG_DUMP |
2251 | 2261 |
2252 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { | 2262 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { |
2253 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); | 2263 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); |
2254 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), | 2264 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), |
2255 pending_upload_request_url_, | 2265 pending_upload_request_url_, |
2256 upload_decision_metrics); | 2266 upload_decision_metrics); |
2257 } | 2267 } |
2258 | 2268 |
2259 } // namespace autofill | 2269 } // namespace autofill |
OLD | NEW |