| 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/card_unmask_prompt_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 unmasking_initial_should_store_pan_(false), | 29 unmasking_initial_should_store_pan_(false), |
| 30 unmasking_number_of_attempts_(0), | 30 unmasking_number_of_attempts_(0), |
| 31 weak_pointer_factory_(this) { | 31 weak_pointer_factory_(this) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 CardUnmaskPromptControllerImpl::~CardUnmaskPromptControllerImpl() { | 34 CardUnmaskPromptControllerImpl::~CardUnmaskPromptControllerImpl() { |
| 35 if (card_unmask_view_) | 35 if (card_unmask_view_) |
| 36 card_unmask_view_->ControllerGone(); | 36 card_unmask_view_->ControllerGone(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 CardUnmaskPromptView* CardUnmaskPromptControllerImpl::CreateAndShowView() { | |
| 40 return CardUnmaskPromptView::CreateAndShow(this); | |
| 41 } | |
| 42 | |
| 43 void CardUnmaskPromptControllerImpl::ShowPrompt( | 39 void CardUnmaskPromptControllerImpl::ShowPrompt( |
| 44 const CreditCard& card, | 40 const CreditCard& card, |
| 45 base::WeakPtr<CardUnmaskDelegate> delegate) { | 41 base::WeakPtr<CardUnmaskDelegate> delegate) { |
| 46 if (card_unmask_view_) | 42 if (card_unmask_view_) |
| 47 card_unmask_view_->ControllerGone(); | 43 card_unmask_view_->ControllerGone(); |
| 48 | 44 |
| 49 pending_response_ = CardUnmaskDelegate::UnmaskResponse(); | 45 pending_response_ = CardUnmaskDelegate::UnmaskResponse(); |
| 50 LoadRiskFingerprint(); | 46 LoadRiskFingerprint(); |
| 51 card_ = card; | 47 card_ = card; |
| 52 delegate_ = delegate; | 48 delegate_ = delegate; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 250 |
| 255 if (year_value < now.year) | 251 if (year_value < now.year) |
| 256 return false; | 252 return false; |
| 257 | 253 |
| 258 if (year_value > now.year) | 254 if (year_value > now.year) |
| 259 return true; | 255 return true; |
| 260 | 256 |
| 261 return month_value >= now.month; | 257 return month_value >= now.month; |
| 262 } | 258 } |
| 263 | 259 |
| 260 base::TimeDelta CardUnmaskPromptControllerImpl::GetSuccessMessageDuration() |
| 261 const { |
| 262 return base::TimeDelta::FromMilliseconds(500); |
| 263 } |
| 264 |
| 265 CardUnmaskPromptView* CardUnmaskPromptControllerImpl::CreateAndShowView() { |
| 266 return CardUnmaskPromptView::CreateAndShow(this); |
| 267 } |
| 268 |
| 264 void CardUnmaskPromptControllerImpl::LoadRiskFingerprint() { | 269 void CardUnmaskPromptControllerImpl::LoadRiskFingerprint() { |
| 265 LoadRiskData( | 270 LoadRiskData( |
| 266 0, web_contents_, | 271 0, web_contents_, |
| 267 base::Bind(&CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint, | 272 base::Bind(&CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint, |
| 268 weak_pointer_factory_.GetWeakPtr())); | 273 weak_pointer_factory_.GetWeakPtr())); |
| 269 } | 274 } |
| 270 | 275 |
| 271 void CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint( | 276 void CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint( |
| 272 const std::string& risk_data) { | 277 const std::string& risk_data) { |
| 273 pending_response_.risk_data = risk_data; | 278 pending_response_.risk_data = risk_data; |
| 274 if (!pending_response_.cvc.empty()) | 279 if (!pending_response_.cvc.empty()) |
| 275 delegate_->OnUnmaskResponse(pending_response_); | 280 delegate_->OnUnmaskResponse(pending_response_); |
| 276 } | 281 } |
| 277 | 282 |
| 278 } // namespace autofill | 283 } // namespace autofill |
| OLD | NEW |