Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 8490017: Setting up external delegate calls to allow a future delegate to handle autofill (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Hard coding input element position Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
46 #include "chrome/common/url_constants.h" 46 #include "chrome/common/url_constants.h"
47 #include "content/browser/renderer_host/render_view_host.h" 47 #include "content/browser/renderer_host/render_view_host.h"
48 #include "content/public/browser/browser_thread.h" 48 #include "content/public/browser/browser_thread.h"
49 #include "content/public/browser/notification_service.h" 49 #include "content/public/browser/notification_service.h"
50 #include "content/public/browser/notification_source.h" 50 #include "content/public/browser/notification_source.h"
51 #include "googleurl/src/gurl.h" 51 #include "googleurl/src/gurl.h"
52 #include "grit/generated_resources.h" 52 #include "grit/generated_resources.h"
53 #include "ipc/ipc_message_macros.h" 53 #include "ipc/ipc_message_macros.h"
54 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
55 #include "ui/gfx/rect.h"
55 #include "webkit/glue/form_data.h" 56 #include "webkit/glue/form_data.h"
56 #include "webkit/glue/form_data_predictions.h" 57 #include "webkit/glue/form_data_predictions.h"
57 #include "webkit/glue/form_field.h" 58 #include "webkit/glue/form_field.h"
58 59
59 using base::TimeTicks; 60 using base::TimeTicks;
60 using content::BrowserThread; 61 using content::BrowserThread;
61 using switches::kEnableAutofillFeedback; 62 using switches::kEnableAutofillFeedback;
62 using webkit_glue::FormData; 63 using webkit_glue::FormData;
63 using webkit_glue::FormDataPredictions; 64 using webkit_glue::FormDataPredictions;
64 using webkit_glue::FormField; 65 using webkit_glue::FormField;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, 305 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog,
305 OnShowAutofillDialog) 306 OnShowAutofillDialog)
306 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, 307 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData,
307 OnFillAutofillFormData) 308 OnFillAutofillFormData)
308 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData, 309 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData,
309 OnDidPreviewAutofillFormData) 310 OnDidPreviewAutofillFormData)
310 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, 311 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData,
311 OnDidFillAutofillFormData) 312 OnDidFillAutofillFormData)
312 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, 313 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions,
313 OnDidShowAutofillSuggestions) 314 OnDidShowAutofillSuggestions)
315 IPC_MESSAGE_HANDLER(AutofillHostMsg_HideAutofillPopup,
316 OnHideAutofillPopup)
314 IPC_MESSAGE_UNHANDLED(handled = false) 317 IPC_MESSAGE_UNHANDLED(handled = false)
315 IPC_END_MESSAGE_MAP() 318 IPC_END_MESSAGE_MAP()
316 319
317 return handled; 320 return handled;
318 } 321 }
319 322
320 bool AutofillManager::OnFormSubmitted(const FormData& form, 323 bool AutofillManager::OnFormSubmitted(const FormData& form,
321 const TimeTicks& timestamp) { 324 const TimeTicks& timestamp) {
322 // Let AutoComplete know as well. 325 // Let AutoComplete know as well.
323 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); 326 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 metric_logger_->LogUserHappinessMetric( 435 metric_logger_->LogUserHappinessMetric(
433 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); 436 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE);
434 } 437 }
435 } 438 }
436 439
437 UpdateInitialInteractionTimestamp(timestamp); 440 UpdateInitialInteractionTimestamp(timestamp);
438 } 441 }
439 442
440 void AutofillManager::OnQueryFormFieldAutofill(int query_id, 443 void AutofillManager::OnQueryFormFieldAutofill(int query_id,
441 const FormData& form, 444 const FormData& form,
442 const FormField& field) { 445 const FormField& field,
446 const gfx::Rect& bounding_box) {
443 std::vector<string16> values; 447 std::vector<string16> values;
444 std::vector<string16> labels; 448 std::vector<string16> labels;
445 std::vector<string16> icons; 449 std::vector<string16> icons;
446 std::vector<int> unique_ids; 450 std::vector<int> unique_ids;
447 451
448 if (external_delegate_) 452 if (external_delegate_) {
449 external_delegate_->OnQuery(query_id, form, field); 453 external_delegate_->OnQuery(query_id, form, field, bounding_box);
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698