OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/autofill/chrome_autofill_client.h" | 5 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "ui/gfx/geometry/rect.h" | 46 #include "ui/gfx/geometry/rect.h" |
47 | 47 |
48 #if BUILDFLAG(ANDROID_JAVA_UI) | 48 #if BUILDFLAG(ANDROID_JAVA_UI) |
49 #include "chrome/browser/android/chrome_application.h" | 49 #include "chrome/browser/android/chrome_application.h" |
50 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 50 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
51 #else | 51 #else |
52 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 52 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
53 #include "components/ui/zoom/zoom_controller.h" | 53 #include "components/ui/zoom/zoom_controller.h" |
54 #endif | 54 #endif |
55 | 55 |
| 56 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 57 #include "components/autofill/core/browser/autofill_save_card_infobar_delegate_m
obile.h" |
| 58 #include "components/autofill/core/browser/autofill_save_card_infobar_mobile.h" |
| 59 #include "components/infobars/core/infobar.h" |
| 60 #endif |
| 61 |
56 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 62 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
57 | 63 |
58 namespace autofill { | 64 namespace autofill { |
59 | 65 |
60 namespace { | 66 namespace { |
61 | 67 |
62 #if !defined(OS_ANDROID) | 68 #if !defined(OS_ANDROID) |
63 bool IsSaveCardBubbleEnabled() { | 69 bool IsSaveCardBubbleEnabled() { |
64 #if defined(OS_MACOSX) | 70 #if defined(OS_MACOSX) |
65 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 71 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), | 173 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), |
168 card, delegate); | 174 card, delegate); |
169 } | 175 } |
170 | 176 |
171 void ChromeAutofillClient::OnUnmaskVerificationResult( | 177 void ChromeAutofillClient::OnUnmaskVerificationResult( |
172 PaymentsRpcResult result) { | 178 PaymentsRpcResult result) { |
173 unmask_controller_.OnVerificationResult(result); | 179 unmask_controller_.OnVerificationResult(result); |
174 } | 180 } |
175 | 181 |
176 void ChromeAutofillClient::ConfirmSaveCreditCardLocally( | 182 void ChromeAutofillClient::ConfirmSaveCreditCardLocally( |
| 183 const CreditCard& card, |
177 const base::Closure& callback) { | 184 const base::Closure& callback) { |
178 #if !defined(OS_ANDROID) | 185 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 186 InfoBarService::FromWebContents(web_contents())->AddInfoBar( |
| 187 CreateSaveCardInfoBarMobile( |
| 188 make_scoped_ptr(new AutofillSaveCardInfoBarDelegateMobile( |
| 189 false, card, scoped_ptr<base::DictionaryValue>(nullptr), |
| 190 callback)))); |
| 191 #else |
179 if (IsSaveCardBubbleEnabled()) { | 192 if (IsSaveCardBubbleEnabled()) { |
180 // Do lazy initialization of SaveCardBubbleControllerImpl. | 193 // Do lazy initialization of SaveCardBubbleControllerImpl. |
181 autofill::SaveCardBubbleControllerImpl::CreateForWebContents( | 194 autofill::SaveCardBubbleControllerImpl::CreateForWebContents( |
182 web_contents()); | 195 web_contents()); |
183 autofill::SaveCardBubbleControllerImpl* controller = | 196 autofill::SaveCardBubbleControllerImpl* controller = |
184 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); | 197 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); |
185 controller->ShowBubbleForLocalSave(callback); | 198 controller->ShowBubbleForLocalSave(callback); |
186 return; | 199 return; |
187 } | 200 } |
188 #endif | 201 |
189 AutofillCCInfoBarDelegate::CreateForLocalSave( | 202 AutofillCCInfoBarDelegate::CreateForLocalSave( |
190 InfoBarService::FromWebContents(web_contents()), callback); | 203 InfoBarService::FromWebContents(web_contents()), callback); |
| 204 #endif |
191 } | 205 } |
192 | 206 |
193 void ChromeAutofillClient::ConfirmSaveCreditCardToCloud( | 207 void ChromeAutofillClient::ConfirmSaveCreditCardToCloud( |
194 const base::Closure& callback, | 208 const CreditCard& card, |
195 scoped_ptr<base::DictionaryValue> legal_message) { | 209 scoped_ptr<base::DictionaryValue> legal_message, |
196 // TODO(jdonnelly): Implement save card prompt for OS_IOS. | 210 const base::Closure& callback) { |
197 #if defined(OS_ANDROID) | 211 #if defined(OS_ANDROID) || defined(OS_IOS) |
198 AutofillCCInfoBarDelegate::CreateForUpload( | 212 InfoBarService::FromWebContents(web_contents())->AddInfoBar( |
199 InfoBarService::FromWebContents(web_contents()), callback); | 213 CreateSaveCardInfoBarMobile( |
| 214 make_scoped_ptr(new AutofillSaveCardInfoBarDelegateMobile( |
| 215 true, card, std::move(legal_message), callback)))); |
200 #else | 216 #else |
201 // Do lazy initialization of SaveCardBubbleControllerImpl. | 217 // Do lazy initialization of SaveCardBubbleControllerImpl. |
202 autofill::SaveCardBubbleControllerImpl::CreateForWebContents(web_contents()); | 218 autofill::SaveCardBubbleControllerImpl::CreateForWebContents(web_contents()); |
203 autofill::SaveCardBubbleControllerImpl* controller = | 219 autofill::SaveCardBubbleControllerImpl* controller = |
204 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); | 220 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents()); |
205 controller->ShowBubbleForUpload(callback, std::move(legal_message)); | 221 controller->ShowBubbleForUpload(callback, std::move(legal_message)); |
206 #endif | 222 #endif |
207 } | 223 } |
208 | 224 |
209 void ChromeAutofillClient::LoadRiskData( | 225 void ChromeAutofillClient::LoadRiskData( |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 | 375 |
360 ssl_status = navigation_entry->GetSSL(); | 376 ssl_status = navigation_entry->GetSSL(); |
361 // Note: If changing the implementation below, also change | 377 // Note: If changing the implementation below, also change |
362 // AwAutofillClient::IsContextSecure. See crbug.com/505388 | 378 // AwAutofillClient::IsContextSecure. See crbug.com/505388 |
363 return ssl_status.security_style == | 379 return ssl_status.security_style == |
364 content::SECURITY_STYLE_AUTHENTICATED && | 380 content::SECURITY_STYLE_AUTHENTICATED && |
365 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; | 381 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; |
366 } | 382 } |
367 | 383 |
368 } // namespace autofill | 384 } // namespace autofill |
OLD | NEW |