OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 14 #include "base/bind.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/guid.h" | 16 #include "base/guid.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/browser/api/infobars/infobar_tab_service.h" |
22 #include "chrome/browser/autofill/autocomplete_history_manager.h" | 23 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
23 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 24 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
24 #include "chrome/browser/autofill/autofill_external_delegate.h" | 25 #include "chrome/browser/autofill/autofill_external_delegate.h" |
25 #include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h" | 26 #include "chrome/browser/autofill/autofill_feedback_infobar_delegate.h" |
26 #include "chrome/browser/autofill/autofill_field.h" | 27 #include "chrome/browser/autofill/autofill_field.h" |
27 #include "chrome/browser/autofill/autofill_metrics.h" | 28 #include "chrome/browser/autofill/autofill_metrics.h" |
28 #include "chrome/browser/autofill/autofill_profile.h" | 29 #include "chrome/browser/autofill/autofill_profile.h" |
29 #include "chrome/browser/autofill/autofill_type.h" | 30 #include "chrome/browser/autofill/autofill_type.h" |
30 #include "chrome/browser/autofill/credit_card.h" | 31 #include "chrome/browser/autofill/credit_card.h" |
31 #include "chrome/browser/autofill/form_structure.h" | 32 #include "chrome/browser/autofill/form_structure.h" |
32 #include "chrome/browser/autofill/password_generator.h" | 33 #include "chrome/browser/autofill/password_generator.h" |
33 #include "chrome/browser/autofill/personal_data_manager.h" | 34 #include "chrome/browser/autofill/personal_data_manager.h" |
34 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 35 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
35 #include "chrome/browser/autofill/phone_number.h" | 36 #include "chrome/browser/autofill/phone_number.h" |
36 #include "chrome/browser/autofill/phone_number_i18n.h" | 37 #include "chrome/browser/autofill/phone_number_i18n.h" |
37 #include "chrome/browser/autofill/select_control_handler.h" | 38 #include "chrome/browser/autofill/select_control_handler.h" |
38 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
39 #include "chrome/browser/password_manager/password_manager.h" | 39 #include "chrome/browser/password_manager/password_manager.h" |
40 #include "chrome/browser/prefs/pref_service.h" | 40 #include "chrome/browser/prefs/pref_service.h" |
41 #include "chrome/browser/profiles/profile.h" | 41 #include "chrome/browser/profiles/profile.h" |
42 #include "chrome/browser/sync/profile_sync_service.h" | 42 #include "chrome/browser/sync/profile_sync_service.h" |
43 #include "chrome/browser/sync/profile_sync_service_factory.h" | 43 #include "chrome/browser/sync/profile_sync_service_factory.h" |
44 #include "chrome/browser/ui/browser.h" | 44 #include "chrome/browser/ui/browser.h" |
45 #include "chrome/browser/ui/browser_finder.h" | 45 #include "chrome/browser/ui/browser_finder.h" |
46 #include "chrome/browser/ui/browser_window.h" | 46 #include "chrome/browser/ui/browser_window.h" |
47 #include "chrome/browser/ui/chrome_pages.h" | 47 #include "chrome/browser/ui/chrome_pages.h" |
48 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 48 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 | 837 |
838 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { | 838 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { |
839 const CreditCard* imported_credit_card; | 839 const CreditCard* imported_credit_card; |
840 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) | 840 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) |
841 return; | 841 return; |
842 | 842 |
843 // If credit card information was submitted, show an infobar to offer to save | 843 // If credit card information was submitted, show an infobar to offer to save |
844 // it. | 844 // it. |
845 scoped_ptr<const CreditCard> scoped_credit_card(imported_credit_card); | 845 scoped_ptr<const CreditCard> scoped_credit_card(imported_credit_card); |
846 if (imported_credit_card && web_contents()) { | 846 if (imported_credit_card && web_contents()) { |
847 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); | 847 InfoBarTabService* infobar_service = |
848 infobar_helper->AddInfoBar( | 848 InfoBarTabService::ForTab(tab_contents_); |
849 new AutofillCCInfoBarDelegate(infobar_helper, | 849 infobar_service->AddInfoBar( |
| 850 new AutofillCCInfoBarDelegate(infobar_service, |
850 scoped_credit_card.release(), | 851 scoped_credit_card.release(), |
851 personal_data_, | 852 personal_data_, |
852 metric_logger_.get())); | 853 metric_logger_.get())); |
853 } | 854 } |
854 } | 855 } |
855 | 856 |
856 // Note that |submitted_form| is passed as a pointer rather than as a reference | 857 // Note that |submitted_form| is passed as a pointer rather than as a reference |
857 // so that we can get memory management right across threads. Note also that we | 858 // so that we can get memory management right across threads. Note also that we |
858 // explicitly pass in all the time stamps of interest, as the cached ones might | 859 // explicitly pass in all the time stamps of interest, as the cached ones might |
859 // get reset before this method executes. | 860 // get reset before this method executes. |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 *profile_guid = IDToGUID(profile_id); | 1412 *profile_guid = IDToGUID(profile_id); |
1412 } | 1413 } |
1413 | 1414 |
1414 void AutofillManager::UpdateInitialInteractionTimestamp( | 1415 void AutofillManager::UpdateInitialInteractionTimestamp( |
1415 const TimeTicks& interaction_timestamp) { | 1416 const TimeTicks& interaction_timestamp) { |
1416 if (initial_interaction_timestamp_.is_null() || | 1417 if (initial_interaction_timestamp_.is_null() || |
1417 interaction_timestamp < initial_interaction_timestamp_) { | 1418 interaction_timestamp < initial_interaction_timestamp_) { |
1418 initial_interaction_timestamp_ = interaction_timestamp; | 1419 initial_interaction_timestamp_ = interaction_timestamp; |
1419 } | 1420 } |
1420 } | 1421 } |
OLD | NEW |