Chromium Code Reviews| Index: ui/aura/mus/property_converter.h |
| diff --git a/ui/aura/mus/property_converter.h b/ui/aura/mus/property_converter.h |
| index dbe10850fff633f37a5b4fdfb9500a3eac2a3c59..d75858bb148d3054e10b04fd45c617dc9500ea03 100644 |
| --- a/ui/aura/mus/property_converter.h |
| +++ b/ui/aura/mus/property_converter.h |
| @@ -12,6 +12,7 @@ |
| #include <string> |
| #include <vector> |
| +#include "base/callback_forward.h" |
| #include "base/macros.h" |
| #include "ui/aura/aura_export.h" |
| #include "ui/aura/window.h" |
| @@ -33,6 +34,8 @@ class AURA_EXPORT PropertyConverter { |
| // All primitive values are stored using this type. |
| using PrimitiveType = int64_t; |
| + static base::RepeatingCallback<bool(int32_t)> AcceptAnyValue(); |
|
sky
2017/02/23 21:02:25
After constructor/destructor, and add a comment.
W
Elliot Glaysher
2017/02/23 22:12:43
Done.
|
| + |
| PropertyConverter(); |
| ~PropertyConverter(); |
| @@ -71,14 +74,17 @@ class AURA_EXPORT PropertyConverter { |
| PrimitiveType* value); |
| // Register a property to support conversion between mus and aura. |
| - template<typename T> |
| - void RegisterProperty(const WindowProperty<T>* property, |
| - const char* transport_name) { |
| + template <typename T> |
| + void RegisterProperty( |
| + const WindowProperty<T>* property, |
| + const char* transport_name, |
| + const base::RepeatingCallback<bool(int32_t)>& validator) { |
|
sky
2017/02/23 21:02:25
Document what the validator is, and mention using
Elliot Glaysher
2017/02/23 22:12:43
Commented, and you are right that all the int32_ts
|
| PrimitiveProperty primitive_property; |
| primitive_property.property_name = property->name; |
| primitive_property.transport_name = transport_name; |
| primitive_property.default_value = |
| ui::ClassPropertyCaster<T>::ToInt64(property->default_value); |
| + primitive_property.validator = validator; |
| primitive_properties_[property] = primitive_property; |
| transport_names_.insert(transport_name); |
| } |
| @@ -97,13 +103,19 @@ class AURA_EXPORT PropertyConverter { |
| private: |
| // Contains data needed to store and convert primitive-type properties. |
| - struct PrimitiveProperty { |
| + struct AURA_EXPORT PrimitiveProperty { |
| + PrimitiveProperty(); |
| + PrimitiveProperty(const PrimitiveProperty& property); |
| + ~PrimitiveProperty(); |
| + |
| // The aura::WindowProperty::name used for storage. |
| const char* property_name = nullptr; |
| // The mus property name used for transport. |
| const char* transport_name = nullptr; |
| // The aura::WindowProperty::default_value stored using PrimitiveType. |
| PrimitiveType default_value = 0; |
| + // A callback used to validate incoming values. |
| + base::RepeatingCallback<bool(int32_t)> validator; |
| }; |
| // A map of aura::WindowProperty<T> to PrimitiveProperty structs. |