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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, | 304 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, |
| 305 OnShowAutofillDialog) | 305 OnShowAutofillDialog) |
| 306 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, | 306 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, |
| 307 OnFillAutofillFormData) | 307 OnFillAutofillFormData) |
| 308 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData, | 308 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData, |
| 309 OnDidPreviewAutofillFormData) | 309 OnDidPreviewAutofillFormData) |
| 310 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, | 310 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, |
| 311 OnDidFillAutofillFormData) | 311 OnDidFillAutofillFormData) |
| 312 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, | 312 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, |
| 313 OnDidShowAutofillSuggestions) | 313 OnDidShowAutofillSuggestions) |
| 314 IPC_MESSAGE_HANDLER(AutofillHostMsg_SetDidEndTextFieldEditing, | |
| 315 OnSetDidEndTextFieldEditing) | |
| 314 IPC_MESSAGE_UNHANDLED(handled = false) | 316 IPC_MESSAGE_UNHANDLED(handled = false) |
| 315 IPC_END_MESSAGE_MAP() | 317 IPC_END_MESSAGE_MAP() |
| 316 | 318 |
| 317 return handled; | 319 return handled; |
| 318 } | 320 } |
| 319 | 321 |
| 320 bool AutofillManager::OnFormSubmitted(const FormData& form, | 322 bool AutofillManager::OnFormSubmitted(const FormData& form, |
| 321 const TimeTicks& timestamp) { | 323 const TimeTicks& timestamp) { |
| 322 // Let AutoComplete know as well. | 324 // Let AutoComplete know as well. |
| 323 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); | 325 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 metric_logger_->LogUserHappinessMetric( | 434 metric_logger_->LogUserHappinessMetric( |
| 433 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); | 435 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); |
| 434 } | 436 } |
| 435 } | 437 } |
| 436 | 438 |
| 437 UpdateInitialInteractionTimestamp(timestamp); | 439 UpdateInitialInteractionTimestamp(timestamp); |
| 438 } | 440 } |
| 439 | 441 |
| 440 void AutofillManager::OnQueryFormFieldAutofill(int query_id, | 442 void AutofillManager::OnQueryFormFieldAutofill(int query_id, |
| 441 const FormData& form, | 443 const FormData& form, |
| 442 const FormField& field) { | 444 const FormField& field, |
| 445 bool display_warning) { | |
| 443 std::vector<string16> values; | 446 std::vector<string16> values; |
| 444 std::vector<string16> labels; | 447 std::vector<string16> labels; |
| 445 std::vector<string16> icons; | 448 std::vector<string16> icons; |
| 446 std::vector<int> unique_ids; | 449 std::vector<int> unique_ids; |
| 447 | 450 |
| 448 if (external_delegate_) | 451 if (external_delegate_) |
| 449 external_delegate_->OnQuery(query_id, form, field); | 452 external_delegate_->OnQuery(query_id, |
| 453 form, | |
| 454 field, | |
| 455 display_warning); | |
|
Ilya Sherman
2011/11/17 02:24:37
nit: Please add curly braces since this method bod
csharp
2011/11/18 18:15:10
Done.
| |
| 450 | 456 |
| 451 RenderViewHost* host = NULL; | 457 RenderViewHost* host = NULL; |
| 452 FormStructure* form_structure = NULL; | 458 FormStructure* form_structure = NULL; |
| 453 AutofillField* autofill_field = NULL; | 459 AutofillField* autofill_field = NULL; |
| 454 if (GetHost( | 460 if (GetHost( |
| 455 personal_data_->profiles(), personal_data_->credit_cards(), &host) && | 461 personal_data_->profiles(), personal_data_->credit_cards(), &host) && |
| 456 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && | 462 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && |
| 457 // Don't send suggestions for forms that aren't auto-fillable. | 463 // Don't send suggestions for forms that aren't auto-fillable. |
| 458 form_structure->IsAutofillable(false)) { | 464 form_structure->IsAutofillable(false)) { |
| 459 AutofillFieldType type = autofill_field->type(); | 465 AutofillFieldType type = autofill_field->type(); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 677 const std::string& response_xml) { | 683 const std::string& response_xml) { |
| 678 // Parse and store the server predictions. | 684 // Parse and store the server predictions. |
| 679 FormStructure::ParseQueryResponse(response_xml, | 685 FormStructure::ParseQueryResponse(response_xml, |
| 680 form_structures_.get(), | 686 form_structures_.get(), |
| 681 *metric_logger_); | 687 *metric_logger_); |
| 682 | 688 |
| 683 // If the corresponding flag is set, annotate forms with the predicted types. | 689 // If the corresponding flag is set, annotate forms with the predicted types. |
| 684 SendAutofillTypePredictions(form_structures_.get()); | 690 SendAutofillTypePredictions(form_structures_.get()); |
| 685 } | 691 } |
| 686 | 692 |
| 693 void AutofillManager::OnSetDidEndTextFieldEditing() { | |
| 694 if (external_delegate_) | |
| 695 external_delegate_->SetDidEndTextFieldEditing(); | |
| 696 } | |
| 697 | |
| 687 bool AutofillManager::IsAutofillEnabled() const { | 698 bool AutofillManager::IsAutofillEnabled() const { |
| 688 Profile* profile = Profile::FromBrowserContext( | 699 Profile* profile = Profile::FromBrowserContext( |
| 689 const_cast<AutofillManager*>(this)->tab_contents()->browser_context()); | 700 const_cast<AutofillManager*>(this)->tab_contents()->browser_context()); |
| 690 return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); | 701 return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
| 691 } | 702 } |
| 692 | 703 |
| 693 void AutofillManager::SendAutofillTypePredictions( | 704 void AutofillManager::SendAutofillTypePredictions( |
| 694 const std::vector<FormStructure*>& forms) const { | 705 const std::vector<FormStructure*>& forms) const { |
| 695 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 706 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 696 switches::kShowAutofillTypePredictions)) | 707 switches::kShowAutofillTypePredictions)) |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 *profile_guid = IDToGUID(profile_id); | 1288 *profile_guid = IDToGUID(profile_id); |
| 1278 } | 1289 } |
| 1279 | 1290 |
| 1280 void AutofillManager::UpdateInitialInteractionTimestamp( | 1291 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1281 const TimeTicks& interaction_timestamp) { | 1292 const TimeTicks& interaction_timestamp) { |
| 1282 if (initial_interaction_timestamp_.is_null() || | 1293 if (initial_interaction_timestamp_.is_null() || |
| 1283 interaction_timestamp < initial_interaction_timestamp_) { | 1294 interaction_timestamp < initial_interaction_timestamp_) { |
| 1284 initial_interaction_timestamp_ = interaction_timestamp; | 1295 initial_interaction_timestamp_ = interaction_timestamp; |
| 1285 } | 1296 } |
| 1286 } | 1297 } |
| OLD | NEW |