| Index: ui/wm/core/transient_window_manager.cc
|
| diff --git a/ui/wm/core/transient_window_manager.cc b/ui/wm/core/transient_window_manager.cc
|
| index 120af84786c5b98a717491d7b4ff263d8facef53..9a2ba387911f95d030d51e8360b683e1b1545254 100644
|
| --- a/ui/wm/core/transient_window_manager.cc
|
| +++ b/ui/wm/core/transient_window_manager.cc
|
| @@ -18,9 +18,12 @@
|
| using aura::Window;
|
|
|
| namespace wm {
|
| +namespace {
|
|
|
| DEFINE_OWNED_WINDOW_PROPERTY_KEY(TransientWindowManager, kPropertyKey, NULL);
|
|
|
| +} // namespace
|
| +
|
| TransientWindowManager::~TransientWindowManager() {
|
| }
|
|
|
| @@ -97,7 +100,10 @@ bool TransientWindowManager::IsStackingTransient(
|
| TransientWindowManager::TransientWindowManager(Window* window)
|
| : window_(window),
|
| transient_parent_(NULL),
|
| - stacking_target_(NULL) {
|
| + stacking_target_(NULL),
|
| + parent_controls_visibility_(false),
|
| + show_on_parent_visible_(false),
|
| + ignore_visibility_changed_event_(false) {
|
| window_->AddObserver(this);
|
| }
|
|
|
| @@ -134,18 +140,44 @@ void TransientWindowManager::OnWindowParentChanged(aura::Window* window,
|
| }
|
| }
|
|
|
| +void TransientWindowManager::UpdateTransientChildVisibility(
|
| + bool parent_visible) {
|
| + base::AutoReset<bool> reset(&ignore_visibility_changed_event_, true);
|
| + if (!parent_visible) {
|
| + show_on_parent_visible_ = window_->TargetVisibility();
|
| + window_->Hide();
|
| + } else {
|
| + if (show_on_parent_visible_ && parent_controls_visibility_)
|
| + window_->Show();
|
| + show_on_parent_visible_ = false;
|
| + }
|
| +}
|
| +
|
| void TransientWindowManager::OnWindowVisibilityChanging(Window* window,
|
| bool visible) {
|
| - // TODO(sky): move handling of becoming visible here.
|
| - if (!visible) {
|
| - std::for_each(transient_children_.begin(), transient_children_.end(),
|
| - std::mem_fun(&Window::Hide));
|
| + DCHECK_EQ(window_, window);
|
| +
|
| + for (auto* child : transient_children_)
|
| + Get(child)->UpdateTransientChildVisibility(visible);
|
| +}
|
| +
|
| +void TransientWindowManager::OnWindowVisibilityChanged(Window* window,
|
| + bool visible) {
|
| + if (window_ != window || ignore_visibility_changed_event_ ||
|
| + !transient_parent_ || !parent_controls_visibility_) {
|
| + return;
|
| + }
|
| + if (!transient_parent_->TargetVisibility() && visible) {
|
| + base::AutoReset<bool> reset(&ignore_visibility_changed_event_, true);
|
| + show_on_parent_visible_ = true;
|
| + window_->Hide();
|
| + } else if (!visible) {
|
| + DCHECK(!show_on_parent_visible_);
|
| }
|
| }
|
|
|
| void TransientWindowManager::OnWindowStackingChanged(Window* window) {
|
| DCHECK_EQ(window_, window);
|
| -
|
| // Do nothing if we initiated the stacking change.
|
| const TransientWindowManager* transient_manager =
|
| Get(static_cast<const Window*>(window));
|
|
|