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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 it->GetMatchingTypes(value, app_locale, &matching_types); | 163 it->GetMatchingTypes(value, app_locale, &matching_types); |
164 } | 164 } |
165 | 165 |
166 if (matching_types.empty()) | 166 if (matching_types.empty()) |
167 matching_types.insert(UNKNOWN_TYPE); | 167 matching_types.insert(UNKNOWN_TYPE); |
168 | 168 |
169 field->set_possible_types(matching_types); | 169 field->set_possible_types(matching_types); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
| 173 // Returns true if server returned known field types to one or more fields in |
| 174 // this form. |
| 175 bool HasServerSpecifiedFieldTypes(const FormStructure& form_structure) { |
| 176 for (size_t i = 0; i < form_structure.field_count(); ++i) { |
| 177 if (form_structure.field(i)->server_type() != NO_SERVER_DATA) |
| 178 return true; |
| 179 } |
| 180 return false; |
| 181 } |
| 182 |
173 } // namespace | 183 } // namespace |
174 | 184 |
175 // static | 185 // static |
176 void AutofillManager::CreateForWebContentsAndDelegate( | 186 void AutofillManager::CreateForWebContentsAndDelegate( |
177 content::WebContents* contents, | 187 content::WebContents* contents, |
178 autofill::AutofillManagerDelegate* delegate, | 188 autofill::AutofillManagerDelegate* delegate, |
179 const std::string& app_locale, | 189 const std::string& app_locale, |
180 AutofillDownloadManagerState enable_download_manager) { | 190 AutofillDownloadManagerState enable_download_manager) { |
181 if (FromWebContents(contents)) | 191 if (FromWebContents(contents)) |
182 return; | 192 return; |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 | 850 |
841 void AutofillManager::OnDidEndTextFieldEditing() { | 851 void AutofillManager::OnDidEndTextFieldEditing() { |
842 if (external_delegate_) | 852 if (external_delegate_) |
843 external_delegate_->DidEndTextFieldEditing(); | 853 external_delegate_->DidEndTextFieldEditing(); |
844 } | 854 } |
845 | 855 |
846 void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) { | 856 void AutofillManager::OnClickFailed(autofill::AutocheckoutStatus status) { |
847 autocheckout_manager_.OnClickFailed(status); | 857 autocheckout_manager_.OnClickFailed(status); |
848 } | 858 } |
849 | 859 |
850 void AutofillManager::OnMaybeShowAutocheckoutBubble( | |
851 const GURL& source_url, | |
852 const content::SSLStatus& ssl_status, | |
853 const gfx::RectF& bounding_box) { | |
854 if (!IsAutofillEnabled()) | |
855 return; | |
856 | |
857 autocheckout_manager_.MaybeShowAutocheckoutBubble( | |
858 source_url, | |
859 ssl_status, | |
860 bounding_box); | |
861 } | |
862 | |
863 std::string AutofillManager::GetAutocheckoutURLPrefix() const { | 860 std::string AutofillManager::GetAutocheckoutURLPrefix() const { |
864 if (!web_contents()) | 861 if (!web_contents()) |
865 return std::string(); | 862 return std::string(); |
866 | 863 |
867 autofill::autocheckout::WhitelistManager* whitelist_manager = | 864 autofill::autocheckout::WhitelistManager* whitelist_manager = |
868 manager_delegate_->GetAutocheckoutWhitelistManager(); | 865 manager_delegate_->GetAutocheckoutWhitelistManager(); |
869 | 866 |
870 return whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()); | 867 return whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()); |
871 } | 868 } |
872 | 869 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 const TimeTicks& submission_time) { | 915 const TimeTicks& submission_time) { |
919 submitted_form->LogQualityMetrics(*metric_logger_, | 916 submitted_form->LogQualityMetrics(*metric_logger_, |
920 load_time, | 917 load_time, |
921 interaction_time, | 918 interaction_time, |
922 submission_time); | 919 submission_time); |
923 | 920 |
924 if (submitted_form->ShouldBeCrowdsourced()) | 921 if (submitted_form->ShouldBeCrowdsourced()) |
925 UploadFormData(*submitted_form); | 922 UploadFormData(*submitted_form); |
926 } | 923 } |
927 | 924 |
| 925 void AutofillManager::OnMaybeShowAutocheckoutBubble( |
| 926 const FormData& form, |
| 927 const gfx::RectF& bounding_box) { |
| 928 if (!IsAutofillEnabled()) |
| 929 return; |
| 930 |
| 931 // Don't show bubble if corresponding FormStructure doesn't have anything to |
| 932 // autofill. |
| 933 FormStructure* cached_form; |
| 934 if (!FindCachedForm(form, &cached_form)) |
| 935 return; |
| 936 |
| 937 // Don't offer Autocheckout bubble if Autofill server is not aware of this |
| 938 // form in the context of Autocheckout experiment. |
| 939 if (!HasServerSpecifiedFieldTypes(*cached_form)) |
| 940 return; |
| 941 |
| 942 autocheckout_manager_.MaybeShowAutocheckoutBubble( |
| 943 form.origin, |
| 944 form.ssl_status, |
| 945 bounding_box); |
| 946 } |
| 947 |
928 void AutofillManager::UploadFormData(const FormStructure& submitted_form) { | 948 void AutofillManager::UploadFormData(const FormStructure& submitted_form) { |
929 if (!download_manager_) | 949 if (!download_manager_) |
930 return; | 950 return; |
931 | 951 |
932 // Check if the form is among the forms that were recently auto-filled. | 952 // Check if the form is among the forms that were recently auto-filled. |
933 bool was_autofilled = false; | 953 bool was_autofilled = false; |
934 std::string form_signature = submitted_form.FormSignature(); | 954 std::string form_signature = submitted_form.FormSignature(); |
935 for (std::list<std::string>::const_iterator it = | 955 for (std::list<std::string>::const_iterator it = |
936 autofilled_form_signatures_.begin(); | 956 autofilled_form_signatures_.begin(); |
937 it != autofilled_form_signatures_.end() && !was_autofilled; | 957 it != autofilled_form_signatures_.end() && !was_autofilled; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 | 1316 |
1297 void AutofillManager::UpdateInitialInteractionTimestamp( | 1317 void AutofillManager::UpdateInitialInteractionTimestamp( |
1298 const TimeTicks& interaction_timestamp) { | 1318 const TimeTicks& interaction_timestamp) { |
1299 if (initial_interaction_timestamp_.is_null() || | 1319 if (initial_interaction_timestamp_.is_null() || |
1300 interaction_timestamp < initial_interaction_timestamp_) { | 1320 interaction_timestamp < initial_interaction_timestamp_) { |
1301 initial_interaction_timestamp_ = interaction_timestamp; | 1321 initial_interaction_timestamp_ = interaction_timestamp; |
1302 } | 1322 } |
1303 } | 1323 } |
1304 | 1324 |
1305 } // namespace autofill | 1325 } // namespace autofill |
OLD | NEW |