| 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 // A client interface that needs to be supplied to the Autofill component by the | 52 // A client interface that needs to be supplied to the Autofill component by the |
| 53 // embedder. | 53 // embedder. |
| 54 // | 54 // |
| 55 // Each client instance is associated with a given context within which an | 55 // Each client instance is associated with a given context within which an |
| 56 // AutofillManager is used (e.g. a single tab), so when we say "for the client" | 56 // AutofillManager is used (e.g. a single tab), so when we say "for the client" |
| 57 // below, we mean "in the execution context the client is associated with" (e.g. | 57 // below, we mean "in the execution context the client is associated with" (e.g. |
| 58 // for the tab the AutofillManager is attached to). | 58 // for the tab the AutofillManager is attached to). |
| 59 class AutofillClient { | 59 class AutofillClient { |
| 60 public: | 60 public: |
| 61 // Copy of blink::WebFormElement::AutocompleteResult. | |
| 62 enum RequestAutocompleteResult { | |
| 63 AutocompleteResultSuccess, | |
| 64 AutocompleteResultErrorDisabled, | |
| 65 AutocompleteResultErrorCancel, | |
| 66 AutocompleteResultErrorInvalid, | |
| 67 }; | |
| 68 | |
| 69 enum PaymentsRpcResult { | 61 enum PaymentsRpcResult { |
| 70 // Empty result. Used for initializing variables and should generally | 62 // Empty result. Used for initializing variables and should generally |
| 71 // not be returned nor passed as arguments unless explicitly allowed by | 63 // not be returned nor passed as arguments unless explicitly allowed by |
| 72 // the API. | 64 // the API. |
| 73 NONE, | 65 NONE, |
| 74 | 66 |
| 75 // Request succeeded. | 67 // Request succeeded. |
| 76 SUCCESS, | 68 SUCCESS, |
| 77 | 69 |
| 78 // Request failed; try again. | 70 // Request failed; try again. |
| 79 TRY_AGAIN_FAILURE, | 71 TRY_AGAIN_FAILURE, |
| 80 | 72 |
| 81 // Request failed; don't try again. | 73 // Request failed; don't try again. |
| 82 PERMANENT_FAILURE, | 74 PERMANENT_FAILURE, |
| 83 | 75 |
| 84 // Unable to connect to Payments servers. Prompt user to check internet | 76 // Unable to connect to Payments servers. Prompt user to check internet |
| 85 // connection. | 77 // connection. |
| 86 NETWORK_ERROR, | 78 NETWORK_ERROR, |
| 87 }; | 79 }; |
| 88 | 80 |
| 89 enum UnmaskCardReason { | 81 enum UnmaskCardReason { |
| 90 // The card is being unmasked for PaymentRequest. | 82 // The card is being unmasked for PaymentRequest. |
| 91 UNMASK_FOR_PAYMENT_REQUEST, | 83 UNMASK_FOR_PAYMENT_REQUEST, |
| 92 | 84 |
| 93 // The card is being unmasked for Autofill. | 85 // The card is being unmasked for Autofill. |
| 94 UNMASK_FOR_AUTOFILL, | 86 UNMASK_FOR_AUTOFILL, |
| 95 }; | 87 }; |
| 96 | 88 |
| 97 typedef base::Callback<void(RequestAutocompleteResult, | |
| 98 const base::string16&, | |
| 99 const FormStructure*)> ResultCallback; | |
| 100 | |
| 101 typedef base::Callback<void(const base::string16& /* card number */, | 89 typedef base::Callback<void(const base::string16& /* card number */, |
| 102 int /* exp month */, | 90 int /* exp month */, |
| 103 int /* exp year */)> CreditCardScanCallback; | 91 int /* exp year */)> CreditCardScanCallback; |
| 104 | 92 |
| 105 virtual ~AutofillClient() {} | 93 virtual ~AutofillClient() {} |
| 106 | 94 |
| 107 // Gets the PersonalDataManager instance associated with the client. | 95 // Gets the PersonalDataManager instance associated with the client. |
| 108 virtual PersonalDataManager* GetPersonalDataManager() = 0; | 96 virtual PersonalDataManager* GetPersonalDataManager() = 0; |
| 109 | 97 |
| 110 // Gets the AutofillWebDataService instance associated with the client. | 98 // Gets the AutofillWebDataService instance associated with the client. |
| 111 virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; | 99 virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0; |
| 112 | 100 |
| 113 // Gets the preferences associated with the client. | 101 // Gets the preferences associated with the client. |
| 114 virtual PrefService* GetPrefs() = 0; | 102 virtual PrefService* GetPrefs() = 0; |
| 115 | 103 |
| 116 // Gets the sync service associated with the client. | 104 // Gets the sync service associated with the client. |
| 117 virtual sync_driver::SyncService* GetSyncService() = 0; | 105 virtual sync_driver::SyncService* GetSyncService() = 0; |
| 118 | 106 |
| 119 // Gets the IdentityProvider associated with the client (for OAuth2). | 107 // Gets the IdentityProvider associated with the client (for OAuth2). |
| 120 virtual IdentityProvider* GetIdentityProvider() = 0; | 108 virtual IdentityProvider* GetIdentityProvider() = 0; |
| 121 | 109 |
| 122 // Gets the RapporService associated with the client (for metrics). | 110 // Gets the RapporService associated with the client (for metrics). |
| 123 virtual rappor::RapporService* GetRapporService() = 0; | 111 virtual rappor::RapporService* GetRapporService() = 0; |
| 124 | 112 |
| 125 // Hides the associated request autocomplete dialog (if it exists). | |
| 126 virtual void HideRequestAutocompleteDialog() = 0; | |
| 127 | |
| 128 // Causes the Autofill settings UI to be shown. | 113 // Causes the Autofill settings UI to be shown. |
| 129 virtual void ShowAutofillSettings() = 0; | 114 virtual void ShowAutofillSettings() = 0; |
| 130 | 115 |
| 131 // A user has attempted to use a masked card. Prompt them for further | 116 // A user has attempted to use a masked card. Prompt them for further |
| 132 // information to proceed. | 117 // information to proceed. |
| 133 virtual void ShowUnmaskPrompt(const CreditCard& card, | 118 virtual void ShowUnmaskPrompt(const CreditCard& card, |
| 134 UnmaskCardReason reason, | 119 UnmaskCardReason reason, |
| 135 base::WeakPtr<CardUnmaskDelegate> delegate) = 0; | 120 base::WeakPtr<CardUnmaskDelegate> delegate) = 0; |
| 136 virtual void OnUnmaskVerificationResult(PaymentsRpcResult result) = 0; | 121 virtual void OnUnmaskVerificationResult(PaymentsRpcResult result) = 0; |
| 137 | 122 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 153 | 138 |
| 154 // Returns true if both the platform and the device support scanning credit | 139 // Returns true if both the platform and the device support scanning credit |
| 155 // cards. Should be called before ScanCreditCard(). | 140 // cards. Should be called before ScanCreditCard(). |
| 156 virtual bool HasCreditCardScanFeature() = 0; | 141 virtual bool HasCreditCardScanFeature() = 0; |
| 157 | 142 |
| 158 // Shows the user interface for scanning a credit card. Invokes the |callback| | 143 // Shows the user interface for scanning a credit card. Invokes the |callback| |
| 159 // when a credit card is scanned successfully. Should be called only if | 144 // when a credit card is scanned successfully. Should be called only if |
| 160 // HasCreditCardScanFeature() returns true. | 145 // HasCreditCardScanFeature() returns true. |
| 161 virtual void ScanCreditCard(const CreditCardScanCallback& callback) = 0; | 146 virtual void ScanCreditCard(const CreditCardScanCallback& callback) = 0; |
| 162 | 147 |
| 163 // Causes the dialog for request autocomplete feature to be shown. | |
| 164 virtual void ShowRequestAutocompleteDialog( | |
| 165 const FormData& form, | |
| 166 content::RenderFrameHost* render_frame_host, | |
| 167 const ResultCallback& callback) = 0; | |
| 168 | |
| 169 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and | 148 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and |
| 170 // |identifiers| for the element at |element_bounds|. |delegate| will be | 149 // |identifiers| for the element at |element_bounds|. |delegate| will be |
| 171 // notified of popup events. | 150 // notified of popup events. |
| 172 virtual void ShowAutofillPopup( | 151 virtual void ShowAutofillPopup( |
| 173 const gfx::RectF& element_bounds, | 152 const gfx::RectF& element_bounds, |
| 174 base::i18n::TextDirection text_direction, | 153 base::i18n::TextDirection text_direction, |
| 175 const std::vector<Suggestion>& suggestions, | 154 const std::vector<Suggestion>& suggestions, |
| 176 base::WeakPtr<AutofillPopupDelegate> delegate) = 0; | 155 base::WeakPtr<AutofillPopupDelegate> delegate) = 0; |
| 177 | 156 |
| 178 // Update the data list values shown by the Autofill popup, if visible. | 157 // Update the data list values shown by the Autofill popup, if visible. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 200 // Informs the client that a user gesture has been observed. | 179 // Informs the client that a user gesture has been observed. |
| 201 virtual void OnFirstUserGestureObserved() = 0; | 180 virtual void OnFirstUserGestureObserved() = 0; |
| 202 | 181 |
| 203 // If the context is secure. | 182 // If the context is secure. |
| 204 virtual bool IsContextSecure(const GURL& form_origin) = 0; | 183 virtual bool IsContextSecure(const GURL& form_origin) = 0; |
| 205 }; | 184 }; |
| 206 | 185 |
| 207 } // namespace autofill | 186 } // namespace autofill |
| 208 | 187 |
| 209 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ | 188 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CLIENT_H_ |
| OLD | NEW |