blob: 2125e0790118f3586d9129e664030388b709f7dc [file] [log] [blame]
[email protected]e053d822013-01-29 20:48:281// Copyright (c) 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
[email protected]e4b2fa32013-03-09 22:56:565#ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_
6#define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_
[email protected]e053d822013-01-29 20:48:287
8#include <string>
9
10#include "base/memory/scoped_ptr.h"
[email protected]300d8152013-03-14 18:23:2311#include "components/autofill/browser/autofill_manager_delegate.h"
[email protected]56cb9ea2013-03-16 05:15:1812#include "components/autofill/browser/wallet/wallet_client.h"
[email protected]300d8152013-03-14 18:23:2313
14class AutofillMetrics;
[email protected]e053d822013-01-29 20:48:2815
[email protected]345175642013-02-20 19:25:5216namespace autofill {
[email protected]e053d822013-01-29 20:48:2817namespace wallet {
18
19class FullWallet;
20class WalletItems;
21
[email protected]300d8152013-03-14 18:23:2322// WalletClientDelegate is to be implemented any classes making calls with
[email protected]e053d822013-01-29 20:48:2823// WalletClient. The appropriate callback method will be called on
[email protected]300d8152013-03-14 18:23:2324// WalletClientDelegate with the response from the Online Wallet backend.
25class WalletClientDelegate {
[email protected]e053d822013-01-29 20:48:2826 public:
[email protected]300d8152013-03-14 18:23:2327 // --------------------------------------
28 // Accessors called when making requests.
29 // --------------------------------------
30
31 // Returns the MetricLogger instance that should be used for logging Online
32 // Wallet metrics.
33 virtual const AutofillMetrics& GetMetricLogger() const = 0;
34
35 // Returns the dialog type that the delegate corresponds to.
36 virtual DialogType GetDialogType() const = 0;
37
[email protected]e3f108e2013-03-23 22:58:0338 // Returns the serialized fingerprint data to be sent to the Risk server.
39 virtual std::string GetRiskData() const = 0;
40
[email protected]300d8152013-03-14 18:23:2341 // --------------------------------------------------------------------------
42 // Callbacks called with responses from the Online Wallet backend.
43 // --------------------------------------------------------------------------
44
[email protected]e053d822013-01-29 20:48:2845 // Called when an AcceptLegalDocuments request finishes successfully.
46 virtual void OnDidAcceptLegalDocuments() = 0;
47
[email protected]f7264ec32013-02-21 05:29:2948 // Called when an AuthenticateInstrument request finishes successfully.
49 virtual void OnDidAuthenticateInstrument(bool success) = 0;
50
[email protected]e053d822013-01-29 20:48:2851 // Called when a GetFullWallet request finishes successfully. Ownership is
52 // transferred to implementer of this interface.
53 virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) = 0;
54
55 // Called when a GetWalletItems request finishes successfully. Ownership is
56 // transferred to implementer of this interface.
57 virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) = 0;
58
59 // Called when a SaveAddress request finishes successfully. |address_id| can
[email protected]860c5212013-02-28 03:50:4860 // be used in subsequent GetFullWallet calls. |required_actions| is populated
61 // if there was a validation error with the data being saved.
62 virtual void OnDidSaveAddress(
63 const std::string& address_id,
64 const std::vector<RequiredAction>& required_actions) = 0;
[email protected]e053d822013-01-29 20:48:2865
[email protected]860c5212013-02-28 03:50:4866 // Called when a SaveInstrument request finishes sucessfully. |instrument_id|
67 // can be used in subsequent GetFullWallet calls. |required_actions| is
68 // populated if there was a validation error with the data being saved.
69 virtual void OnDidSaveInstrument(
70 const std::string& instrument_id,
71 const std::vector<RequiredAction>& required_actions) = 0;
[email protected]e053d822013-01-29 20:48:2872
73 // Called when a SaveInstrumentAndAddress request finishes succesfully.
74 // |instrument_id| and |address_id| can be used in subsequent
[email protected]860c5212013-02-28 03:50:4875 // GetFullWallet calls. |required_actions| is populated if there was a
76 // validation error with the data being saved.
[email protected]e053d822013-01-29 20:48:2877 virtual void OnDidSaveInstrumentAndAddress(
78 const std::string& instrument_id,
[email protected]860c5212013-02-28 03:50:4879 const std::string& address_id,
80 const std::vector<RequiredAction>& required_actions) = 0;
[email protected]e053d822013-01-29 20:48:2881
[email protected]ffc06592013-03-19 20:24:1082 // Called when an UpdateAddress request finishes successfully.
83 // |required_actions| is populated if there was a validation error with the
84 // data being saved.
85 virtual void OnDidUpdateAddress(
86 const std::string& address_id,
87 const std::vector<RequiredAction>& required_actions) = 0;
88
[email protected]a2f7b972013-02-08 20:02:4689 // Called when an UpdateInstrument request finishes successfully.
[email protected]860c5212013-02-28 03:50:4890 // |required_actions| is populated if there was a validation error with the
91 // data being saved.
92 virtual void OnDidUpdateInstrument(
93 const std::string& instrument_id,
94 const std::vector<RequiredAction>& required_actions) = 0;
[email protected]a2f7b972013-02-08 20:02:4695
[email protected]e053d822013-01-29 20:48:2896 // Called when a request fails due to an Online Wallet error.
[email protected]56cb9ea2013-03-16 05:15:1897 virtual void OnWalletError(WalletClient::ErrorType error_type) = 0;
[email protected]e053d822013-01-29 20:48:2898
99 // Called when a request fails due to a malformed response.
100 virtual void OnMalformedResponse() = 0;
101
102 // Called when a request fails due to a network error.
103 virtual void OnNetworkError(int response_code) = 0;
104
105 protected:
[email protected]300d8152013-03-14 18:23:23106 virtual ~WalletClientDelegate() {}
[email protected]e053d822013-01-29 20:48:28107};
108
109} // namespace wallet
[email protected]345175642013-02-20 19:25:52110} // namespace autofill
[email protected]e053d822013-01-29 20:48:28111
[email protected]e4b2fa32013-03-09 22:56:56112#endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_