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 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_ 7 8 #include <string> 9 10 #include "base/memory/scoped_ptr.h" 11 #include "components/autofill/content/browser/wallet/form_field_error.h" 12 #include "components/autofill/content/browser/wallet/wallet_client.h" 13 #include "components/autofill/core/browser/autofill_manager_delegate.h" 14 15 class AutofillMetrics; 16 17 namespace autofill { 18 namespace wallet { 19 20 class FullWallet; 21 class WalletItems; 22 23 // WalletClientDelegate is to be implemented any classes making calls with 24 // WalletClient. The appropriate callback method will be called on 25 // WalletClientDelegate with the response from the Online Wallet backend. 26 class WalletClientDelegate { 27 public: 28 // -------------------------------------- 29 // Accessors called when making requests. 30 // -------------------------------------- 31 32 // Returns the MetricLogger instance that should be used for logging Online 33 // Wallet metrics. 34 virtual const AutofillMetrics& GetMetricLogger() const = 0; 35 36 // Returns the dialog type that the delegate corresponds to. 37 virtual DialogType GetDialogType() const = 0; 38 39 // Returns the serialized fingerprint data to be sent to the Risk server. 40 virtual std::string GetRiskData() const = 0; 41 42 // Returns the cookie value used for authorization when making requests to 43 // Wallet. 44 virtual std::string GetWalletCookieValue() const = 0; 45 46 // Whether or not shipping address is required by the delegate. 47 virtual bool IsShippingAddressRequired() const = 0; 48 49 // -------------------------------------------------------------------------- 50 // Callbacks called with responses from the Online Wallet backend. 51 // -------------------------------------------------------------------------- 52 53 // Called when an AcceptLegalDocuments request finishes successfully. 54 virtual void OnDidAcceptLegalDocuments() = 0; 55 56 // Called when an AuthenticateInstrument request finishes successfully. 57 virtual void OnDidAuthenticateInstrument(bool success) = 0; 58 59 // Called when a GetFullWallet request finishes successfully. Ownership is 60 // transferred to implementer of this interface. 61 virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) = 0; 62 63 // Called when a GetWalletItems request finishes successfully. Ownership is 64 // transferred to implementer of this interface. 65 virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) = 0; 66 67 // Called when a SaveToWallet request finishes succesfully. 68 // |instrument_id| and |address_id| can be used in subsequent 69 // GetFullWallet calls. |required_actions| is populated if there was a 70 // validation error with the data being saved. |form_field_errors| is 71 // populated with the actual form fields that are failing validation. 72 virtual void OnDidSaveToWallet( 73 const std::string& instrument_id, 74 const std::string& address_id, 75 const std::vector<RequiredAction>& required_actions, 76 const std::vector<FormFieldError>& form_field_errors) = 0; 77 78 // Called when a request fails. 79 virtual void OnWalletError(WalletClient::ErrorType error_type) = 0; 80 81 protected: 82 virtual ~WalletClientDelegate() {} 83 }; 84 85 } // namespace wallet 86 } // namespace autofill 87 88 #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_ 89