| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/wm/public/scoped_tooltip_disabler.h" | |
| 6 | |
| 7 #include "ui/aura/window.h" | |
| 8 #include "ui/wm/public/tooltip_client.h" | |
| 9 | |
| 10 namespace aura { | |
| 11 namespace client { | |
| 12 | |
| 13 ScopedTooltipDisabler::ScopedTooltipDisabler(aura::Window* window) | |
| 14 : root_(window ? window->GetRootWindow() : NULL) { | |
| 15 if (root_) { | |
| 16 root_->AddObserver(this); | |
| 17 TooltipClient* client = GetTooltipClient(root_); | |
| 18 if (client) | |
| 19 client->SetTooltipsEnabled(false); | |
| 20 } | |
| 21 } | |
| 22 | |
| 23 ScopedTooltipDisabler::~ScopedTooltipDisabler() { | |
| 24 EnableTooltips(); | |
| 25 } | |
| 26 | |
| 27 void ScopedTooltipDisabler::EnableTooltips() { | |
| 28 if (!root_) | |
| 29 return; | |
| 30 TooltipClient* client = GetTooltipClient(root_); | |
| 31 if (client) | |
| 32 client->SetTooltipsEnabled(true); | |
| 33 root_->RemoveObserver(this); | |
| 34 root_ = NULL; | |
| 35 } | |
| 36 | |
| 37 void ScopedTooltipDisabler::OnWindowDestroying(aura::Window* window) { | |
| 38 EnableTooltips(); | |
| 39 } | |
| 40 | |
| 41 | |
| 42 } // namespace client | |
| 43 } // namespace aura | |
| OLD | NEW |