Chromium Code Reviews| Index: ash/mus/container_delegate_mus.cc |
| diff --git a/ash/mus/container_delegate_mus.cc b/ash/mus/container_delegate_mus.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..78ca9f623e537c2e6d34821acd5a7745b00d1736 |
| --- /dev/null |
| +++ b/ash/mus/container_delegate_mus.cc |
| @@ -0,0 +1,50 @@ |
| +// 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 "ash/mus/container_delegate_mus.h" |
| + |
| +#include <stdint.h> |
| + |
| +#include "components/mus/public/cpp/property_type_converters.h" |
| +#include "components/mus/public/cpp/window.h" |
| +#include "components/mus/public/cpp/window_property.h" |
| +#include "mash/wm/public/interfaces/container.mojom.h" |
| +#include "ui/views/mus/native_widget_mus.h" |
| +#include "ui/views/widget/widget.h" |
| + |
| +using mash::wm::mojom::Container; |
| + |
| +namespace ash { |
| +namespace sysui { |
| + |
| +namespace { |
| + |
| +// Returns true if a top-level |widget| is in |container|. |
| +bool IsInContainer(views::Widget* widget, Container container) { |
| + mus::Window* window = |
|
sky
2016/05/06 21:20:46
Use GetMusWindow, that way you don't need casts. A
James Cook
2016/05/06 22:46:24
Done.
|
| + static_cast<views::NativeWidgetMus*>(widget->native_widget())->window(); |
| + if (window->HasSharedProperty(mash::wm::mojom::kWindowContainer_Property)) |
| + return container == |
| + static_cast<Container>(window->GetSharedProperty<int32_t>( |
| + mash::wm::mojom::kWindowContainer_Property)); |
| + |
| + return false; |
| +} |
| + |
| +} // namespace |
| + |
| +ContainerDelegateMus::ContainerDelegateMus() {} |
| + |
| +ContainerDelegateMus::~ContainerDelegateMus() {} |
| + |
| +bool ContainerDelegateMus::IsInMenuContainer(views::Widget* widget) { |
| + return IsInContainer(widget, Container::MENUS); |
| +} |
| + |
| +bool ContainerDelegateMus::IsInStatusContainer(views::Widget* widget) { |
| + return IsInContainer(widget, Container::STATUS); |
| +} |
| + |
| +} // namespace sysui |
| +} // namespace ash |