Include more file name patterns in the presubmit check for IPC security.
Additionally, rename some files to adhere to the expected naming conventions.
Review-Url: https://codereview.chromium.org/2642973006
Cr-Commit-Position: refs/heads/master@{#445636}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 375351d5..686ae51 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1455,13 +1455,19 @@
Whether or not a file affects IPC is determined by a simple whitelist of
filename patterns."""
file_patterns = [
+ # Legacy IPC:
'*_messages.cc',
'*_messages*.h',
'*_param_traits*.*',
+ # Mojo IPC:
'*.mojom',
'*_struct_traits*.*',
'*_type_converter*.*',
- # Blink uses a different file naming convention
+ '*.typemap',
+ # Android native IPC:
+ '*.aidl',
+ # Blink uses a different file naming convention:
+ '*EnumTraits*.*',
'*StructTraits*.*',
'*TypeConverter*.*',
]
diff --git a/ash/public/interfaces/OWNERS b/ash/public/interfaces/OWNERS
index 08850f4..2c44a46 100644
--- a/ash/public/interfaces/OWNERS
+++ b/ash/public/interfaces/OWNERS
@@ -1,2 +1,6 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
+per-file *_struct_traits*.*=set noparent
+per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
+per-file *.typemap=set noparent
+per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/ash/public/interfaces/shelf.typemap b/ash/public/interfaces/shelf.typemap
index 5fd20642..1a85b6e 100644
--- a/ash/public/interfaces/shelf.typemap
+++ b/ash/public/interfaces/shelf.typemap
@@ -4,7 +4,7 @@
mojom = "//ash/public/interfaces/shelf.mojom"
public_headers = [ "//ash/public/cpp/shelf_types.h" ]
-traits_headers = [ "//ash/public/interfaces/shelf_enum_traits.h" ]
+traits_headers = [ "//ash/public/interfaces/shelf_struct_traits.h" ]
public_deps = [
"//ash/public/cpp",
]
diff --git a/ash/public/interfaces/shelf_enum_traits.h b/ash/public/interfaces/shelf_struct_traits.h
similarity index 94%
rename from ash/public/interfaces/shelf_enum_traits.h
rename to ash/public/interfaces/shelf_struct_traits.h
index 4765ab4..50dbdae 100644
--- a/ash/public/interfaces/shelf_enum_traits.h
+++ b/ash/public/interfaces/shelf_struct_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_PUBLIC_INTERFACES_SHELF_ENUM_TRAITS_H_
-#define ASH_PUBLIC_INTERFACES_SHELF_ENUM_TRAITS_H_
+#ifndef ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
+#define ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
#include "ash/public/cpp/shelf_types.h"
#include "ash/public/interfaces/shelf.mojom.h"
@@ -85,4 +85,4 @@
} // namespace mojo
-#endif // ASH_PUBLIC_INTERFACES_SHELF_ENUM_TRAITS_H_
+#endif // ASH_PUBLIC_INTERFACES_SHELF_STRUCT_TRAITS_H_
diff --git a/ash/public/interfaces/wallpaper.typemap b/ash/public/interfaces/wallpaper.typemap
index a8612da7..6b314986 100644
--- a/ash/public/interfaces/wallpaper.typemap
+++ b/ash/public/interfaces/wallpaper.typemap
@@ -4,7 +4,7 @@
mojom = "//ash/public/interfaces/wallpaper.mojom"
public_headers = [ "//components/wallpaper/wallpaper_layout.h" ]
-traits_headers = [ "//ash/public/interfaces/wallpaper_enum_traits.h" ]
+traits_headers = [ "//ash/public/interfaces/wallpaper_struct_traits.h" ]
public_deps = [
"//ash/public/cpp",
]
diff --git a/ash/public/interfaces/wallpaper_enum_traits.h b/ash/public/interfaces/wallpaper_struct_traits.h
similarity index 90%
rename from ash/public/interfaces/wallpaper_enum_traits.h
rename to ash/public/interfaces/wallpaper_struct_traits.h
index 03c15b9..a86779f 100644
--- a/ash/public/interfaces/wallpaper_enum_traits.h
+++ b/ash/public/interfaces/wallpaper_struct_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_PUBLIC_INTERFACES_WALLPAPER_ENUM_TRAITS_H_
-#define ASH_PUBLIC_INTERFACES_WALLPAPER_ENUM_TRAITS_H_
+#ifndef ASH_PUBLIC_INTERFACES_WALLPAPER_STRUCT_TRAITS_H_
+#define ASH_PUBLIC_INTERFACES_WALLPAPER_STRUCT_TRAITS_H_
#include "ash/public/interfaces/wallpaper.mojom.h"
#include "components/wallpaper/wallpaper_layout.h"
@@ -52,4 +52,4 @@
} // namespace mojo
-#endif // ASH_PUBLIC_INTERFACES_WALLPAPER_ENUM_TRAITS_H_
+#endif // ASH_PUBLIC_INTERFACES_WALLPAPER_STRUCT_TRAITS_H_
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
index 4bea97e1..b49e24c 100644
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -90,7 +90,7 @@
"descriptors_android.h",
"ini_parser.cc",
"ini_parser.h",
- "instant_type_traits.h",
+ "instant_struct_traits.h",
"logging_chrome.cc",
"logging_chrome.h",
"mac/app_shim_launch.h",
diff --git a/chrome/common/OWNERS b/chrome/common/OWNERS
index 0154a24..e02099c 100644
--- a/chrome/common/OWNERS
+++ b/chrome/common/OWNERS
@@ -24,6 +24,12 @@
per-file *_type_converter*.*=set noparent
per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
+per-file *_struct_traits*.*=set noparent
+per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
+
+per-file *.typemap=set noparent
+per-file *.typemap=file://ipc/SECURITY_OWNERS
+
# Changes to Mojo interfaces require a security review to avoid
# introducing new sandbox escapes.
per-file *.mojom=set noparent
diff --git a/chrome/common/instant.typemap b/chrome/common/instant.typemap
index 04878d87..eed07806 100644
--- a/chrome/common/instant.typemap
+++ b/chrome/common/instant.typemap
@@ -9,7 +9,7 @@
"//components/ntp_tiles/ntp_tile_source.h",
"//components/omnibox/common/omnibox_focus_state.h",
]
-traits_headers = [ "//chrome/common/instant_type_traits.h" ]
+traits_headers = [ "//chrome/common/instant_struct_traits.h" ]
deps = [
"//chrome/common",
"//ipc",
diff --git a/chrome/common/instant_type_traits.h b/chrome/common/instant_struct_traits.h
similarity index 100%
rename from chrome/common/instant_type_traits.h
rename to chrome/common/instant_struct_traits.h
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 993810f7..51671718 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -12,7 +12,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/common/features.h"
-#include "chrome/common/instant_type_traits.h"
+#include "chrome/common/instant_struct_traits.h"
#include "chrome/common/search/instant_types.h"
#include "chrome/common/search/ntp_logging_events.h"
#include "chrome/common/web_application_info.h"
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn
index 2686a33..2339da0 100644
--- a/content/common/BUILD.gn
+++ b/content/common/BUILD.gn
@@ -134,8 +134,6 @@
"in_process_child_thread_params.cc",
"in_process_child_thread_params.h",
"indexed_db/indexed_db_constants.h",
- "indexed_db/indexed_db_enum_traits.cc",
- "indexed_db/indexed_db_enum_traits.h",
"indexed_db/indexed_db_key.cc",
"indexed_db/indexed_db_key.h",
"indexed_db/indexed_db_key_path.cc",
diff --git a/content/common/indexed_db/OWNERS b/content/common/indexed_db/OWNERS
index d9a1490..801d2601 100644
--- a/content/common/indexed_db/OWNERS
+++ b/content/common/indexed_db/OWNERS
@@ -8,3 +8,5 @@
per-file *_param_traits*.*=file://ipc/SECURITY_OWNERS
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
+per-file *.typemap=set noparent
+per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/content/common/indexed_db/indexed_db.typemap b/content/common/indexed_db/indexed_db.typemap
index f9ff19b..1640ff07 100644
--- a/content/common/indexed_db/indexed_db.typemap
+++ b/content/common/indexed_db/indexed_db.typemap
@@ -10,10 +10,7 @@
"//content/common/indexed_db/indexed_db_metadata.h",
"//third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h",
]
-traits_headers = [
- "//content/common/indexed_db/indexed_db_enum_traits.h",
- "//content/common/indexed_db/indexed_db_struct_traits.h",
-]
+traits_headers = [ "//content/common/indexed_db/indexed_db_struct_traits.h" ]
type_mappings = [
"indexed_db.mojom.CursorDirection=blink::WebIDBCursorDirection",
"indexed_db.mojom.DatabaseMetadata=content::IndexedDBDatabaseMetadata",
diff --git a/content/common/indexed_db/indexed_db_enum_traits.cc b/content/common/indexed_db/indexed_db_enum_traits.cc
deleted file mode 100644
index 54e12b65..0000000
--- a/content/common/indexed_db/indexed_db_enum_traits.cc
+++ /dev/null
@@ -1,219 +0,0 @@
-// 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.
-
-#include "content/common/indexed_db/indexed_db_enum_traits.h"
-
-using indexed_db::mojom::CursorDirection;
-using indexed_db::mojom::DataLoss;
-using indexed_db::mojom::OperationType;
-using indexed_db::mojom::PutMode;
-using indexed_db::mojom::TaskType;
-using indexed_db::mojom::TransactionMode;
-
-namespace mojo {
-
-// static
-CursorDirection
-EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::ToMojom(
- blink::WebIDBCursorDirection input) {
- switch (input) {
- case blink::WebIDBCursorDirectionNext:
- return CursorDirection::Next;
- case blink::WebIDBCursorDirectionNextNoDuplicate:
- return CursorDirection::NextNoDuplicate;
- case blink::WebIDBCursorDirectionPrev:
- return CursorDirection::Prev;
- case blink::WebIDBCursorDirectionPrevNoDuplicate:
- return CursorDirection::PrevNoDuplicate;
- }
- NOTREACHED();
- return CursorDirection::Next;
-}
-
-// static
-bool EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::FromMojom(
- CursorDirection input,
- blink::WebIDBCursorDirection* output) {
- switch (input) {
- case CursorDirection::Next:
- *output = blink::WebIDBCursorDirectionNext;
- return true;
- case CursorDirection::NextNoDuplicate:
- *output = blink::WebIDBCursorDirectionNextNoDuplicate;
- return true;
- case CursorDirection::Prev:
- *output = blink::WebIDBCursorDirectionPrev;
- return true;
- case CursorDirection::PrevNoDuplicate:
- *output = blink::WebIDBCursorDirectionPrevNoDuplicate;
- return true;
- }
- return false;
-}
-
-// static
-DataLoss EnumTraits<DataLoss, blink::WebIDBDataLoss>::ToMojom(
- blink::WebIDBDataLoss input) {
- switch (input) {
- case blink::WebIDBDataLossNone:
- return DataLoss::None;
- case blink::WebIDBDataLossTotal:
- return DataLoss::Total;
- }
- NOTREACHED();
- return DataLoss::None;
-}
-
-// static
-bool EnumTraits<DataLoss, blink::WebIDBDataLoss>::FromMojom(
- DataLoss input,
- blink::WebIDBDataLoss* output) {
- switch (input) {
- case DataLoss::None:
- *output = blink::WebIDBDataLossNone;
- return true;
- case DataLoss::Total:
- *output = blink::WebIDBDataLossTotal;
- return true;
- }
- return false;
-}
-
-// static
-OperationType EnumTraits<OperationType, blink::WebIDBOperationType>::ToMojom(
- blink::WebIDBOperationType input) {
- switch (input) {
- case blink::WebIDBAdd:
- return OperationType::Add;
- case blink::WebIDBPut:
- return OperationType::Put;
- case blink::WebIDBDelete:
- return OperationType::Delete;
- case blink::WebIDBClear:
- return OperationType::Clear;
- case blink::WebIDBOperationTypeCount:
- // WebIDBOperationTypeCount is not a valid option.
- break;
- }
- NOTREACHED();
- return OperationType::Add;
-}
-
-// static
-bool EnumTraits<OperationType, blink::WebIDBOperationType>::FromMojom(
- OperationType input,
- blink::WebIDBOperationType* output) {
- switch (input) {
- case OperationType::Add:
- *output = blink::WebIDBAdd;
- return true;
- case OperationType::Put:
- *output = blink::WebIDBPut;
- return true;
- case OperationType::Delete:
- *output = blink::WebIDBDelete;
- return true;
- case OperationType::Clear:
- *output = blink::WebIDBClear;
- return true;
- }
- return false;
-}
-
-// static
-PutMode EnumTraits<PutMode, blink::WebIDBPutMode>::ToMojom(
- blink::WebIDBPutMode input) {
- switch (input) {
- case blink::WebIDBPutModeAddOrUpdate:
- return PutMode::AddOrUpdate;
- case blink::WebIDBPutModeAddOnly:
- return PutMode::AddOnly;
- case blink::WebIDBPutModeCursorUpdate:
- return PutMode::CursorUpdate;
- }
- NOTREACHED();
- return PutMode::AddOrUpdate;
-}
-
-// static
-bool EnumTraits<PutMode, blink::WebIDBPutMode>::FromMojom(
- PutMode input,
- blink::WebIDBPutMode* output) {
- switch (input) {
- case PutMode::AddOrUpdate:
- *output = blink::WebIDBPutModeAddOrUpdate;
- return true;
- case PutMode::AddOnly:
- *output = blink::WebIDBPutModeAddOnly;
- return true;
- case PutMode::CursorUpdate:
- *output = blink::WebIDBPutModeCursorUpdate;
- return true;
- }
- return false;
-}
-
-// static
-TaskType EnumTraits<TaskType, blink::WebIDBTaskType>::ToMojom(
- blink::WebIDBTaskType input) {
- switch (input) {
- case blink::WebIDBTaskTypeNormal:
- return TaskType::Normal;
- case blink::WebIDBTaskTypePreemptive:
- return TaskType::Preemptive;
- }
- NOTREACHED();
- return TaskType::Normal;
-}
-
-// static
-bool EnumTraits<TaskType, blink::WebIDBTaskType>::FromMojom(
- TaskType input,
- blink::WebIDBTaskType* output) {
- switch (input) {
- case TaskType::Normal:
- *output = blink::WebIDBTaskTypeNormal;
- return true;
- case TaskType::Preemptive:
- *output = blink::WebIDBTaskTypePreemptive;
- return true;
- }
- return false;
-}
-
-// static
-TransactionMode
-EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::ToMojom(
- blink::WebIDBTransactionMode input) {
- switch (input) {
- case blink::WebIDBTransactionModeReadOnly:
- return TransactionMode::ReadOnly;
- case blink::WebIDBTransactionModeReadWrite:
- return TransactionMode::ReadWrite;
- case blink::WebIDBTransactionModeVersionChange:
- return TransactionMode::VersionChange;
- }
- NOTREACHED();
- return TransactionMode::ReadOnly;
-}
-
-// static
-bool EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::FromMojom(
- TransactionMode input,
- blink::WebIDBTransactionMode* output) {
- switch (input) {
- case TransactionMode::ReadOnly:
- *output = blink::WebIDBTransactionModeReadOnly;
- return true;
- case TransactionMode::ReadWrite:
- *output = blink::WebIDBTransactionModeReadWrite;
- return true;
- case TransactionMode::VersionChange:
- *output = blink::WebIDBTransactionModeVersionChange;
- return true;
- }
- return false;
-}
-
-} // namespace mojo
diff --git a/content/common/indexed_db/indexed_db_enum_traits.h b/content/common/indexed_db/indexed_db_enum_traits.h
deleted file mode 100644
index d367b32..0000000
--- a/content/common/indexed_db/indexed_db_enum_traits.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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 CONTENT_COMMON_INDEXED_DB_INDEXED_DB_ENUM_TRAITS_H_
-#define CONTENT_COMMON_INDEXED_DB_INDEXED_DB_ENUM_TRAITS_H_
-
-#include "content/common/indexed_db/indexed_db.mojom.h"
-#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
-
-namespace mojo {
-
-template <>
-struct EnumTraits<indexed_db::mojom::CursorDirection,
- blink::WebIDBCursorDirection> {
- static indexed_db::mojom::CursorDirection ToMojom(
- blink::WebIDBCursorDirection input);
- static bool FromMojom(indexed_db::mojom::CursorDirection input,
- blink::WebIDBCursorDirection* output);
-};
-
-template <>
-struct EnumTraits<indexed_db::mojom::DataLoss, blink::WebIDBDataLoss> {
- static indexed_db::mojom::DataLoss ToMojom(blink::WebIDBDataLoss input);
- static bool FromMojom(indexed_db::mojom::DataLoss input,
- blink::WebIDBDataLoss* output);
-};
-
-template <>
-struct EnumTraits<indexed_db::mojom::OperationType,
- blink::WebIDBOperationType> {
- static indexed_db::mojom::OperationType ToMojom(
- blink::WebIDBOperationType input);
- static bool FromMojom(indexed_db::mojom::OperationType input,
- blink::WebIDBOperationType* output);
-};
-
-template <>
-struct EnumTraits<indexed_db::mojom::PutMode, blink::WebIDBPutMode> {
- static indexed_db::mojom::PutMode ToMojom(blink::WebIDBPutMode input);
- static bool FromMojom(indexed_db::mojom::PutMode input,
- blink::WebIDBPutMode* output);
-};
-
-template <>
-struct EnumTraits<indexed_db::mojom::TaskType, blink::WebIDBTaskType> {
- static indexed_db::mojom::TaskType ToMojom(blink::WebIDBTaskType input);
- static bool FromMojom(indexed_db::mojom::TaskType input,
- blink::WebIDBTaskType* output);
-};
-
-template <>
-struct EnumTraits<indexed_db::mojom::TransactionMode,
- blink::WebIDBTransactionMode> {
- static indexed_db::mojom::TransactionMode ToMojom(
- blink::WebIDBTransactionMode input);
- static bool FromMojom(indexed_db::mojom::TransactionMode input,
- blink::WebIDBTransactionMode* output);
-};
-
-} // namespace mojo
-
-#endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_ENUM_TRAITS_H_
diff --git a/content/common/indexed_db/indexed_db_struct_traits.cc b/content/common/indexed_db/indexed_db_struct_traits.cc
index f9ab3189..ecd1e675 100644
--- a/content/common/indexed_db/indexed_db_struct_traits.cc
+++ b/content/common/indexed_db/indexed_db_struct_traits.cc
@@ -8,6 +8,12 @@
using content::IndexedDBKey;
using content::IndexedDBKeyPath;
using content::IndexedDBKeyRange;
+using indexed_db::mojom::CursorDirection;
+using indexed_db::mojom::DataLoss;
+using indexed_db::mojom::OperationType;
+using indexed_db::mojom::PutMode;
+using indexed_db::mojom::TaskType;
+using indexed_db::mojom::TransactionMode;
namespace mojo {
@@ -237,4 +243,206 @@
return true;
}
+// static
+CursorDirection
+EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::ToMojom(
+ blink::WebIDBCursorDirection input) {
+ switch (input) {
+ case blink::WebIDBCursorDirectionNext:
+ return CursorDirection::Next;
+ case blink::WebIDBCursorDirectionNextNoDuplicate:
+ return CursorDirection::NextNoDuplicate;
+ case blink::WebIDBCursorDirectionPrev:
+ return CursorDirection::Prev;
+ case blink::WebIDBCursorDirectionPrevNoDuplicate:
+ return CursorDirection::PrevNoDuplicate;
+ }
+ NOTREACHED();
+ return CursorDirection::Next;
+}
+
+// static
+bool EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::FromMojom(
+ CursorDirection input,
+ blink::WebIDBCursorDirection* output) {
+ switch (input) {
+ case CursorDirection::Next:
+ *output = blink::WebIDBCursorDirectionNext;
+ return true;
+ case CursorDirection::NextNoDuplicate:
+ *output = blink::WebIDBCursorDirectionNextNoDuplicate;
+ return true;
+ case CursorDirection::Prev:
+ *output = blink::WebIDBCursorDirectionPrev;
+ return true;
+ case CursorDirection::PrevNoDuplicate:
+ *output = blink::WebIDBCursorDirectionPrevNoDuplicate;
+ return true;
+ }
+ return false;
+}
+
+// static
+DataLoss EnumTraits<DataLoss, blink::WebIDBDataLoss>::ToMojom(
+ blink::WebIDBDataLoss input) {
+ switch (input) {
+ case blink::WebIDBDataLossNone:
+ return DataLoss::None;
+ case blink::WebIDBDataLossTotal:
+ return DataLoss::Total;
+ }
+ NOTREACHED();
+ return DataLoss::None;
+}
+
+// static
+bool EnumTraits<DataLoss, blink::WebIDBDataLoss>::FromMojom(
+ DataLoss input,
+ blink::WebIDBDataLoss* output) {
+ switch (input) {
+ case DataLoss::None:
+ *output = blink::WebIDBDataLossNone;
+ return true;
+ case DataLoss::Total:
+ *output = blink::WebIDBDataLossTotal;
+ return true;
+ }
+ return false;
+}
+
+// static
+OperationType EnumTraits<OperationType, blink::WebIDBOperationType>::ToMojom(
+ blink::WebIDBOperationType input) {
+ switch (input) {
+ case blink::WebIDBAdd:
+ return OperationType::Add;
+ case blink::WebIDBPut:
+ return OperationType::Put;
+ case blink::WebIDBDelete:
+ return OperationType::Delete;
+ case blink::WebIDBClear:
+ return OperationType::Clear;
+ case blink::WebIDBOperationTypeCount:
+ // WebIDBOperationTypeCount is not a valid option.
+ break;
+ }
+ NOTREACHED();
+ return OperationType::Add;
+}
+
+// static
+bool EnumTraits<OperationType, blink::WebIDBOperationType>::FromMojom(
+ OperationType input,
+ blink::WebIDBOperationType* output) {
+ switch (input) {
+ case OperationType::Add:
+ *output = blink::WebIDBAdd;
+ return true;
+ case OperationType::Put:
+ *output = blink::WebIDBPut;
+ return true;
+ case OperationType::Delete:
+ *output = blink::WebIDBDelete;
+ return true;
+ case OperationType::Clear:
+ *output = blink::WebIDBClear;
+ return true;
+ }
+ return false;
+}
+
+// static
+PutMode EnumTraits<PutMode, blink::WebIDBPutMode>::ToMojom(
+ blink::WebIDBPutMode input) {
+ switch (input) {
+ case blink::WebIDBPutModeAddOrUpdate:
+ return PutMode::AddOrUpdate;
+ case blink::WebIDBPutModeAddOnly:
+ return PutMode::AddOnly;
+ case blink::WebIDBPutModeCursorUpdate:
+ return PutMode::CursorUpdate;
+ }
+ NOTREACHED();
+ return PutMode::AddOrUpdate;
+}
+
+// static
+bool EnumTraits<PutMode, blink::WebIDBPutMode>::FromMojom(
+ PutMode input,
+ blink::WebIDBPutMode* output) {
+ switch (input) {
+ case PutMode::AddOrUpdate:
+ *output = blink::WebIDBPutModeAddOrUpdate;
+ return true;
+ case PutMode::AddOnly:
+ *output = blink::WebIDBPutModeAddOnly;
+ return true;
+ case PutMode::CursorUpdate:
+ *output = blink::WebIDBPutModeCursorUpdate;
+ return true;
+ }
+ return false;
+}
+
+// static
+TaskType EnumTraits<TaskType, blink::WebIDBTaskType>::ToMojom(
+ blink::WebIDBTaskType input) {
+ switch (input) {
+ case blink::WebIDBTaskTypeNormal:
+ return TaskType::Normal;
+ case blink::WebIDBTaskTypePreemptive:
+ return TaskType::Preemptive;
+ }
+ NOTREACHED();
+ return TaskType::Normal;
+}
+
+// static
+bool EnumTraits<TaskType, blink::WebIDBTaskType>::FromMojom(
+ TaskType input,
+ blink::WebIDBTaskType* output) {
+ switch (input) {
+ case TaskType::Normal:
+ *output = blink::WebIDBTaskTypeNormal;
+ return true;
+ case TaskType::Preemptive:
+ *output = blink::WebIDBTaskTypePreemptive;
+ return true;
+ }
+ return false;
+}
+
+// static
+TransactionMode
+EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::ToMojom(
+ blink::WebIDBTransactionMode input) {
+ switch (input) {
+ case blink::WebIDBTransactionModeReadOnly:
+ return TransactionMode::ReadOnly;
+ case blink::WebIDBTransactionModeReadWrite:
+ return TransactionMode::ReadWrite;
+ case blink::WebIDBTransactionModeVersionChange:
+ return TransactionMode::VersionChange;
+ }
+ NOTREACHED();
+ return TransactionMode::ReadOnly;
+}
+
+// static
+bool EnumTraits<TransactionMode, blink::WebIDBTransactionMode>::FromMojom(
+ TransactionMode input,
+ blink::WebIDBTransactionMode* output) {
+ switch (input) {
+ case TransactionMode::ReadOnly:
+ *output = blink::WebIDBTransactionModeReadOnly;
+ return true;
+ case TransactionMode::ReadWrite:
+ *output = blink::WebIDBTransactionModeReadWrite;
+ return true;
+ case TransactionMode::VersionChange:
+ *output = blink::WebIDBTransactionModeVersionChange;
+ return true;
+ }
+ return false;
+}
} // namespace mojo
diff --git a/content/common/indexed_db/indexed_db_struct_traits.h b/content/common/indexed_db/indexed_db_struct_traits.h
index f69692bbf..913b562 100644
--- a/content/common/indexed_db/indexed_db_struct_traits.h
+++ b/content/common/indexed_db/indexed_db_struct_traits.h
@@ -138,6 +138,54 @@
content::IndexedDBDatabaseMetadata* out);
};
+template <>
+struct EnumTraits<indexed_db::mojom::CursorDirection,
+ blink::WebIDBCursorDirection> {
+ static indexed_db::mojom::CursorDirection ToMojom(
+ blink::WebIDBCursorDirection input);
+ static bool FromMojom(indexed_db::mojom::CursorDirection input,
+ blink::WebIDBCursorDirection* output);
+};
+
+template <>
+struct EnumTraits<indexed_db::mojom::DataLoss, blink::WebIDBDataLoss> {
+ static indexed_db::mojom::DataLoss ToMojom(blink::WebIDBDataLoss input);
+ static bool FromMojom(indexed_db::mojom::DataLoss input,
+ blink::WebIDBDataLoss* output);
+};
+
+template <>
+struct EnumTraits<indexed_db::mojom::OperationType,
+ blink::WebIDBOperationType> {
+ static indexed_db::mojom::OperationType ToMojom(
+ blink::WebIDBOperationType input);
+ static bool FromMojom(indexed_db::mojom::OperationType input,
+ blink::WebIDBOperationType* output);
+};
+
+template <>
+struct EnumTraits<indexed_db::mojom::PutMode, blink::WebIDBPutMode> {
+ static indexed_db::mojom::PutMode ToMojom(blink::WebIDBPutMode input);
+ static bool FromMojom(indexed_db::mojom::PutMode input,
+ blink::WebIDBPutMode* output);
+};
+
+template <>
+struct EnumTraits<indexed_db::mojom::TaskType, blink::WebIDBTaskType> {
+ static indexed_db::mojom::TaskType ToMojom(blink::WebIDBTaskType input);
+ static bool FromMojom(indexed_db::mojom::TaskType input,
+ blink::WebIDBTaskType* output);
+};
+
+template <>
+struct EnumTraits<indexed_db::mojom::TransactionMode,
+ blink::WebIDBTransactionMode> {
+ static indexed_db::mojom::TransactionMode ToMojom(
+ blink::WebIDBTransactionMode input);
+ static bool FromMojom(indexed_db::mojom::TransactionMode input,
+ blink::WebIDBTransactionMode* output);
+};
+
} // namespace mojo
#endif // CONTENT_COMMON_INDEXED_DB_INDEXED_DB_STRUCT_TRAITS_H_
diff --git a/ui/base/mojo/OWNERS b/ui/base/mojo/OWNERS
index 08850f4..2c44a46 100644
--- a/ui/base/mojo/OWNERS
+++ b/ui/base/mojo/OWNERS
@@ -1,2 +1,6 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
+per-file *_struct_traits*.*=set noparent
+per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
+per-file *.typemap=set noparent
+per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/ui/base/mojo/window_open_disposition.typemap b/ui/base/mojo/window_open_disposition.typemap
index 9c4991d..2c770884 100644
--- a/ui/base/mojo/window_open_disposition.typemap
+++ b/ui/base/mojo/window_open_disposition.typemap
@@ -8,5 +8,5 @@
"//mojo/public/cpp/bindings",
"//ui/base",
]
-traits_headers = [ "//ui/base/mojo/window_open_disposition_enum_traits.h" ]
+traits_headers = [ "//ui/base/mojo/window_open_disposition_struct_traits.h" ]
type_mappings = [ "ui.mojom.WindowOpenDisposition=WindowOpenDisposition" ]
diff --git a/ui/base/mojo/window_open_disposition_enum_traits.h b/ui/base/mojo/window_open_disposition_struct_traits.h
similarity index 94%
rename from ui/base/mojo/window_open_disposition_enum_traits.h
rename to ui/base/mojo/window_open_disposition_struct_traits.h
index 8c2f88c..4b90eb23 100644
--- a/ui/base/mojo/window_open_disposition_enum_traits.h
+++ b/ui/base/mojo/window_open_disposition_struct_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_BASE_MOJO_WINDOW_OPEN_DISPOSITION_ENUM_TRAITS_H_
-#define UI_BASE_MOJO_WINDOW_OPEN_DISPOSITION_ENUM_TRAITS_H_
+#ifndef UI_BASE_MOJO_WINDOW_OPEN_DISPOSITION_STRUCT_TRAITS_H_
+#define UI_BASE_MOJO_WINDOW_OPEN_DISPOSITION_STRUCT_TRAITS_H_
#include "base/logging.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
@@ -85,4 +85,4 @@
} // namespace mojo
-#endif // UI_BASE_MOJO_WINDOW_OPEN_DISPOSITION_ENUM_TRAITS_H_
+#endif // UI_BASE_MOJO_WINDOW_OPEN_DISPOSITION_STRUCT_TRAITS_H_