[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 1 | // 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] | e4b2fa3 | 2013-03-09 22:56:56 | [diff] [blame] | 5 | #ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_ |
6 | #define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_ | ||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
10 | #include "base/memory/scoped_ptr.h" | ||||
[email protected] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 11 | #include "components/autofill/browser/autofill_manager_delegate.h" |
[email protected] | 56cb9ea | 2013-03-16 05:15:18 | [diff] [blame] | 12 | #include "components/autofill/browser/wallet/wallet_client.h" |
[email protected] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 13 | |
14 | class AutofillMetrics; | ||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 15 | |
[email protected] | 34517564 | 2013-02-20 19:25:52 | [diff] [blame] | 16 | namespace autofill { |
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 17 | namespace wallet { |
18 | |||||
19 | class FullWallet; | ||||
20 | class WalletItems; | ||||
21 | |||||
[email protected] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 22 | // WalletClientDelegate is to be implemented any classes making calls with |
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 23 | // WalletClient. The appropriate callback method will be called on |
[email protected] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 24 | // WalletClientDelegate with the response from the Online Wallet backend. |
25 | class WalletClientDelegate { | ||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 26 | public: |
[email protected] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 27 | // -------------------------------------- |
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] | e3f108e | 2013-03-23 22:58:03 | [diff] [blame] | 38 | // Returns the serialized fingerprint data to be sent to the Risk server. |
39 | virtual std::string GetRiskData() const = 0; | ||||
40 | |||||
[email protected] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 41 | // -------------------------------------------------------------------------- |
42 | // Callbacks called with responses from the Online Wallet backend. | ||||
43 | // -------------------------------------------------------------------------- | ||||
44 | |||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 45 | // Called when an AcceptLegalDocuments request finishes successfully. |
46 | virtual void OnDidAcceptLegalDocuments() = 0; | ||||
47 | |||||
[email protected] | f7264ec3 | 2013-02-21 05:29:29 | [diff] [blame] | 48 | // Called when an AuthenticateInstrument request finishes successfully. |
49 | virtual void OnDidAuthenticateInstrument(bool success) = 0; | ||||
50 | |||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 51 | // 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] | 860c521 | 2013-02-28 03:50:48 | [diff] [blame] | 60 | // 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] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 65 | |
[email protected] | 860c521 | 2013-02-28 03:50:48 | [diff] [blame] | 66 | // 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] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 72 | |
73 | // Called when a SaveInstrumentAndAddress request finishes succesfully. | ||||
74 | // |instrument_id| and |address_id| can be used in subsequent | ||||
[email protected] | 860c521 | 2013-02-28 03:50:48 | [diff] [blame] | 75 | // GetFullWallet calls. |required_actions| is populated if there was a |
76 | // validation error with the data being saved. | ||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 77 | virtual void OnDidSaveInstrumentAndAddress( |
78 | const std::string& instrument_id, | ||||
[email protected] | 860c521 | 2013-02-28 03:50:48 | [diff] [blame] | 79 | const std::string& address_id, |
80 | const std::vector<RequiredAction>& required_actions) = 0; | ||||
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 81 | |
[email protected] | ffc0659 | 2013-03-19 20:24:10 | [diff] [blame] | 82 | // 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] | a2f7b97 | 2013-02-08 20:02:46 | [diff] [blame] | 89 | // Called when an UpdateInstrument request finishes successfully. |
[email protected] | 860c521 | 2013-02-28 03:50:48 | [diff] [blame] | 90 | // |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] | a2f7b97 | 2013-02-08 20:02:46 | [diff] [blame] | 95 | |
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 96 | // Called when a request fails due to an Online Wallet error. |
[email protected] | 56cb9ea | 2013-03-16 05:15:18 | [diff] [blame] | 97 | virtual void OnWalletError(WalletClient::ErrorType error_type) = 0; |
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 98 | |
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] | 300d815 | 2013-03-14 18:23:23 | [diff] [blame] | 106 | virtual ~WalletClientDelegate() {} |
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 107 | }; |
108 | |||||
109 | } // namespace wallet | ||||
[email protected] | 34517564 | 2013-02-20 19:25:52 | [diff] [blame] | 110 | } // namespace autofill |
[email protected] | e053d82 | 2013-01-29 20:48:28 | [diff] [blame] | 111 | |
[email protected] | e4b2fa3 | 2013-03-09 22:56:56 | [diff] [blame] | 112 | #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_ |