OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "ios/chrome/browser/ui/autofill/autofill_client_ios.h" | 5 #import "ios/chrome/browser/ui/autofill/autofill_client_ios.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
9 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" | 11 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m
obile.h" |
| 12 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" |
10 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" | 13 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" |
11 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
12 #include "components/autofill/core/common/autofill_pref_names.h" | 15 #include "components/autofill/core/common/autofill_pref_names.h" |
| 16 #include "components/infobars/core/infobar.h" |
13 #include "components/infobars/core/infobar_manager.h" | 17 #include "components/infobars/core/infobar_manager.h" |
14 #include "components/keyed_service/core/service_access_type.h" | 18 #include "components/keyed_service/core/service_access_type.h" |
15 #include "components/password_manager/core/browser/password_generation_manager.h
" | 19 #include "components/password_manager/core/browser/password_generation_manager.h
" |
16 #include "google_apis/gaia/identity_provider.h" | 20 #include "google_apis/gaia/identity_provider.h" |
17 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" | 21 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" |
18 #include "ios/chrome/browser/web_data_service_factory.h" | 22 #include "ios/chrome/browser/web_data_service_factory.h" |
19 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" | 23 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.
h" |
20 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 24 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
21 | 25 |
22 namespace autofill { | 26 namespace autofill { |
23 | 27 |
24 AutofillClientIOS::AutofillClientIOS( | 28 AutofillClientIOS::AutofillClientIOS( |
25 ios::ChromeBrowserState* browser_state, | 29 ios::ChromeBrowserState* browser_state, |
26 infobars::InfoBarManager* infobar_manager, | 30 infobars::InfoBarManager* infobar_manager, |
27 id<AutofillClientIOSBridge> bridge, | 31 id<AutofillClientIOSBridge> bridge, |
28 password_manager::PasswordGenerationManager* password_generation_manager, | 32 password_manager::PasswordGenerationManager* password_generation_manager, |
29 scoped_ptr<IdentityProvider> identity_provider) | 33 scoped_ptr<IdentityProvider> identity_provider) |
30 : browser_state_(browser_state), | 34 : browser_state_(browser_state), |
31 infobar_manager_(infobar_manager), | 35 infobar_manager_(infobar_manager), |
32 bridge_(bridge), | 36 bridge_(bridge), |
33 password_generation_manager_(password_generation_manager), | 37 password_generation_manager_(password_generation_manager), |
34 identity_provider_(identity_provider.Pass()), | 38 identity_provider_(std::move(identity_provider)), |
35 unmask_controller_(browser_state->GetPrefs(), | 39 unmask_controller_(browser_state->GetPrefs(), |
36 browser_state->IsOffTheRecord()) {} | 40 browser_state->IsOffTheRecord()) {} |
37 | 41 |
38 AutofillClientIOS::~AutofillClientIOS() { | 42 AutofillClientIOS::~AutofillClientIOS() { |
39 HideAutofillPopup(); | 43 HideAutofillPopup(); |
40 } | 44 } |
41 | 45 |
42 PersonalDataManager* AutofillClientIOS::GetPersonalDataManager() { | 46 PersonalDataManager* AutofillClientIOS::GetPersonalDataManager() { |
43 return PersonalDataManagerFactory::GetForBrowserState( | 47 return PersonalDataManagerFactory::GetForBrowserState( |
44 browser_state_->GetOriginalChromeBrowserState()); | 48 browser_state_->GetOriginalChromeBrowserState()); |
(...skipping 25 matching lines...) Expand all Loading... |
70 unmask_controller_.ShowPrompt( | 74 unmask_controller_.ShowPrompt( |
71 provider->CreateCardUnmaskPromptView(&unmask_controller_), card, | 75 provider->CreateCardUnmaskPromptView(&unmask_controller_), card, |
72 delegate); | 76 delegate); |
73 } | 77 } |
74 | 78 |
75 void AutofillClientIOS::OnUnmaskVerificationResult(PaymentsRpcResult result) { | 79 void AutofillClientIOS::OnUnmaskVerificationResult(PaymentsRpcResult result) { |
76 unmask_controller_.OnVerificationResult(result); | 80 unmask_controller_.OnVerificationResult(result); |
77 } | 81 } |
78 | 82 |
79 void AutofillClientIOS::ConfirmSaveCreditCardLocally( | 83 void AutofillClientIOS::ConfirmSaveCreditCardLocally( |
| 84 const CreditCard& card, |
80 const base::Closure& callback) { | 85 const base::Closure& callback) { |
81 // This method is invoked synchronously from | 86 // This method is invoked synchronously from |
82 // AutofillManager::OnFormSubmitted(); at the time of detecting that a form | 87 // AutofillManager::OnFormSubmitted(); at the time of detecting that a form |
83 // was submitted, the WebContents is guaranteed to be live. Since the | 88 // was submitted, the WebContents is guaranteed to be live. Since the |
84 // InfoBarService is a WebContentsUserData, it must also be alive at this | 89 // InfoBarService is a WebContentsUserData, it must also be alive at this |
85 // time. | 90 // time. |
86 AutofillCCInfoBarDelegate::CreateForLocalSave(infobar_manager_, callback); | 91 infobar_manager_->AddInfoBar(CreateSaveCardInfoBarMobile( |
| 92 make_scoped_ptr(new AutofillSaveCardInfoBarDelegateMobile( |
| 93 false, card, scoped_ptr<base::DictionaryValue>(nullptr), callback)))); |
87 } | 94 } |
88 | 95 |
89 void AutofillClientIOS::ConfirmSaveCreditCardToCloud( | 96 void AutofillClientIOS::ConfirmSaveCreditCardToCloud( |
90 const base::Closure& callback, | 97 const CreditCard& card, |
91 scoped_ptr<base::DictionaryValue> legal_message) { | 98 scoped_ptr<base::DictionaryValue> legal_message, |
92 AutofillCCInfoBarDelegate::CreateForUpload(infobar_manager_, callback); | 99 const base::Closure& callback) { |
| 100 infobar_manager_->AddInfoBar(CreateSaveCardInfoBarMobile( |
| 101 make_scoped_ptr(new AutofillSaveCardInfoBarDelegateMobile( |
| 102 true, card, std::move(legal_message), callback)))); |
93 } | 103 } |
94 | 104 |
95 void AutofillClientIOS::LoadRiskData( | 105 void AutofillClientIOS::LoadRiskData( |
96 const base::Callback<void(const std::string&)>& callback) { | 106 const base::Callback<void(const std::string&)>& callback) { |
97 callback.Run(ios::GetChromeBrowserProvider()->GetRiskData()); | 107 callback.Run(ios::GetChromeBrowserProvider()->GetRiskData()); |
98 } | 108 } |
99 | 109 |
100 bool AutofillClientIOS::HasCreditCardScanFeature() { | 110 bool AutofillClientIOS::HasCreditCardScanFeature() { |
101 return false; | 111 return false; |
102 } | 112 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return form_origin.SchemeIsCryptographic(); | 173 return form_origin.SchemeIsCryptographic(); |
164 } | 174 } |
165 | 175 |
166 void AutofillClientIOS::OnFirstUserGestureObserved() { | 176 void AutofillClientIOS::OnFirstUserGestureObserved() { |
167 // TODO(gcasto): [Merge 306796] http://crbug.com/439425 Verify if this method | 177 // TODO(gcasto): [Merge 306796] http://crbug.com/439425 Verify if this method |
168 // needs a real implementation or not. | 178 // needs a real implementation or not. |
169 NOTIMPLEMENTED(); | 179 NOTIMPLEMENTED(); |
170 } | 180 } |
171 | 181 |
172 } // namespace autofill | 182 } // namespace autofill |
OLD | NEW |