Chromium Code Reviews| 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 "components/autofill/browser/autofill_manager.h" | 5 #include "components/autofill/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 | 333 |
| 334 submitted_form->UpdateFromCache(*cached_submitted_form); | 334 submitted_form->UpdateFromCache(*cached_submitted_form); |
| 335 // Don't prompt the user to save data entered by Autocheckout. | 335 // Don't prompt the user to save data entered by Autocheckout. |
| 336 if (submitted_form->IsAutofillable(true) && | 336 if (submitted_form->IsAutofillable(true) && |
| 337 !submitted_form->filled_by_autocheckout()) | 337 !submitted_form->filled_by_autocheckout()) |
| 338 ImportFormData(*submitted_form); | 338 ImportFormData(*submitted_form); |
| 339 | 339 |
| 340 // Only upload server statistics and UMA metrics if at least some local data | 340 // Only upload server statistics and UMA metrics if at least some local data |
| 341 // is available to use as a baseline. | 341 // is available to use as a baseline. |
| 342 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); | 342 const std::vector<AutofillProfile*>& profiles = personal_data_->GetProfiles(); |
| 343 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); | 343 const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); |
|
Ilya Sherman
2013/04/30 08:20:29
nit: Please preserve this variable name.
Dan Beam
2013/05/01 03:46:44
Done.
| |
| 344 if (!profiles.empty() || !credit_cards.empty()) { | 344 if (!profiles.empty() || !cards.empty()) { |
| 345 // Copy the profile and credit card data, so that it can be accessed on a | 345 // Copy the profile and credit card data, so that it can be accessed on a |
| 346 // separate thread. | 346 // separate thread. |
| 347 std::vector<AutofillProfile> copied_profiles; | 347 std::vector<AutofillProfile> copied_profiles; |
| 348 copied_profiles.reserve(profiles.size()); | 348 copied_profiles.reserve(profiles.size()); |
| 349 for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin(); | 349 for (std::vector<AutofillProfile*>::const_iterator it = profiles.begin(); |
| 350 it != profiles.end(); ++it) { | 350 it != profiles.end(); ++it) { |
| 351 copied_profiles.push_back(**it); | 351 copied_profiles.push_back(**it); |
| 352 } | 352 } |
| 353 | 353 |
| 354 std::vector<CreditCard> copied_credit_cards; | 354 std::vector<CreditCard> copied_cards; |
| 355 copied_credit_cards.reserve(credit_cards.size()); | 355 copied_cards.reserve(cards.size()); |
| 356 for (std::vector<CreditCard*>::const_iterator it = credit_cards.begin(); | 356 for (std::vector<CreditCard*>::const_iterator it = cards.begin(); |
| 357 it != credit_cards.end(); ++it) { | 357 it != cards.end(); ++it) { |
| 358 copied_credit_cards.push_back(**it); | 358 copied_cards.push_back(**it); |
| 359 } | 359 } |
| 360 | 360 |
| 361 // Note that ownership of |submitted_form| is passed to the second task, | 361 // Note that ownership of |submitted_form| is passed to the second task, |
| 362 // using |base::Owned|. | 362 // using |base::Owned|. |
| 363 FormStructure* raw_submitted_form = submitted_form.get(); | 363 FormStructure* raw_submitted_form = submitted_form.get(); |
| 364 BrowserThread::GetBlockingPool()->PostTaskAndReply( | 364 BrowserThread::GetBlockingPool()->PostTaskAndReply( |
| 365 FROM_HERE, | 365 FROM_HERE, |
| 366 base::Bind(&DeterminePossibleFieldTypesForUpload, | 366 base::Bind(&DeterminePossibleFieldTypesForUpload, |
| 367 copied_profiles, | 367 copied_profiles, |
| 368 copied_credit_cards, | 368 copied_cards, |
| 369 app_locale_, | 369 app_locale_, |
| 370 raw_submitted_form), | 370 raw_submitted_form), |
| 371 base::Bind(&AutofillManager::UploadFormDataAsyncCallback, | 371 base::Bind(&AutofillManager::UploadFormDataAsyncCallback, |
| 372 weak_ptr_factory_.GetWeakPtr(), | 372 weak_ptr_factory_.GetWeakPtr(), |
| 373 base::Owned(submitted_form.release()), | 373 base::Owned(submitted_form.release()), |
| 374 forms_loaded_timestamp_, | 374 forms_loaded_timestamp_, |
| 375 initial_interaction_timestamp_, | 375 initial_interaction_timestamp_, |
| 376 timestamp)); | 376 timestamp)); |
| 377 } | 377 } |
| 378 | 378 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { | 963 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { |
| 964 metric_logger_.reset(metric_logger); | 964 metric_logger_.reset(metric_logger); |
| 965 } | 965 } |
| 966 | 966 |
| 967 bool AutofillManager::GetHost(RenderViewHost** host) const { | 967 bool AutofillManager::GetHost(RenderViewHost** host) const { |
| 968 if (!IsAutofillEnabled()) | 968 if (!IsAutofillEnabled()) |
| 969 return false; | 969 return false; |
| 970 | 970 |
| 971 // No autofill data to return if the profiles are empty. | 971 // No autofill data to return if the profiles are empty. |
| 972 if (personal_data_->GetProfiles().empty() && | 972 if (personal_data_->GetProfiles().empty() && |
| 973 personal_data_->credit_cards().empty()) { | 973 personal_data_->GetCreditCards().empty()) { |
| 974 return false; | 974 return false; |
| 975 } | 975 } |
| 976 | 976 |
| 977 *host = web_contents()->GetRenderViewHost(); | 977 *host = web_contents()->GetRenderViewHost(); |
| 978 if (!*host) | 978 if (!*host) |
| 979 return false; | 979 return false; |
| 980 | 980 |
| 981 return true; | 981 return true; |
| 982 } | 982 } |
| 983 | 983 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1271 | 1271 |
| 1272 void AutofillManager::UpdateInitialInteractionTimestamp( | 1272 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1273 const TimeTicks& interaction_timestamp) { | 1273 const TimeTicks& interaction_timestamp) { |
| 1274 if (initial_interaction_timestamp_.is_null() || | 1274 if (initial_interaction_timestamp_.is_null() || |
| 1275 interaction_timestamp < initial_interaction_timestamp_) { | 1275 interaction_timestamp < initial_interaction_timestamp_) { |
| 1276 initial_interaction_timestamp_ = interaction_timestamp; | 1276 initial_interaction_timestamp_ = interaction_timestamp; |
| 1277 } | 1277 } |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 } // namespace autofill | 1280 } // namespace autofill |
| OLD | NEW |