OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ | 5 #ifndef UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ |
6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ | 6 #define UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ |
7 | 7 |
8 #include <gestures/gestures.h> | 8 #include <gestures/gestures.h> |
9 #include <libevdev/libevdev.h> | 9 #include <libevdev/libevdev.h> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void RegisterDevice(const DeviceId id, const DevicePtr device); | 121 void RegisterDevice(const DeviceId id, const DevicePtr device); |
122 | 122 |
123 // Unregister a device. Remove all of its properties being tracked. | 123 // Unregister a device. Remove all of its properties being tracked. |
124 void UnregisterDevice(const DeviceId id); | 124 void UnregisterDevice(const DeviceId id); |
125 | 125 |
126 // Called by functions in GesturesPropFunctionsWrapper to manipulate | 126 // Called by functions in GesturesPropFunctionsWrapper to manipulate |
127 // properties. Note these functions do not new/delete the GesturesProp | 127 // properties. Note these functions do not new/delete the GesturesProp |
128 // pointers. It is caller's responsibility to manage them. | 128 // pointers. It is caller's responsibility to manage them. |
129 void AddProperty(const DeviceId device_id, | 129 void AddProperty(const DeviceId device_id, |
130 const std::string& name, | 130 const std::string& name, |
131 GesturesProp* property); | 131 scoped_ptr<GesturesProp> property); |
132 void DeleteProperty(const DeviceId device_id, const std::string& name); | 132 void DeleteProperty(const DeviceId device_id, const std::string& name); |
133 | 133 |
134 // Check if a property exists for a device. Return if it is found. | 134 // Check if a property exists for a device. Return if it is found. |
135 GesturesProp* FindProperty(const DeviceId device_id, const std::string& name); | 135 GesturesProp* FindProperty(const DeviceId device_id, const std::string& name); |
136 | 136 |
137 // Get the default value of a property based on the configuration files. | 137 // Get the default value of a property based on the configuration files. |
138 GesturesProp* GetDefaultProperty(const DeviceId device_id, | 138 GesturesProp* GetDefaultProperty(const DeviceId device_id, |
139 const std::string& name); | 139 const std::string& name); |
140 | 140 |
141 // The device configuration files are parsed and stored in the memory upon | 141 // The device configuration files are parsed and stored in the memory upon |
142 // Chrome starts. The default property values are then applied to each device | 142 // Chrome starts. The default property values are then applied to each device |
143 // when it is attached/detected. | 143 // when it is attached/detected. |
144 void LoadDeviceConfigurations(); | 144 void LoadDeviceConfigurations(); |
145 | 145 |
146 // Parse a xorg-conf file. We ignore all sections other than InputClass. | 146 // Parse a xorg-conf file. We ignore all sections other than InputClass. |
147 // Check the xorg-conf spec for more infomation about its format. | 147 // Check the xorg-conf spec for more infomation about its format. |
148 void ParseXorgConfFile(const std::string& content); | 148 void ParseXorgConfFile(const std::string& content); |
149 | 149 |
150 // Create a match criteria. | 150 // Create a match criteria. |
151 internal::MatchCriteria* CreateMatchCriteria(const std::string& match_type, | 151 scoped_ptr<internal::MatchCriteria> CreateMatchCriteria( |
152 const std::string& arg); | 152 const std::string& match_type, |
| 153 const std::string& arg); |
153 | 154 |
154 // Create a property that comes from the conf files. | 155 // Create a property that comes from the conf files. |
155 GesturesProp* CreateDefaultProperty(const std::string& name, | 156 scoped_ptr<GesturesProp> CreateDefaultProperty(const std::string& name, |
156 const std::string& value); | 157 const std::string& value); |
157 | 158 |
158 // Setup default property values for a newly found device. | 159 // Setup default property values for a newly found device. |
159 void SetupDefaultProperties(const DeviceId device_id, const DevicePtr device); | 160 void SetupDefaultProperties(const DeviceId device_id, const DevicePtr device); |
160 | 161 |
161 // Map from device ids to device pointers. | 162 // Map from device ids to device pointers. |
162 DeviceMap device_map_; | 163 DeviceMap device_map_; |
163 | 164 |
164 // GestureDevicePropertyData indexed by their respective device ids. Owns the | 165 // GestureDevicePropertyData indexed by their respective device ids. Owns the |
165 // objects. | 166 // objects. |
166 ScopedDeviceDataMap device_data_map_; | 167 ScopedDeviceDataMap device_data_map_; |
167 | 168 |
168 // A vector of parsed sections in configuration files. Owns MatchCriterias, | 169 // A vector of parsed sections in configuration files. Owns MatchCriterias, |
169 // GesturesProps and ConfigurationSections in it. | 170 // GesturesProps and ConfigurationSections in it. |
170 ScopedVector<internal::ConfigurationSection> configurations_; | 171 std::vector<scoped_ptr<internal::ConfigurationSection>> configurations_; |
171 | 172 |
172 DISALLOW_COPY_AND_ASSIGN(GesturePropertyProvider); | 173 DISALLOW_COPY_AND_ASSIGN(GesturePropertyProvider); |
173 }; | 174 }; |
174 | 175 |
175 // Wrapper of GesturesProp related functions. We group them together so that we | 176 // Wrapper of GesturesProp related functions. We group them together so that we |
176 // can friend them all at once. | 177 // can friend them all at once. |
177 class GesturesPropFunctionsWrapper { | 178 class GesturesPropFunctionsWrapper { |
178 public: | 179 public: |
179 // Property provider interface implementation. | 180 // Property provider interface implementation. |
180 // | 181 // |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 const T* init); | 240 const T* init); |
240 | 241 |
241 // Do things that should happen BEFORE we create the property. | 242 // Do things that should happen BEFORE we create the property. |
242 static bool PreCreateProperty(void* device_data, | 243 static bool PreCreateProperty(void* device_data, |
243 const char* name, | 244 const char* name, |
244 GesturesProp** default_property); | 245 GesturesProp** default_property); |
245 | 246 |
246 // Do things that should happen AFTER we create the property. | 247 // Do things that should happen AFTER we create the property. |
247 static void PostCreateProperty(void* device_data, | 248 static void PostCreateProperty(void* device_data, |
248 const char* name, | 249 const char* name, |
249 GesturesProp* property); | 250 scoped_ptr<GesturesProp> property); |
250 | 251 |
251 // Some other utility functions used in InitializeDeviceProperties. | 252 // Some other utility functions used in InitializeDeviceProperties. |
252 static GesturesProp* CreateIntSingle(void* device_data, | 253 static GesturesProp* CreateIntSingle(void* device_data, |
253 const char* name, | 254 const char* name, |
254 int* value, | 255 int* value, |
255 int init); | 256 int init); |
256 static GesturesProp* CreateBoolSingle(void* device_data, | 257 static GesturesProp* CreateBoolSingle(void* device_data, |
257 const char* name, | 258 const char* name, |
258 GesturesPropBool* value, | 259 GesturesPropBool* value, |
259 GesturesPropBool init); | 260 GesturesPropBool init); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // Handler function pointers and the data to be passed to them when the | 333 // Handler function pointers and the data to be passed to them when the |
333 // property is accessed. | 334 // property is accessed. |
334 GesturesPropGetHandler get_; | 335 GesturesPropGetHandler get_; |
335 GesturesPropSetHandler set_; | 336 GesturesPropSetHandler set_; |
336 void* handler_data_; | 337 void* handler_data_; |
337 | 338 |
338 DISALLOW_COPY_AND_ASSIGN(GesturesProp); | 339 DISALLOW_COPY_AND_ASSIGN(GesturesProp); |
339 }; | 340 }; |
340 | 341 |
341 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ | 342 #endif // UI_EVENTS_OZONE_EVDEV_LIBGESTURES_GLUE_GESTURE_PROPERTY_PROVIDER_H_ |
OLD | NEW |