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

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: feedback 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()), 212 download_manager_(tab_contents->profile()),
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 download_manager_.SetObserver(this); 227 download_manager_.SetObserver(this);
226 } 228 }
227 229
228 AutofillManager::~AutofillManager() { 230 AutofillManager::~AutofillManager() {
229 download_manager_.SetObserver(NULL); 231 download_manager_.SetObserver(NULL);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 377 }
376 378
377 void AutofillManager::OnQueryFormFieldAutofill(int query_id, 379 void AutofillManager::OnQueryFormFieldAutofill(int query_id,
378 const FormData& form, 380 const FormData& form,
379 const FormField& field) { 381 const FormField& field) {
380 std::vector<string16> values; 382 std::vector<string16> values;
381 std::vector<string16> labels; 383 std::vector<string16> labels;
382 std::vector<string16> icons; 384 std::vector<string16> icons;
383 std::vector<int> unique_ids; 385 std::vector<int> unique_ids;
384 386
387 if (external_delegate_)
388 external_delegate_->OnQuery(query_id, form, field);
389
385 RenderViewHost* host = NULL; 390 RenderViewHost* host = NULL;
386 FormStructure* form_structure = NULL; 391 FormStructure* form_structure = NULL;
387 AutofillField* autofill_field = NULL; 392 AutofillField* autofill_field = NULL;
388 if (GetHost( 393 if (GetHost(
389 personal_data_->profiles(), personal_data_->credit_cards(), &host) && 394 personal_data_->profiles(), personal_data_->credit_cards(), &host) &&
390 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 395 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
391 // Don't send suggestions for forms that aren't auto-fillable. 396 // Don't send suggestions for forms that aren't auto-fillable.
392 form_structure->IsAutofillable(false)) { 397 form_structure->IsAutofillable(false)) {
393 AutofillFieldType type = autofill_field->type(); 398 AutofillFieldType type = autofill_field->type();
394 bool is_filling_credit_card = 399 bool is_filling_credit_card =
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 tab_contents_wrapper_(tab_contents), 742 tab_contents_wrapper_(tab_contents),
738 personal_data_(personal_data), 743 personal_data_(personal_data),
739 download_manager_(NULL), 744 download_manager_(NULL),
740 disable_download_manager_requests_(true), 745 disable_download_manager_requests_(true),
741 metric_logger_(new AutofillMetrics), 746 metric_logger_(new AutofillMetrics),
742 has_logged_autofill_enabled_(false), 747 has_logged_autofill_enabled_(false),
743 has_logged_address_suggestions_count_(false), 748 has_logged_address_suggestions_count_(false),
744 did_show_suggestions_(false), 749 did_show_suggestions_(false),
745 user_did_type_(false), 750 user_did_type_(false),
746 user_did_autofill_(false), 751 user_did_autofill_(false),
747 user_did_edit_autofilled_field_(false) { 752 user_did_edit_autofilled_field_(false),
753 external_delegate_(NULL) {
748 DCHECK(tab_contents); 754 DCHECK(tab_contents);
749 } 755 }
750 756
751 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { 757 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) {
752 metric_logger_.reset(metric_logger); 758 metric_logger_.reset(metric_logger);
753 } 759 }
754 760
755 bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles, 761 bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles,
756 const std::vector<CreditCard*>& credit_cards, 762 const std::vector<CreditCard*>& credit_cards,
757 RenderViewHost** host) const { 763 RenderViewHost** host) const {
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 *profile_guid = IDToGUID(profile_id); 1234 *profile_guid = IDToGUID(profile_id);
1229 } 1235 }
1230 1236
1231 void AutofillManager::UpdateInitialInteractionTimestamp( 1237 void AutofillManager::UpdateInitialInteractionTimestamp(
1232 const TimeTicks& interaction_timestamp) { 1238 const TimeTicks& interaction_timestamp) {
1233 if (initial_interaction_timestamp_.is_null() || 1239 if (initial_interaction_timestamp_.is_null() ||
1234 interaction_timestamp < initial_interaction_timestamp_) { 1240 interaction_timestamp < initial_interaction_timestamp_) {
1235 initial_interaction_timestamp_ = interaction_timestamp; 1241 initial_interaction_timestamp_ = interaction_timestamp;
1236 } 1242 }
1237 } 1243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698