Chromium Code Reviews| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 return handled; | 408 return handled; |
| 409 } | 409 } |
| 410 | 410 |
| 411 void AutofillManager::OnFormSubmitted(const FormData& form) { | 411 void AutofillManager::OnFormSubmitted(const FormData& form) { |
| 412 // Let AutoComplete know as well. | 412 // Let AutoComplete know as well. |
| 413 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); | 413 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); |
| 414 | 414 |
| 415 if (!IsAutofillEnabled()) | 415 if (!IsAutofillEnabled()) |
| 416 return; | 416 return; |
| 417 | 417 |
| 418 if (tab_contents()->profile()->IsOffTheRecord()) | 418 if (tab_contents()->browser_context()->IsOffTheRecord()) |
| 419 return; | 419 return; |
| 420 | 420 |
| 421 // Don't save data that was submitted through JavaScript. | 421 // Don't save data that was submitted through JavaScript. |
| 422 if (!form.user_submitted) | 422 if (!form.user_submitted) |
| 423 return; | 423 return; |
| 424 | 424 |
| 425 // Grab a copy of the form data. | 425 // Grab a copy of the form data. |
| 426 FormStructure submitted_form(form); | 426 FormStructure submitted_form(form); |
| 427 | 427 |
| 428 // Disregard forms that we wouldn't ever autofill in the first place. | 428 // Disregard forms that we wouldn't ever autofill in the first place. |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 689 // positives and to avoid wasting memory. | 689 // positives and to avoid wasting memory. |
| 690 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) | 690 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) |
| 691 autofilled_form_signatures_.pop_back(); | 691 autofilled_form_signatures_.pop_back(); |
| 692 | 692 |
| 693 host->Send(new AutofillMsg_FormDataFilled( | 693 host->Send(new AutofillMsg_FormDataFilled( |
| 694 host->routing_id(), query_id, result)); | 694 host->routing_id(), query_id, result)); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void AutofillManager::OnShowAutofillDialog() { | 697 void AutofillManager::OnShowAutofillDialog() { |
| 698 Browser* browser = BrowserList::GetLastActiveWithProfile( | 698 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 699 tab_contents()->profile()); | 699 static_cast<Profile*>(tab_contents()->browser_context())); |
|
Ilya Sherman
2011/07/21 22:29:23
I really don't like that clients need to magically
| |
| 700 if (browser) | 700 if (browser) |
| 701 browser->ShowOptionsTab(chrome::kAutofillSubPage); | 701 browser->ShowOptionsTab(chrome::kAutofillSubPage); |
| 702 } | 702 } |
| 703 | 703 |
| 704 void AutofillManager::OnDidFillAutofillFormData() { | 704 void AutofillManager::OnDidFillAutofillFormData() { |
| 705 NotificationService::current()->Notify( | 705 NotificationService::current()->Notify( |
| 706 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, | 706 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, |
| 707 Source<RenderViewHost>(tab_contents()->render_view_host()), | 707 Source<RenderViewHost>(tab_contents()->render_view_host()), |
| 708 NotificationService::NoDetails()); | 708 NotificationService::NoDetails()); |
| 709 } | 709 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 738 void AutofillManager::OnUploadedPossibleFieldTypes() { | 738 void AutofillManager::OnUploadedPossibleFieldTypes() { |
| 739 } | 739 } |
| 740 | 740 |
| 741 void AutofillManager::OnServerRequestError( | 741 void AutofillManager::OnServerRequestError( |
| 742 const std::string& form_signature, | 742 const std::string& form_signature, |
| 743 AutofillDownloadManager::AutofillRequestType request_type, | 743 AutofillDownloadManager::AutofillRequestType request_type, |
| 744 int http_error) { | 744 int http_error) { |
| 745 } | 745 } |
| 746 | 746 |
| 747 bool AutofillManager::IsAutofillEnabled() const { | 747 bool AutofillManager::IsAutofillEnabled() const { |
| 748 return const_cast<AutofillManager*>(this)->tab_contents()->profile()-> | 748 Profile* profile = static_cast<Profile*>( |
| 749 GetPrefs()->GetBoolean(prefs::kAutofillEnabled); | 749 const_cast<AutofillManager*>(this)->tab_contents()->browser_context()); |
| 750 return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); | |
|
Ilya Sherman
2011/07/21 22:29:23
Similar question here: Are all clients of GetPrefs
| |
| 750 } | 751 } |
| 751 | 752 |
| 752 void AutofillManager::DeterminePossibleFieldTypesForUpload( | 753 void AutofillManager::DeterminePossibleFieldTypesForUpload( |
| 753 FormStructure* submitted_form) { | 754 FormStructure* submitted_form) { |
| 754 for (size_t i = 0; i < submitted_form->field_count(); i++) { | 755 for (size_t i = 0; i < submitted_form->field_count(); i++) { |
| 755 const AutofillField* field = submitted_form->field(i); | 756 const AutofillField* field = submitted_form->field(i); |
| 756 FieldTypeSet field_types; | 757 FieldTypeSet field_types; |
| 757 personal_data_->GetMatchingTypes(field->value, &field_types); | 758 personal_data_->GetMatchingTypes(field->value, &field_types); |
| 758 | 759 |
| 759 DCHECK(!field_types.empty()); | 760 DCHECK(!field_types.empty()); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1174 void AutofillManager::UnpackGUIDs(int id, | 1175 void AutofillManager::UnpackGUIDs(int id, |
| 1175 GUIDPair* cc_guid, | 1176 GUIDPair* cc_guid, |
| 1176 GUIDPair* profile_guid) { | 1177 GUIDPair* profile_guid) { |
| 1177 int cc_id = id >> std::numeric_limits<unsigned short>::digits & | 1178 int cc_id = id >> std::numeric_limits<unsigned short>::digits & |
| 1178 std::numeric_limits<unsigned short>::max(); | 1179 std::numeric_limits<unsigned short>::max(); |
| 1179 int profile_id = id & std::numeric_limits<unsigned short>::max(); | 1180 int profile_id = id & std::numeric_limits<unsigned short>::max(); |
| 1180 | 1181 |
| 1181 *cc_guid = IDToGUID(cc_id); | 1182 *cc_guid = IDToGUID(cc_id); |
| 1182 *profile_guid = IDToGUID(profile_id); | 1183 *profile_guid = IDToGUID(profile_id); |
| 1183 } | 1184 } |
| OLD | NEW |