OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 } // namespace | 205 } // namespace |
206 | 206 |
207 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) | 207 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) |
208 : TabContentsObserver(tab_contents->tab_contents()), | 208 : TabContentsObserver(tab_contents->tab_contents()), |
209 tab_contents_wrapper_(tab_contents), | 209 tab_contents_wrapper_(tab_contents), |
210 personal_data_(NULL), | 210 personal_data_(NULL), |
211 download_manager_(tab_contents->profile()), | 211 download_manager_(tab_contents->profile(), this), |
212 disable_download_manager_requests_(false), | 212 disable_download_manager_requests_(false), |
213 metric_logger_(new AutofillMetrics), | 213 metric_logger_(new AutofillMetrics), |
214 has_logged_autofill_enabled_(false), | 214 has_logged_autofill_enabled_(false), |
215 has_logged_address_suggestions_count_(false), | 215 has_logged_address_suggestions_count_(false), |
216 did_show_suggestions_(false), | 216 did_show_suggestions_(false), |
217 user_did_type_(false), | 217 user_did_type_(false), |
218 user_did_autofill_(false), | 218 user_did_autofill_(false), |
219 user_did_edit_autofilled_field_(false) { | 219 user_did_edit_autofilled_field_(false) { |
220 DCHECK(tab_contents); | 220 DCHECK(tab_contents); |
221 | 221 |
222 // |personal_data_| is NULL when using TestTabContents. | 222 // |personal_data_| is NULL when using TestTabContents. |
223 personal_data_ = PersonalDataManagerFactory::GetForProfile( | 223 personal_data_ = PersonalDataManagerFactory::GetForProfile( |
224 tab_contents->profile()->GetOriginalProfile()); | 224 tab_contents->profile()->GetOriginalProfile()); |
225 download_manager_.SetObserver(this); | |
226 } | 225 } |
227 | 226 |
228 AutofillManager::~AutofillManager() { | 227 AutofillManager::~AutofillManager() { |
229 download_manager_.SetObserver(NULL); | |
230 } | 228 } |
231 | 229 |
232 // static | 230 // static |
233 void AutofillManager::RegisterUserPrefs(PrefService* prefs) { | 231 void AutofillManager::RegisterUserPrefs(PrefService* prefs) { |
234 prefs->RegisterBooleanPref(prefs::kAutofillEnabled, | 232 prefs->RegisterBooleanPref(prefs::kAutofillEnabled, |
235 true, | 233 true, |
236 PrefService::SYNCABLE_PREF); | 234 PrefService::SYNCABLE_PREF); |
237 #if defined(OS_MACOSX) | 235 #if defined(OS_MACOSX) |
238 prefs->RegisterBooleanPref(prefs::kAutofillAuxiliaryProfilesEnabled, | 236 prefs->RegisterBooleanPref(prefs::kAutofillAuxiliaryProfilesEnabled, |
239 true, | 237 true, |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 const std::string& response_xml) { | 609 const std::string& response_xml) { |
612 // Parse and store the server predictions. | 610 // Parse and store the server predictions. |
613 FormStructure::ParseQueryResponse(response_xml, | 611 FormStructure::ParseQueryResponse(response_xml, |
614 form_structures_.get(), | 612 form_structures_.get(), |
615 *metric_logger_); | 613 *metric_logger_); |
616 | 614 |
617 // If the corresponding flag is set, annotate forms with the predicted types. | 615 // If the corresponding flag is set, annotate forms with the predicted types. |
618 SendAutofillTypePredictions(form_structures_.get()); | 616 SendAutofillTypePredictions(form_structures_.get()); |
619 } | 617 } |
620 | 618 |
621 void AutofillManager::OnUploadedPossibleFieldTypes() { | |
622 } | |
623 | |
624 void AutofillManager::OnServerRequestError( | |
625 const std::string& form_signature, | |
626 AutofillDownloadManager::AutofillRequestType request_type, | |
627 int http_error) { | |
628 } | |
629 | |
630 bool AutofillManager::IsAutofillEnabled() const { | 619 bool AutofillManager::IsAutofillEnabled() const { |
631 Profile* profile = Profile::FromBrowserContext( | 620 Profile* profile = Profile::FromBrowserContext( |
632 const_cast<AutofillManager*>(this)->tab_contents()->browser_context()); | 621 const_cast<AutofillManager*>(this)->tab_contents()->browser_context()); |
633 return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); | 622 return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
634 } | 623 } |
635 | 624 |
636 void AutofillManager::DeterminePossibleFieldTypesForUpload( | 625 void AutofillManager::DeterminePossibleFieldTypesForUpload( |
637 FormStructure* submitted_form) { | 626 FormStructure* submitted_form) { |
638 // Combine all the profiles and credit cards stored in |personal_data_| into | 627 // Combine all the profiles and credit cards stored in |personal_data_| into |
639 // one vector for ease of iteration. | 628 // one vector for ease of iteration. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 user_did_edit_autofilled_field_ = false; | 718 user_did_edit_autofilled_field_ = false; |
730 forms_loaded_timestamp_ = TimeTicks(); | 719 forms_loaded_timestamp_ = TimeTicks(); |
731 initial_interaction_timestamp_ = TimeTicks(); | 720 initial_interaction_timestamp_ = TimeTicks(); |
732 } | 721 } |
733 | 722 |
734 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, | 723 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, |
735 PersonalDataManager* personal_data) | 724 PersonalDataManager* personal_data) |
736 : TabContentsObserver(tab_contents->tab_contents()), | 725 : TabContentsObserver(tab_contents->tab_contents()), |
737 tab_contents_wrapper_(tab_contents), | 726 tab_contents_wrapper_(tab_contents), |
738 personal_data_(personal_data), | 727 personal_data_(personal_data), |
739 download_manager_(NULL), | 728 download_manager_(tab_contents->profile(), this), |
740 disable_download_manager_requests_(true), | 729 disable_download_manager_requests_(true), |
741 metric_logger_(new AutofillMetrics), | 730 metric_logger_(new AutofillMetrics), |
742 has_logged_autofill_enabled_(false), | 731 has_logged_autofill_enabled_(false), |
743 has_logged_address_suggestions_count_(false), | 732 has_logged_address_suggestions_count_(false), |
744 did_show_suggestions_(false), | 733 did_show_suggestions_(false), |
745 user_did_type_(false), | 734 user_did_type_(false), |
746 user_did_autofill_(false), | 735 user_did_autofill_(false), |
747 user_did_edit_autofilled_field_(false) { | 736 user_did_edit_autofilled_field_(false) { |
748 DCHECK(tab_contents); | 737 DCHECK(tab_contents); |
749 } | 738 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 *profile_guid = IDToGUID(profile_id); | 1219 *profile_guid = IDToGUID(profile_id); |
1231 } | 1220 } |
1232 | 1221 |
1233 void AutofillManager::UpdateInitialInteractionTimestamp( | 1222 void AutofillManager::UpdateInitialInteractionTimestamp( |
1234 const TimeTicks& interaction_timestamp) { | 1223 const TimeTicks& interaction_timestamp) { |
1235 if (initial_interaction_timestamp_.is_null() || | 1224 if (initial_interaction_timestamp_.is_null() || |
1236 interaction_timestamp < initial_interaction_timestamp_) { | 1225 interaction_timestamp < initial_interaction_timestamp_) { |
1237 initial_interaction_timestamp_ = interaction_timestamp; | 1226 initial_interaction_timestamp_ = interaction_timestamp; |
1238 } | 1227 } |
1239 } | 1228 } |
OLD | NEW |