Chromium Code Reviews| Index: chrome/browser/ui/ash/property_util.cc |
| diff --git a/chrome/browser/ui/ash/property_util.cc b/chrome/browser/ui/ash/property_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..12068492cf7cc8679474f307b5838ad627343548 |
| --- /dev/null |
| +++ b/chrome/browser/ui/ash/property_util.cc |
| @@ -0,0 +1,45 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/ash/property_util.h" |
| + |
| +#include "ash/wm/window_properties.h" |
| +#include "services/ui/public/cpp/window.h" |
| +#include "services/ui/public/interfaces/window_manager.mojom.h" |
| +#include "ui/aura/mus/mus_util.h" |
| + |
| +namespace { |
| + |
| +// Get the corresponding ui::Window property key for an aura::Window key. |
| +template <typename T> |
| +const char* GetMusProperty(const aura::WindowProperty<T>* aura_key) { |
| + if (aura_key == ash::kShelfIconResourceIdKey) |
| + return ui::mojom::WindowManager::kShelfIconResourceId_Property; |
| + if (aura_key == ash::kShelfItemTypeKey) |
| + return ui::mojom::WindowManager::kShelfItemType_Property; |
| + NOTREACHED(); |
| + return nullptr; |
| +} |
| + |
| +} // namespace |
| + |
| +void SetIntProperty(aura::Window* window, |
| + const aura::WindowProperty<int>* property, |
| + int value) { |
| + ui::Window* ui_window = aura::GetMusWindow(window); |
|
James Cook
2016/10/01 00:16:21
nit: DCHECK(window)?
msw
2016/10/03 19:14:23
Done.
|
| + if (ui_window) |
|
James Cook
2016/10/01 00:16:21
I think it would be better to check IsRunningInMas
msw
2016/10/03 19:14:23
Done.
|
| + ui_window->SetSharedProperty<int>(GetMusProperty(property), value); |
| + else |
| + window->SetProperty(property, value); |
| +} |
| + |
| +void SetTitle(aura::Window* window, const base::string16& value) { |
|
James Cook
2016/10/01 00:16:21
Should these functions take a views::Widget instea
msw
2016/10/03 19:14:23
I'm following the example of ash/mus/property_util
|
| + ui::Window* ui_window = aura::GetMusWindow(window); |
| + if (ui_window) { |
|
James Cook
2016/10/01 00:16:21
ditto re IsRunningInMash, DCHECKS, etc.
msw
2016/10/03 19:14:23
Done.
|
| + ui_window->SetSharedProperty<base::string16>( |
| + ui::mojom::WindowManager::kWindowTitle_Property, value); |
| + } else { |
| + window->SetTitle(value); |
| + } |
| +} |