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

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

Issue 8353025: External autofill delegates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase against TOT 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>
11 #include <set> 11 #include <set>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "chrome/browser/autocomplete_history_manager.h" 19 #include "chrome/browser/autocomplete_history_manager.h"
20 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" 20 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
21 #include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h" 21 #include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h"
22 #include "chrome/browser/autofill/autofill_external_delegate.h"
22 #include "chrome/browser/autofill/autofill_field.h" 23 #include "chrome/browser/autofill/autofill_field.h"
23 #include "chrome/browser/autofill/autofill_metrics.h" 24 #include "chrome/browser/autofill/autofill_metrics.h"
24 #include "chrome/browser/autofill/autofill_profile.h" 25 #include "chrome/browser/autofill/autofill_profile.h"
25 #include "chrome/browser/autofill/autofill_type.h" 26 #include "chrome/browser/autofill/autofill_type.h"
26 #include "chrome/browser/autofill/credit_card.h" 27 #include "chrome/browser/autofill/credit_card.h"
27 #include "chrome/browser/autofill/form_structure.h" 28 #include "chrome/browser/autofill/form_structure.h"
28 #include "chrome/browser/autofill/personal_data_manager.h" 29 #include "chrome/browser/autofill/personal_data_manager.h"
29 #include "chrome/browser/autofill/personal_data_manager_factory.h" 30 #include "chrome/browser/autofill/personal_data_manager_factory.h"
30 #include "chrome/browser/autofill/phone_number.h" 31 #include "chrome/browser/autofill/phone_number.h"
31 #include "chrome/browser/autofill/phone_number_i18n.h" 32 #include "chrome/browser/autofill/phone_number_i18n.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 tab_contents_wrapper_(tab_contents), 210 tab_contents_wrapper_(tab_contents),
210 personal_data_(NULL), 211 personal_data_(NULL),
211 download_manager_(tab_contents->profile(), this), 212 download_manager_(tab_contents->profile(), this),
212 disable_download_manager_requests_(false), 213 disable_download_manager_requests_(false),
213 metric_logger_(new AutofillMetrics), 214 metric_logger_(new AutofillMetrics),
214 has_logged_autofill_enabled_(false), 215 has_logged_autofill_enabled_(false),
215 has_logged_address_suggestions_count_(false), 216 has_logged_address_suggestions_count_(false),
216 did_show_suggestions_(false), 217 did_show_suggestions_(false),
217 user_did_type_(false), 218 user_did_type_(false),
218 user_did_autofill_(false), 219 user_did_autofill_(false),
219 user_did_edit_autofilled_field_(false) { 220 user_did_edit_autofilled_field_(false),
221 external_delegate_(NULL) {
220 DCHECK(tab_contents); 222 DCHECK(tab_contents);
221 223
222 // |personal_data_| is NULL when using TestTabContents. 224 // |personal_data_| is NULL when using TestTabContents.
223 personal_data_ = PersonalDataManagerFactory::GetForProfile( 225 personal_data_ = PersonalDataManagerFactory::GetForProfile(
224 tab_contents->profile()->GetOriginalProfile()); 226 tab_contents->profile()->GetOriginalProfile());
225 } 227 }
226 228
227 AutofillManager::~AutofillManager() { 229 AutofillManager::~AutofillManager() {
228 } 230 }
229 231
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 375 }
374 376
375 void AutofillManager::OnQueryFormFieldAutofill(int query_id, 377 void AutofillManager::OnQueryFormFieldAutofill(int query_id,
376 const FormData& form, 378 const FormData& form,
377 const FormField& field) { 379 const FormField& field) {
378 std::vector<string16> values; 380 std::vector<string16> values;
379 std::vector<string16> labels; 381 std::vector<string16> labels;
380 std::vector<string16> icons; 382 std::vector<string16> icons;
381 std::vector<int> unique_ids; 383 std::vector<int> unique_ids;
382 384
385 if (external_delegate_)
386 external_delegate_->OnQuery(query_id, form, field);
387
383 RenderViewHost* host = NULL; 388 RenderViewHost* host = NULL;
384 FormStructure* form_structure = NULL; 389 FormStructure* form_structure = NULL;
385 AutofillField* autofill_field = NULL; 390 AutofillField* autofill_field = NULL;
386 if (GetHost( 391 if (GetHost(
387 personal_data_->profiles(), personal_data_->credit_cards(), &host) && 392 personal_data_->profiles(), personal_data_->credit_cards(), &host) &&
388 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 393 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
389 // Don't send suggestions for forms that aren't auto-fillable. 394 // Don't send suggestions for forms that aren't auto-fillable.
390 form_structure->IsAutofillable(false)) { 395 form_structure->IsAutofillable(false)) {
391 AutofillFieldType type = autofill_field->type(); 396 AutofillFieldType type = autofill_field->type();
392 bool is_filling_credit_card = 397 bool is_filling_credit_card =
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 tab_contents_wrapper_(tab_contents), 731 tab_contents_wrapper_(tab_contents),
727 personal_data_(personal_data), 732 personal_data_(personal_data),
728 download_manager_(tab_contents->profile(), this), 733 download_manager_(tab_contents->profile(), this),
729 disable_download_manager_requests_(true), 734 disable_download_manager_requests_(true),
730 metric_logger_(new AutofillMetrics), 735 metric_logger_(new AutofillMetrics),
731 has_logged_autofill_enabled_(false), 736 has_logged_autofill_enabled_(false),
732 has_logged_address_suggestions_count_(false), 737 has_logged_address_suggestions_count_(false),
733 did_show_suggestions_(false), 738 did_show_suggestions_(false),
734 user_did_type_(false), 739 user_did_type_(false),
735 user_did_autofill_(false), 740 user_did_autofill_(false),
736 user_did_edit_autofilled_field_(false) { 741 user_did_edit_autofilled_field_(false),
742 external_delegate_(NULL) {
737 DCHECK(tab_contents); 743 DCHECK(tab_contents);
738 } 744 }
739 745
740 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { 746 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) {
741 metric_logger_.reset(metric_logger); 747 metric_logger_.reset(metric_logger);
742 } 748 }
743 749
744 bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles, 750 bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles,
745 const std::vector<CreditCard*>& credit_cards, 751 const std::vector<CreditCard*>& credit_cards,
746 RenderViewHost** host) const { 752 RenderViewHost** host) const {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 *profile_guid = IDToGUID(profile_id); 1225 *profile_guid = IDToGUID(profile_id);
1220 } 1226 }
1221 1227
1222 void AutofillManager::UpdateInitialInteractionTimestamp( 1228 void AutofillManager::UpdateInitialInteractionTimestamp(
1223 const TimeTicks& interaction_timestamp) { 1229 const TimeTicks& interaction_timestamp) {
1224 if (initial_interaction_timestamp_.is_null() || 1230 if (initial_interaction_timestamp_.is_null() ||
1225 interaction_timestamp < initial_interaction_timestamp_) { 1231 interaction_timestamp < initial_interaction_timestamp_) {
1226 initial_interaction_timestamp_ = interaction_timestamp; 1232 initial_interaction_timestamp_ = interaction_timestamp;
1227 } 1233 }
1228 } 1234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698