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 #include "ui/aura/mus/property_converter.h" | 5 #include "ui/aura/mus/property_converter.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "mojo/public/cpp/bindings/type_converter.h" | 8 #include "mojo/public/cpp/bindings/type_converter.h" |
| 9 #include "services/ui/public/cpp/property_type_converters.h" | 9 #include "services/ui/public/cpp/property_type_converters.h" |
| 10 #include "services/ui/public/interfaces/window_manager.mojom.h" | 10 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 PropertyConverter::PrimitiveProperty::~PrimitiveProperty() {} | 59 PropertyConverter::PrimitiveProperty::~PrimitiveProperty() {} |
| 60 | 60 |
| 61 // static | 61 // static |
| 62 base::RepeatingCallback<bool(int64_t)> | 62 base::RepeatingCallback<bool(int64_t)> |
| 63 PropertyConverter::CreateAcceptAnyValueCallback() { | 63 PropertyConverter::CreateAcceptAnyValueCallback() { |
| 64 return base::Bind(&AlwaysTrue); | 64 return base::Bind(&AlwaysTrue); |
| 65 } | 65 } |
| 66 | 66 |
| 67 PropertyConverter::PropertyConverter() { | 67 PropertyConverter::PropertyConverter() { |
| 68 // Add known aura properties with associated mus properties. | 68 // Add known aura properties with associated mus properties. |
| 69 RegisterProperty(client::kAlwaysOnTopKey, | 69 RegisterPrimitiveProperty(client::kAlwaysOnTopKey, |
| 70 ui::mojom::WindowManager::kAlwaysOnTop_Property, | 70 ui::mojom::WindowManager::kAlwaysOnTop_Property, |
| 71 CreateAcceptAnyValueCallback()); | 71 CreateAcceptAnyValueCallback()); |
|
Elliot Glaysher
2017/05/15 22:46:04
Now that the method name differs, should it be sor
msw
2017/05/15 22:52:54
Good question, I slightly prefer still sorting by
msw
2017/05/15 23:03:58
I reordered them, as per Elliot's offline request.
| |
| 72 RegisterProperty(client::kAppIconKey, | 72 RegisterImageProperty(client::kAppIconKey, |
| 73 ui::mojom::WindowManager::kAppIcon_Property); | 73 ui::mojom::WindowManager::kAppIcon_Property); |
| 74 RegisterProperty(client::kImmersiveFullscreenKey, | 74 RegisterPrimitiveProperty( |
| 75 ui::mojom::WindowManager::kImmersiveFullscreen_Property, | 75 client::kImmersiveFullscreenKey, |
| 76 CreateAcceptAnyValueCallback()); | 76 ui::mojom::WindowManager::kImmersiveFullscreen_Property, |
| 77 RegisterProperty(client::kNameKey, ui::mojom::WindowManager::kName_Property); | 77 CreateAcceptAnyValueCallback()); |
| 78 RegisterProperty(client::kPreferredSize, | 78 RegisterStringProperty(client::kNameKey, |
| 79 ui::mojom::WindowManager::kPreferredSize_Property); | 79 ui::mojom::WindowManager::kName_Property); |
| 80 RegisterProperty(client::kResizeBehaviorKey, | 80 RegisterSizeProperty(client::kPreferredSize, |
| 81 ui::mojom::WindowManager::kResizeBehavior_Property, | 81 ui::mojom::WindowManager::kPreferredSize_Property); |
| 82 base::Bind(&ValidateResizeBehaviour)); | 82 RegisterPrimitiveProperty(client::kResizeBehaviorKey, |
| 83 RegisterProperty(client::kRestoreBoundsKey, | 83 ui::mojom::WindowManager::kResizeBehavior_Property, |
| 84 ui::mojom::WindowManager::kRestoreBounds_Property); | 84 base::Bind(&ValidateResizeBehaviour)); |
| 85 RegisterProperty(client::kShowStateKey, | 85 RegisterRectProperty(client::kRestoreBoundsKey, |
| 86 ui::mojom::WindowManager::kShowState_Property, | 86 ui::mojom::WindowManager::kRestoreBounds_Property); |
| 87 base::Bind(&ValidateShowState)); | 87 RegisterPrimitiveProperty(client::kShowStateKey, |
| 88 RegisterProperty(client::kWindowIconKey, | 88 ui::mojom::WindowManager::kShowState_Property, |
| 89 ui::mojom::WindowManager::kWindowIcon_Property); | 89 base::Bind(&ValidateShowState)); |
| 90 RegisterProperty(client::kTitleKey, | 90 RegisterImageProperty(client::kWindowIconKey, |
| 91 ui::mojom::WindowManager::kWindowTitle_Property); | 91 ui::mojom::WindowManager::kWindowIcon_Property); |
| 92 RegisterString16Property(client::kTitleKey, | |
| 93 ui::mojom::WindowManager::kWindowTitle_Property); | |
| 92 } | 94 } |
| 93 | 95 |
| 94 PropertyConverter::~PropertyConverter() {} | 96 PropertyConverter::~PropertyConverter() {} |
| 95 | 97 |
| 96 bool PropertyConverter::IsTransportNameRegistered( | 98 bool PropertyConverter::IsTransportNameRegistered( |
| 97 const std::string& name) const { | 99 const std::string& name) const { |
| 98 return transport_names_.count(name) > 0; | 100 return transport_names_.count(name) > 0; |
| 99 } | 101 } |
| 100 | 102 |
| 101 bool PropertyConverter::ConvertPropertyForTransport( | 103 bool PropertyConverter::ConvertPropertyForTransport( |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 << transport_name; | 283 << transport_name; |
| 282 return false; | 284 return false; |
| 283 } | 285 } |
| 284 *value = v; | 286 *value = v; |
| 285 return true; | 287 return true; |
| 286 } | 288 } |
| 287 } | 289 } |
| 288 return false; | 290 return false; |
| 289 } | 291 } |
| 290 | 292 |
| 291 void PropertyConverter::RegisterProperty( | 293 void PropertyConverter::RegisterImageProperty( |
| 292 const WindowProperty<gfx::ImageSkia*>* property, | 294 const WindowProperty<gfx::ImageSkia*>* property, |
| 293 const char* transport_name) { | 295 const char* transport_name) { |
| 294 image_properties_[property] = transport_name; | 296 image_properties_[property] = transport_name; |
| 295 transport_names_.insert(transport_name); | 297 transport_names_.insert(transport_name); |
| 296 } | 298 } |
| 297 | 299 |
| 298 void PropertyConverter::RegisterProperty( | 300 void PropertyConverter::RegisterRectProperty( |
| 299 const WindowProperty<gfx::Rect*>* property, | 301 const WindowProperty<gfx::Rect*>* property, |
| 300 const char* transport_name) { | 302 const char* transport_name) { |
| 301 rect_properties_[property] = transport_name; | 303 rect_properties_[property] = transport_name; |
| 302 transport_names_.insert(transport_name); | 304 transport_names_.insert(transport_name); |
| 303 } | 305 } |
| 304 | 306 |
| 305 void PropertyConverter::RegisterProperty( | 307 void PropertyConverter::RegisterSizeProperty( |
| 306 const WindowProperty<gfx::Size*>* property, | 308 const WindowProperty<gfx::Size*>* property, |
| 307 const char* transport_name) { | 309 const char* transport_name) { |
| 308 size_properties_[property] = transport_name; | 310 size_properties_[property] = transport_name; |
| 309 transport_names_.insert(transport_name); | 311 transport_names_.insert(transport_name); |
| 310 } | 312 } |
| 311 | 313 |
| 312 void PropertyConverter::RegisterProperty( | 314 void PropertyConverter::RegisterStringProperty( |
| 313 const WindowProperty<std::string*>* property, | 315 const WindowProperty<std::string*>* property, |
| 314 const char* transport_name) { | 316 const char* transport_name) { |
| 315 string_properties_[property] = transport_name; | 317 string_properties_[property] = transport_name; |
| 316 transport_names_.insert(transport_name); | 318 transport_names_.insert(transport_name); |
| 317 } | 319 } |
| 318 | 320 |
| 319 void PropertyConverter::RegisterProperty( | 321 void PropertyConverter::RegisterString16Property( |
| 320 const WindowProperty<base::string16*>* property, | 322 const WindowProperty<base::string16*>* property, |
| 321 const char* transport_name) { | 323 const char* transport_name) { |
| 322 string16_properties_[property] = transport_name; | 324 string16_properties_[property] = transport_name; |
| 323 transport_names_.insert(transport_name); | 325 transport_names_.insert(transport_name); |
| 324 } | 326 } |
| 325 | 327 |
| 326 } // namespace aura | 328 } // namespace aura |
| OLD | NEW |