Make |track_| in MediaStreamTrack const. and a couple of other cosmetic changes.
[chromium-blink-merge.git] / components / autofill / content / browser / wallet / form_field_error.h
blob60df6d941486d6d6ffed3599b7a3366a5f29e7ce
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.
5 #ifndef COMPONENTS_AUTOFILL_BROWSER_WALLET_FORM_FIELD_ERROR_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_WALLET_FORM_FIELD_ERROR_H_
8 #include "base/strings/string16.h"
9 #include "components/autofill/core/browser/field_types.h"
11 namespace base {
12 class DictionaryValue;
15 namespace autofill {
16 namespace wallet {
18 // Class for representing a single Wallet server side validation error.
19 class FormFieldError {
20 public:
21 // The validation error returned from the server.
22 enum ErrorType {
23 UNKNOWN_ERROR,
24 INVALID_PHONE_NUMBER,
25 INVALID_POSTAL_CODE,
26 // Bad street address.
27 INVALID_ADDRESS,
28 // Bad CVC.
29 INVALID_CARD_DETAILS,
30 // Wallet sends this when ZIP is invalid for the given city.
31 INVALID_CITY,
32 // Catch-all for many errors. E.g., no address given, no address ID,
33 // invalid card number. Wallet should only send us this error for invalid
34 // card number.
35 INVALID_INSTRUMENT,
36 // Wallet sends this when ZIP is invalid for the given state.
37 INVALID_STATE,
38 REQUIRED_FIELD_NOT_SET,
39 // TODO(ahutter): Add INVALID_COUNTRY when user can select country in the
40 // chooser.
43 // The section of the "form" where the error occurred.
44 enum Location {
45 UNKNOWN_LOCATION,
46 PAYMENT_INSTRUMENT,
47 SHIPPING_ADDRESS,
48 // Currently Sugar uses the billing address as user's legal address. So any
49 // error in billing address will be accompanied by an error in legal
50 // address. The client side should map LEGAL_ADDRESS to the billing address.
51 // This will ensure compatibility in case Sugar starts having a separate
52 // legal address form.
53 LEGAL_ADDRESS,
56 FormFieldError(ErrorType error_type, Location location);
57 ~FormFieldError();
59 ErrorType error_type() const { return error_type_; }
60 Location location() const { return location_; }
62 // Gets the appropriate field type for |location| and |error_type|.
63 ServerFieldType GetAutofillType() const;
65 // Gets a user facing error message appropriate for |location| and
66 // |error_type|.
67 base::string16 GetErrorMessage() const;
69 // Creates an instance of FormFieldError from the input dictionary.
70 static FormFieldError CreateFormFieldError(
71 const base::DictionaryValue& dictionary);
73 bool operator==(const FormFieldError& other) const;
75 private:
76 // The type of error as defined by the Wallet server.
77 ErrorType error_type_;
79 // The location of the error as defined by the Wallet server.
80 Location location_;
82 // This class is intentionally copyable and assignable.
85 } // namespace wallet
86 } // namespace autofill
88 #endif // COMPONENTS_AUTOFILL_BROWSER_WALLET_FORM_FIELD_ERROR_H_