Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_AURA_MUS_PROPERTY_CONVERTER_H_ | 5 #ifndef UI_AURA_MUS_PROPERTY_CONVERTER_H_ |
| 6 #define UI_AURA_MUS_PROPERTY_CONVERTER_H_ | 6 #define UI_AURA_MUS_PROPERTY_CONVERTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | |
| 10 #include <memory> | 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "ui/aura/aura_export.h" | 16 #include "ui/aura/aura_export.h" |
| 17 #include "ui/aura/window.h" | |
| 18 | |
| 19 namespace gfx { | |
| 20 class Rect; | |
| 21 } | |
| 16 | 22 |
| 17 namespace aura { | 23 namespace aura { |
| 18 | 24 |
| 19 class Window; | |
| 20 | |
| 21 // PropertyConverter is used to convert Window properties for transport to the | 25 // PropertyConverter is used to convert Window properties for transport to the |
| 22 // mus window server and back. Any time a property changes from one side it is | 26 // mus window server and back. Any time a property changes from one side it is |
| 23 // mapped to the other using this class. Not all Window properties need to map | 27 // mapped to the other using this class. Not all Window properties need to map |
| 24 // to server properties, and similarly not all transport properties need map to | 28 // to server properties, and similarly not all transport properties need map to |
| 25 // Window properties. | 29 // Window properties. |
| 26 class AURA_EXPORT PropertyConverter { | 30 class AURA_EXPORT PropertyConverter { |
| 27 public: | 31 public: |
| 28 PropertyConverter(); | 32 PropertyConverter(); |
| 29 virtual ~PropertyConverter(); | 33 ~PropertyConverter(); |
| 30 | 34 |
| 31 // Maps a property on the Window to a property pushed to the server. Return | 35 // Maps a property on the Window to a property pushed to the server. Return |
| 32 // true if the property should be sent to the server, false if the property | 36 // true if the property should be sent to the server, false if the property |
| 33 // is only used locally. | 37 // is only used locally. |
| 34 virtual bool ConvertPropertyForTransport( | 38 bool ConvertPropertyForTransport( |
| 35 Window* window, | 39 Window* window, |
| 36 const void* key, | 40 const void* key, |
| 37 std::string* transport_name, | 41 std::string* transport_name, |
| 38 std::unique_ptr<std::vector<uint8_t>>* transport_value); | 42 std::unique_ptr<std::vector<uint8_t>>* transport_value); |
| 39 | 43 |
| 40 // Returns the transport name for a Window property. | 44 // Returns the transport name for a Window property. |
| 41 virtual std::string GetTransportNameForPropertyKey(const void* key); | 45 std::string GetTransportNameForPropertyKey(const void* key); |
| 42 | 46 |
| 43 // Applies a value from the server to |window|. |transport_name| is the | 47 // Applies a value from the server to |window|. |transport_name| is the |
| 44 // name of the property and |transport_data| the value. |transport_data| may | 48 // name of the property and |transport_data| the value. |transport_data| may |
| 45 // be null. | 49 // be null. |
| 46 virtual void SetPropertyFromTransportValue( | 50 void SetPropertyFromTransportValue( |
| 47 Window* window, | 51 Window* window, |
| 48 const std::string& transport_name, | 52 const std::string& transport_name, |
| 49 const std::vector<uint8_t>* transport_data); | 53 const std::vector<uint8_t>* transport_data); |
| 50 | 54 |
| 55 void RegisterPrimitiveProperty(const void* key, | |
|
sky
2016/11/16 17:56:13
Document what |key| is. Or better yet, is it possi
msw
2016/11/16 22:47:45
Done.
| |
| 56 const char* aura_name, | |
| 57 const char* transport_name); | |
| 58 void RegisterRectProperty(const WindowProperty<gfx::Rect*>* property, | |
| 59 const char* transport_name); | |
| 60 void RegisterStringProperty(const WindowProperty<std::string*>* property, | |
| 61 const char* transport_name); | |
| 62 | |
| 51 private: | 63 private: |
| 64 // A map of primitive property keys to their aura and mus property names. | |
| 65 typedef std::pair<const char*, const char*> PropertyNames; | |
|
sky
2016/11/16 17:56:13
using?
msw
2016/11/16 22:47:45
Done.
| |
| 66 std::map<const void*, PropertyNames> primitive_properties_; | |
|
sky
2016/11/16 17:56:13
Document what the key is as it isn't readily obvio
msw
2016/11/16 22:47:45
Done.
| |
| 67 | |
| 68 // Maps of some aura window properties to their mus property names. | |
| 69 std::map<const WindowProperty<gfx::Rect*>*, const char*> rect_properties_; | |
| 70 std::map<const WindowProperty<std::string*>*, const char*> string_properties_; | |
| 71 | |
| 52 DISALLOW_COPY_AND_ASSIGN(PropertyConverter); | 72 DISALLOW_COPY_AND_ASSIGN(PropertyConverter); |
| 53 }; | 73 }; |
| 54 | 74 |
| 55 } // namespace aura | 75 } // namespace aura |
| 56 | 76 |
| 57 #endif // UI_AURA_MUS_PROPERTY_CONVERTER_H_ | 77 #endif // UI_AURA_MUS_PROPERTY_CONVERTER_H_ |
| OLD | NEW |