Index: components/autofill/core/browser/full_card_request.h |
diff --git a/components/autofill/core/browser/full_card_request.h b/components/autofill/core/browser/full_card_request.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1ae69d4cc703557f4dcecb24f73faa6c9655ae07 |
--- /dev/null |
+++ b/components/autofill/core/browser/full_card_request.h |
@@ -0,0 +1,88 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FULL_CARD_REQUEST_H_ |
Mathieu
2016/04/22 17:58:35
should it be under core/browser/payments (alongsid
please use gerrit instead
2016/04/22 20:50:18
Done.
|
+#define COMPONENTS_AUTOFILL_CORE_BROWSER_FULL_CARD_REQUEST_H_ |
+ |
+#include <memory> |
+#include <string> |
+ |
+#include "base/macros.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/strings/string16.h" |
+#include "base/time/time.h" |
+#include "components/autofill/core/browser/card_unmask_delegate.h" |
+#include "components/autofill/core/browser/payments/payments_client.h" |
+ |
+namespace net { |
+class URLRequestContextGetter; |
+} |
+ |
+namespace autofill { |
+ |
+class AutofillClient; |
+class CreditCard; |
+class PersonalDataManager; |
+ |
+// Retrieves the full card details, including the pan and the cvc. |
+class FullCardRequest : public CardUnmaskDelegate, |
+ public payments::PaymentsClientDelegate { |
+ public: |
+ // The interface for receiving the full card details. |
+ class Delegate { |
+ public: |
+ virtual void OnFullCardDetails(const CreditCard& card, |
+ const base::string16& cvc) = 0; |
+ virtual void OnFullCardError() = 0; |
+ }; |
+ |
+ // The parameters should outlive the FullCardRequest. |
+ FullCardRequest(net::URLRequestContextGetter* url_getter, |
+ AutofillClient* autofill_client, |
+ PersonalDataManager* personal_data_manager); |
+ ~FullCardRequest(); |
+ |
+ // Retrieves the pan and cvc for |card| and invokes |
+ // Delegate::OnFullCardDetails() or Delegate::OnFullCardError(). Only one |
+ // request should be active at a time. |
+ void GetFullCard(const CreditCard& card, |
+ AutofillClient::UnmaskCardReason reason, |
+ base::WeakPtr<Delegate> delegate); |
+ |
+ // Returns true if there's a pending request to get the full card. |
+ bool IsGettingFullCard() const; |
+ |
+ private: |
+ void OnDidGetUnmaskRiskData(const std::string& risk_data); |
+ |
+ // CardUnmaskDelegate: |
+ void OnUnmaskResponse(const UnmaskResponse& response) override; |
+ void OnUnmaskPromptClosed() override; |
+ |
+ // Used payments::PaymentsClientDelegate methods: |
+ IdentityProvider* GetIdentityProvider() override; |
+ void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, |
+ const std::string& real_pan) override; |
+ |
+ // Unused payments::PaymentsClientDelegate methods: |
+ void OnDidGetUploadDetails( |
+ AutofillClient::PaymentsRpcResult result, |
+ const base::string16& context_token, |
+ std::unique_ptr<base::DictionaryValue> legal_message) override; |
+ void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) override; |
+ |
+ AutofillClient* const autofill_client_; |
+ PersonalDataManager* const personal_data_manager_; |
+ base::WeakPtr<Delegate> delegate_; |
+ payments::PaymentsClient payments_client_; |
+ std::unique_ptr<payments::PaymentsClient::UnmaskRequestDetails> request_; |
+ base::Time real_pan_request_timestamp_; |
+ base::WeakPtrFactory<FullCardRequest> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FullCardRequest); |
+}; |
+ |
+} // namespace autofill |
+ |
+#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FULL_CARD_REQUEST_H_ |