| 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 "chrome/browser/ui/ash/property_util.h" | 5 #include "chrome/browser/ui/ash/property_util.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_properties.h" | 7 #include "ash/wm/window_properties.h" |
| 8 #include "chrome/browser/ui/ash/ash_util.h" | 8 #include "chrome/browser/ui/ash/ash_util.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/cpp/window.h" | 10 #include "services/ui/public/cpp/window.h" |
| 11 #include "services/ui/public/cpp/window_property.h" | 11 #include "services/ui/public/cpp/window_property.h" |
| 12 #include "services/ui/public/interfaces/window_manager.mojom.h" | 12 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 13 #include "ui/aura/mus/mus_util.h" | 13 #include "ui/aura/mus/mus_util.h" |
| 14 #include "ui/aura/mus/property_converter.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // Get the corresponding ui::Window property key for an aura::Window key. | 18 // Get the corresponding ui::Window property key for an aura::Window key. |
| 18 template <typename T> | 19 template <typename T> |
| 19 const char* GetMusProperty(const aura::WindowProperty<T>* aura_key) { | 20 const char* GetMusProperty(const aura::WindowProperty<T>* aura_key) { |
| 20 if (aura_key == ash::kShelfItemTypeKey) | 21 if (aura_key == ash::kShelfItemTypeKey) |
| 21 return ui::mojom::WindowManager::kShelfItemType_Property; | 22 return ui::mojom::WindowManager::kShelfItemType_Property; |
| 22 NOTREACHED(); | 23 NOTREACHED(); |
| 23 return nullptr; | 24 return nullptr; |
| 24 } | 25 } |
| 25 | 26 |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 namespace property_util { | 29 namespace property_util { |
| 29 | 30 |
| 30 void SetIntProperty(aura::Window* window, | 31 void SetIntProperty(aura::Window* window, |
| 31 const aura::WindowProperty<int>* property, | 32 const aura::WindowProperty<int>* property, |
| 32 int value) { | 33 int value) { |
| 33 DCHECK(window); | 34 DCHECK(window); |
| 34 if (chrome::IsRunningInMash()) { | 35 if (chrome::IsRunningInMash()) { |
| 35 aura::GetMusWindow(window)->SetSharedProperty<int>(GetMusProperty(property), | 36 aura::GetMusWindow(window) |
| 36 value); | 37 ->SetSharedProperty<aura::PropertyConverter::PrimitiveType>( |
| 38 GetMusProperty(property), value); |
| 37 } else { | 39 } else { |
| 38 window->SetProperty(property, value); | 40 window->SetProperty(property, value); |
| 39 } | 41 } |
| 40 } | 42 } |
| 41 | 43 |
| 42 void SetTitle(aura::Window* window, const base::string16& value) { | 44 void SetTitle(aura::Window* window, const base::string16& value) { |
| 43 DCHECK(window); | 45 DCHECK(window); |
| 44 if (chrome::IsRunningInMash()) { | 46 if (chrome::IsRunningInMash()) { |
| 45 aura::GetMusWindow(window)->SetSharedProperty<base::string16>( | 47 aura::GetMusWindow(window)->SetSharedProperty<base::string16>( |
| 46 ui::mojom::WindowManager::kWindowTitle_Property, value); | 48 ui::mojom::WindowManager::kWindowTitle_Property, value); |
| 47 } else { | 49 } else { |
| 48 window->SetTitle(value); | 50 window->SetTitle(value); |
| 49 } | 51 } |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace property_util | 54 } // namespace property_util |
| OLD | NEW |