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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 AutofillManager::AutofillManager( | 213 AutofillManager::AutofillManager( |
214 content::WebContents* web_contents, | 214 content::WebContents* web_contents, |
215 autofill::AutofillManagerDelegate* delegate, | 215 autofill::AutofillManagerDelegate* delegate, |
216 const std::string& app_locale, | 216 const std::string& app_locale, |
217 AutofillDownloadManagerState enable_download_manager) | 217 AutofillDownloadManagerState enable_download_manager) |
218 : content::WebContentsObserver(web_contents), | 218 : content::WebContentsObserver(web_contents), |
219 manager_delegate_(delegate), | 219 manager_delegate_(delegate), |
220 app_locale_(app_locale), | 220 app_locale_(app_locale), |
221 personal_data_(delegate->GetPersonalDataManager()), | 221 personal_data_(delegate->GetPersonalDataManager()), |
222 autocomplete_history_manager_(web_contents), | 222 autocomplete_history_manager_(web_contents, delegate), |
223 autocheckout_manager_(this), | 223 autocheckout_manager_(this), |
224 metric_logger_(new AutofillMetrics), | 224 metric_logger_(new AutofillMetrics), |
225 has_logged_autofill_enabled_(false), | 225 has_logged_autofill_enabled_(false), |
226 has_logged_address_suggestions_count_(false), | 226 has_logged_address_suggestions_count_(false), |
227 did_show_suggestions_(false), | 227 did_show_suggestions_(false), |
228 user_did_type_(false), | 228 user_did_type_(false), |
229 user_did_autofill_(false), | 229 user_did_autofill_(false), |
230 user_did_edit_autofilled_field_(false), | 230 user_did_edit_autofilled_field_(false), |
231 external_delegate_(NULL), | 231 external_delegate_(NULL), |
232 test_delegate_(NULL), | 232 test_delegate_(NULL), |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 IPC_MESSAGE_HANDLER(AutofillHostMsg_MaybeShowAutocheckoutBubble, | 322 IPC_MESSAGE_HANDLER(AutofillHostMsg_MaybeShowAutocheckoutBubble, |
323 OnMaybeShowAutocheckoutBubble) | 323 OnMaybeShowAutocheckoutBubble) |
324 IPC_MESSAGE_UNHANDLED(handled = false) | 324 IPC_MESSAGE_UNHANDLED(handled = false) |
325 IPC_END_MESSAGE_MAP() | 325 IPC_END_MESSAGE_MAP() |
326 | 326 |
327 return handled; | 327 return handled; |
328 } | 328 } |
329 | 329 |
330 bool AutofillManager::OnFormSubmitted(const FormData& form, | 330 bool AutofillManager::OnFormSubmitted(const FormData& form, |
331 const TimeTicks& timestamp) { | 331 const TimeTicks& timestamp) { |
332 // Let AutoComplete know as well. | 332 // Let Autocomplete know as well. |
333 autocomplete_history_manager_.OnFormSubmitted(form); | 333 autocomplete_history_manager_.OnFormSubmitted(form); |
334 | 334 |
335 if (!IsAutofillEnabled()) | 335 if (!IsAutofillEnabled()) |
336 return false; | 336 return false; |
337 | 337 |
338 if (web_contents()->GetBrowserContext()->IsOffTheRecord()) | 338 if (web_contents()->GetBrowserContext()->IsOffTheRecord()) |
339 return false; | 339 return false; |
340 | 340 |
341 // Don't save data that was submitted through JavaScript. | 341 // Don't save data that was submitted through JavaScript. |
342 if (!form.user_submitted) | 342 if (!form.user_submitted) |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 autocheckout_manager_.OnClickFailed(status); | 857 autocheckout_manager_.OnClickFailed(status); |
858 } | 858 } |
859 | 859 |
860 std::string AutofillManager::GetAutocheckoutURLPrefix() const { | 860 std::string AutofillManager::GetAutocheckoutURLPrefix() const { |
861 if (!web_contents()) | 861 if (!web_contents()) |
862 return std::string(); | 862 return std::string(); |
863 | 863 |
864 autofill::autocheckout::WhitelistManager* whitelist_manager = | 864 autofill::autocheckout::WhitelistManager* whitelist_manager = |
865 manager_delegate_->GetAutocheckoutWhitelistManager(); | 865 manager_delegate_->GetAutocheckoutWhitelistManager(); |
866 | 866 |
867 return whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()); | 867 return whitelist_manager ? |
| 868 whitelist_manager->GetMatchedURLPrefix(web_contents()->GetURL()) : |
| 869 std::string(); |
868 } | 870 } |
869 | 871 |
870 bool AutofillManager::IsAutofillEnabled() const { | 872 bool AutofillManager::IsAutofillEnabled() const { |
871 return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); | 873 return manager_delegate_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
872 } | 874 } |
873 | 875 |
874 void AutofillManager::SendAutofillTypePredictions( | 876 void AutofillManager::SendAutofillTypePredictions( |
875 const std::vector<FormStructure*>& forms) const { | 877 const std::vector<FormStructure*>& forms) const { |
876 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 878 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
877 switches::kShowAutofillTypePredictions)) | 879 switches::kShowAutofillTypePredictions)) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 external_delegate_->Reset(); | 984 external_delegate_->Reset(); |
983 } | 985 } |
984 | 986 |
985 AutofillManager::AutofillManager(content::WebContents* web_contents, | 987 AutofillManager::AutofillManager(content::WebContents* web_contents, |
986 autofill::AutofillManagerDelegate* delegate, | 988 autofill::AutofillManagerDelegate* delegate, |
987 PersonalDataManager* personal_data) | 989 PersonalDataManager* personal_data) |
988 : content::WebContentsObserver(web_contents), | 990 : content::WebContentsObserver(web_contents), |
989 manager_delegate_(delegate), | 991 manager_delegate_(delegate), |
990 app_locale_("en-US"), | 992 app_locale_("en-US"), |
991 personal_data_(personal_data), | 993 personal_data_(personal_data), |
992 autocomplete_history_manager_(web_contents), | 994 autocomplete_history_manager_(web_contents, delegate), |
993 autocheckout_manager_(this), | 995 autocheckout_manager_(this), |
994 metric_logger_(new AutofillMetrics), | 996 metric_logger_(new AutofillMetrics), |
995 has_logged_autofill_enabled_(false), | 997 has_logged_autofill_enabled_(false), |
996 has_logged_address_suggestions_count_(false), | 998 has_logged_address_suggestions_count_(false), |
997 did_show_suggestions_(false), | 999 did_show_suggestions_(false), |
998 user_did_type_(false), | 1000 user_did_type_(false), |
999 user_did_autofill_(false), | 1001 user_did_autofill_(false), |
1000 user_did_edit_autofilled_field_(false), | 1002 user_did_edit_autofilled_field_(false), |
1001 external_delegate_(NULL), | 1003 external_delegate_(NULL), |
1002 test_delegate_(NULL), | 1004 test_delegate_(NULL), |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 | 1318 |
1317 void AutofillManager::UpdateInitialInteractionTimestamp( | 1319 void AutofillManager::UpdateInitialInteractionTimestamp( |
1318 const TimeTicks& interaction_timestamp) { | 1320 const TimeTicks& interaction_timestamp) { |
1319 if (initial_interaction_timestamp_.is_null() || | 1321 if (initial_interaction_timestamp_.is_null() || |
1320 interaction_timestamp < initial_interaction_timestamp_) { | 1322 interaction_timestamp < initial_interaction_timestamp_) { |
1321 initial_interaction_timestamp_ = interaction_timestamp; | 1323 initial_interaction_timestamp_ = interaction_timestamp; |
1322 } | 1324 } |
1323 } | 1325 } |
1324 | 1326 |
1325 } // namespace autofill | 1327 } // namespace autofill |
OLD | NEW |