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_HideAutofillPopup, | |
| 315 OnHideAutofillPopup) | |
| 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 const gfx::Rect& bounding_box) { | |
| 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, form, field); |
| 453 external_delegate_->SetAutofillElementBounds(bounding_box); | |
|
Ilya Sherman
2011/11/09 20:34:19
nit: Are you sure you want these to be two separat
csharp
2011/11/10 18:09:32
Hmmm, I don't think we would need to call them sep
| |
| 454 } | |
| 450 | 455 |
| 451 RenderViewHost* host = NULL; | 456 RenderViewHost* host = NULL; |
| 452 FormStructure* form_structure = NULL; | 457 FormStructure* form_structure = NULL; |
| 453 AutofillField* autofill_field = NULL; | 458 AutofillField* autofill_field = NULL; |
| 454 if (GetHost( | 459 if (GetHost( |
| 455 personal_data_->profiles(), personal_data_->credit_cards(), &host) && | 460 personal_data_->profiles(), personal_data_->credit_cards(), &host) && |
| 456 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && | 461 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && |
| 457 // Don't send suggestions for forms that aren't auto-fillable. | 462 // Don't send suggestions for forms that aren't auto-fillable. |
| 458 form_structure->IsAutofillable(false)) { | 463 form_structure->IsAutofillable(false)) { |
| 459 AutofillFieldType type = autofill_field->type(); | 464 AutofillFieldType type = autofill_field->type(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN); | 671 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN); |
| 667 | 672 |
| 668 if (!did_show_suggestions_) { | 673 if (!did_show_suggestions_) { |
| 669 did_show_suggestions_ = true; | 674 did_show_suggestions_ = true; |
| 670 metric_logger_->LogUserHappinessMetric( | 675 metric_logger_->LogUserHappinessMetric( |
| 671 AutofillMetrics::SUGGESTIONS_SHOWN_ONCE); | 676 AutofillMetrics::SUGGESTIONS_SHOWN_ONCE); |
| 672 } | 677 } |
| 673 } | 678 } |
| 674 } | 679 } |
| 675 | 680 |
| 681 void AutofillManager::OnHideAutofillPopup() { | |
| 682 if (external_delegate_) | |
| 683 external_delegate_->HideAutofillPopup(); | |
| 684 } | |
| 685 | |
| 676 void AutofillManager::OnLoadedServerPredictions( | 686 void AutofillManager::OnLoadedServerPredictions( |
| 677 const std::string& response_xml) { | 687 const std::string& response_xml) { |
| 678 // Parse and store the server predictions. | 688 // Parse and store the server predictions. |
| 679 FormStructure::ParseQueryResponse(response_xml, | 689 FormStructure::ParseQueryResponse(response_xml, |
| 680 form_structures_.get(), | 690 form_structures_.get(), |
| 681 *metric_logger_); | 691 *metric_logger_); |
| 682 | 692 |
| 683 // If the corresponding flag is set, annotate forms with the predicted types. | 693 // If the corresponding flag is set, annotate forms with the predicted types. |
| 684 SendAutofillTypePredictions(form_structures_.get()); | 694 SendAutofillTypePredictions(form_structures_.get()); |
| 685 } | 695 } |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 *profile_guid = IDToGUID(profile_id); | 1287 *profile_guid = IDToGUID(profile_id); |
| 1278 } | 1288 } |
| 1279 | 1289 |
| 1280 void AutofillManager::UpdateInitialInteractionTimestamp( | 1290 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1281 const TimeTicks& interaction_timestamp) { | 1291 const TimeTicks& interaction_timestamp) { |
| 1282 if (initial_interaction_timestamp_.is_null() || | 1292 if (initial_interaction_timestamp_.is_null() || |
| 1283 interaction_timestamp < initial_interaction_timestamp_) { | 1293 interaction_timestamp < initial_interaction_timestamp_) { |
| 1284 initial_interaction_timestamp_ = interaction_timestamp; | 1294 initial_interaction_timestamp_ = interaction_timestamp; |
| 1285 } | 1295 } |
| 1286 } | 1296 } |
| OLD | NEW |