summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/android/provider/form_field_data_android.h
blob: ff0879b48b962253e14901aba317df739857415c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_AUTOFILL_ANDROID_PROVIDER_FORM_FIELD_DATA_ANDROID_H_
#define COMPONENTS_AUTOFILL_ANDROID_PROVIDER_FORM_FIELD_DATA_ANDROID_H_

#include "base/android/jni_weak_ref.h"
#include "base/android/scoped_java_ref.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/common/form_field_data.h"

namespace autofill {

// This class is native peer of FormFieldData.java, makes
// autofill::FormFieldData available in Java.
class FormFieldDataAndroid {
 public:
  explicit FormFieldDataAndroid(FormFieldData* field);
  virtual ~FormFieldDataAndroid();

  base::android::ScopedJavaLocalRef<jobject> GetJavaPeer();
  void GetValue();
  void OnFormFieldDidChange(const base::string16& value);
  bool SimilarFieldAs(const FormFieldData& field) const;
  void UpdateAutofillTypes(const AutofillType& heuristic_type,
                           const AutofillType& server_type,
                           const AutofillType& computed_type,
                           const std::vector<AutofillType>& server_predictions);

 private:
  AutofillType heuristic_type_;
  AutofillType server_type_;
  AutofillType computed_type_;
  std::vector<AutofillType> server_predictions_;

  // Not owned.
  FormFieldData* field_ptr_;
  JavaObjectWeakGlobalRef java_ref_;

  DISALLOW_COPY_AND_ASSIGN(FormFieldDataAndroid);
};

}  // namespace autofill

#endif  // COMPONENTS_AUTOFILL_ANDROID_PROVIDER_FORM_FIELD_DATA_ANDROID_H_