Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: components/autofill/content/public/cpp/autofill_types_struct_traits.h

Issue 1999623002: [Autofill] Add typemap for autofill:FormFieldData and autofill::FormData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/public/cpp/autofill_types_struct_traits.h
diff --git a/components/autofill/content/public/cpp/autofill_types_struct_traits.h b/components/autofill/content/public/cpp/autofill_types_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d0c37bbb48a59d7f2cdea888b63f3e72e36c6f5
--- /dev/null
+++ b/components/autofill/content/public/cpp/autofill_types_struct_traits.h
@@ -0,0 +1,117 @@
+// Copyright 2016 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_CONTENT_PUBLIC_INTERFACES_AUTOFILL_TYPES_STRUCT_TRAITS_H_
+#define COMPONENTS_AUTOFILL_CONTENT_PUBLIC_INTERFACES_AUTOFILL_TYPES_STRUCT_TRAITS_H_
+
+#include "base/strings/string16.h"
+#include "components/autofill/content/public/interfaces/autofill_types.mojom.h"
+#include "components/autofill/core/common/form_data.h"
+#include "components/autofill/core/common/form_field_data.h"
+#include "mojo/public/cpp/bindings/struct_traits.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<autofill::mojom::FormFieldData, autofill::FormFieldData> {
+ static const base::string16& label(const autofill::FormFieldData& r) {
+ return r.label;
+ }
+
+ static const base::string16& name(const autofill::FormFieldData& r) {
+ return r.name;
+ }
+
+ static const base::string16& value(const autofill::FormFieldData& r) {
+ return r.value;
+ }
+
+ static const std::string& form_control_type(
+ const autofill::FormFieldData& r) {
+ return r.form_control_type;
+ }
+
+ static const std::string& autocomplete_attribute(
+ const autofill::FormFieldData& r) {
+ return r.autocomplete_attribute;
+ }
+
+ static const base::string16& placeholder(const autofill::FormFieldData& r) {
+ return r.placeholder;
+ }
+
+ static uint64_t max_length(const autofill::FormFieldData& r) {
+ return r.max_length;
+ }
+
+ static bool is_autofilled(const autofill::FormFieldData& r) {
+ return r.is_autofilled;
+ }
+
+ static bool is_checked(const autofill::FormFieldData& r) {
+ return r.is_checked;
+ }
+
+ static bool is_checkable(const autofill::FormFieldData& r) {
+ return r.is_checkable;
+ }
+
+ static bool is_focusable(const autofill::FormFieldData& r) {
+ return r.is_focusable;
+ }
+
+ static bool should_autocomplete(const autofill::FormFieldData& r) {
+ return r.should_autocomplete;
+ }
+
+ // TODO(leonhsl): return autofill::mojom::RoleAttribute.
+ static int32_t role(const autofill::FormFieldData& r) { return r.role; }
+
+ // TODO(leonhsl): return autofill::mojom::TextDirection.
+ static int32_t text_direction(const autofill::FormFieldData& r) {
+ return r.text_direction;
+ }
+
+ static const std::vector<base::string16>& option_values(
+ const autofill::FormFieldData& r) {
+ return r.option_values;
+ }
+
+ static const std::vector<base::string16>& option_contents(
+ const autofill::FormFieldData& r) {
+ return r.option_contents;
+ }
+
+ static bool Read(autofill::mojom::FormFieldDataDataView data,
+ autofill::FormFieldData* out);
+};
+
+template <>
+struct StructTraits<autofill::mojom::FormData, autofill::FormData> {
+ static const base::string16& name(const autofill::FormData& r) {
+ return r.name;
+ }
+
+ static const GURL& origin(const autofill::FormData& r) { return r.origin; }
+
+ static const GURL& action(const autofill::FormData& r) { return r.action; }
+
+ static bool is_form_tag(const autofill::FormData& r) { return r.is_form_tag; }
+
+ static bool is_formless_checkout(const autofill::FormData& r) {
+ return r.is_formless_checkout;
+ }
+
+ static const std::vector<autofill::FormFieldData>& fields(
+ const autofill::FormData& r) {
+ return r.fields;
+ }
+
+ static bool Read(autofill::mojom::FormDataDataView data,
+ autofill::FormData* out);
+};
+
+} // namespace mojo
+
+#endif // COMPONENTS_AUTOFILL_CONTENT_PUBLIC_INTERFACES_AUTOFILL_TYPES_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698