| 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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "components/autofill/core/browser/autofill_experiments.h" | 23 #include "components/autofill/core/browser/autofill_experiments.h" |
| 24 #include "components/autofill/core/browser/autofill_field.h" | 24 #include "components/autofill/core/browser/autofill_field.h" |
| 25 #include "components/autofill/core/browser/autofill_metrics.h" | 25 #include "components/autofill/core/browser/autofill_metrics.h" |
| 26 #include "components/autofill/core/browser/form_structure.h" | 26 #include "components/autofill/core/browser/form_structure.h" |
| 27 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 27 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 28 #include "components/autofill/core/browser/phone_number.h" | 28 #include "components/autofill/core/browser/phone_number.h" |
| 29 #include "components/autofill/core/browser/phone_number_i18n.h" | 29 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 30 #include "components/autofill/core/browser/validation.h" | 30 #include "components/autofill/core/browser/validation.h" |
| 31 #include "components/autofill/core/common/autofill_pref_names.h" | 31 #include "components/autofill/core/common/autofill_pref_names.h" |
| 32 #include "components/autofill/core/common/autofill_switches.h" | 32 #include "components/autofill/core/common/autofill_switches.h" |
| 33 #include "components/signin/core/browser/account_tracker_service.h" |
| 33 #include "components/signin/core/common/signin_pref_names.h" | 34 #include "components/signin/core/common/signin_pref_names.h" |
| 34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 35 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
| 35 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" | 36 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" |
| 36 | 37 |
| 37 namespace autofill { | 38 namespace autofill { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 using ::i18n::addressinput::AddressField; | 41 using ::i18n::addressinput::AddressField; |
| 41 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; | 42 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
| 42 using ::i18n::addressinput::STREET_ADDRESS; | 43 using ::i18n::addressinput::STREET_ADDRESS; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 235 |
| 235 PersonalDataManager::PersonalDataManager(const std::string& app_locale) | 236 PersonalDataManager::PersonalDataManager(const std::string& app_locale) |
| 236 : database_(NULL), | 237 : database_(NULL), |
| 237 is_data_loaded_(false), | 238 is_data_loaded_(false), |
| 238 pending_profiles_query_(0), | 239 pending_profiles_query_(0), |
| 239 pending_server_profiles_query_(0), | 240 pending_server_profiles_query_(0), |
| 240 pending_creditcards_query_(0), | 241 pending_creditcards_query_(0), |
| 241 pending_server_creditcards_query_(0), | 242 pending_server_creditcards_query_(0), |
| 242 app_locale_(app_locale), | 243 app_locale_(app_locale), |
| 243 pref_service_(NULL), | 244 pref_service_(NULL), |
| 245 account_tracker_(NULL), |
| 244 is_off_the_record_(false), | 246 is_off_the_record_(false), |
| 245 has_logged_profile_count_(false) {} | 247 has_logged_profile_count_(false) {} |
| 246 | 248 |
| 247 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, | 249 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, |
| 248 PrefService* pref_service, | 250 PrefService* pref_service, |
| 251 AccountTrackerService* account_tracker, |
| 249 bool is_off_the_record) { | 252 bool is_off_the_record) { |
| 250 database_ = database; | 253 database_ = database; |
| 251 SetPrefService(pref_service); | 254 SetPrefService(pref_service); |
| 255 account_tracker_ = account_tracker; |
| 252 is_off_the_record_ = is_off_the_record; | 256 is_off_the_record_ = is_off_the_record; |
| 253 | 257 |
| 254 if (!is_off_the_record_) | 258 if (!is_off_the_record_) |
| 255 AutofillMetrics::LogIsAutofillEnabledAtStartup(IsAutofillEnabled()); | 259 AutofillMetrics::LogIsAutofillEnabledAtStartup(IsAutofillEnabled()); |
| 256 | 260 |
| 257 // WebDataService may not be available in tests. | 261 // WebDataService may not be available in tests. |
| 258 if (!database_.get()) | 262 if (!database_.get()) |
| 259 return; | 263 return; |
| 260 | 264 |
| 261 LoadProfiles(); | 265 LoadProfiles(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 case AUTOFILL_PROFILES_RESULT: | 303 case AUTOFILL_PROFILES_RESULT: |
| 300 if (h == pending_profiles_query_) { | 304 if (h == pending_profiles_query_) { |
| 301 ReceiveLoadedDbValues(h, result, &pending_profiles_query_, | 305 ReceiveLoadedDbValues(h, result, &pending_profiles_query_, |
| 302 &web_profiles_); | 306 &web_profiles_); |
| 303 LogProfileCount(); // This only logs local profiles. | 307 LogProfileCount(); // This only logs local profiles. |
| 304 } else { | 308 } else { |
| 305 ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_, | 309 ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_, |
| 306 &server_profiles_); | 310 &server_profiles_); |
| 307 | 311 |
| 308 if (!server_profiles_.empty()) { | 312 if (!server_profiles_.empty()) { |
| 309 base::string16 email = base::UTF8ToUTF16( | 313 std::string account_id = |
| 310 pref_service_->GetString(::prefs::kGoogleServicesUsername)); | 314 pref_service_->GetString(::prefs::kGoogleServicesAccountId); |
| 315 base::string16 email = |
| 316 base::UTF8ToUTF16( |
| 317 account_tracker_->GetAccountInfo(account_id).email); |
| 311 DCHECK(!email.empty()); | 318 DCHECK(!email.empty()); |
| 312 for (AutofillProfile* profile : server_profiles_) | 319 for (AutofillProfile* profile : server_profiles_) |
| 313 profile->SetRawInfo(EMAIL_ADDRESS, email); | 320 profile->SetRawInfo(EMAIL_ADDRESS, email); |
| 314 } | 321 } |
| 315 } | 322 } |
| 316 break; | 323 break; |
| 317 case AUTOFILL_CREDITCARDS_RESULT: | 324 case AUTOFILL_CREDITCARDS_RESULT: |
| 318 if (h == pending_creditcards_query_) { | 325 if (h == pending_creditcards_query_) { |
| 319 ReceiveLoadedDbValues(h, result, &pending_creditcards_query_, | 326 ReceiveLoadedDbValues(h, result, &pending_creditcards_query_, |
| 320 &local_credit_cards_); | 327 &local_credit_cards_); |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 } | 1400 } |
| 1394 if (IsExperimentalWalletIntegrationEnabled() && | 1401 if (IsExperimentalWalletIntegrationEnabled() && |
| 1395 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1402 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
| 1396 profiles_.insert( | 1403 profiles_.insert( |
| 1397 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1404 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
| 1398 } | 1405 } |
| 1399 return profiles_; | 1406 return profiles_; |
| 1400 } | 1407 } |
| 1401 | 1408 |
| 1402 } // namespace autofill | 1409 } // namespace autofill |
| OLD | NEW |