Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / wm / public / scoped_tooltip_disabler.cc
blob45a39ca6a9ef2174148783c02db02548d8ebd5d4
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.
5 #include "ui/wm/public/scoped_tooltip_disabler.h"
7 #include "ui/aura/window.h"
8 #include "ui/wm/public/tooltip_client.h"
10 namespace aura {
11 namespace client {
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);
23 ScopedTooltipDisabler::~ScopedTooltipDisabler() {
24 EnableTooltips();
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;
37 void ScopedTooltipDisabler::OnWindowDestroying(aura::Window* window) {
38 EnableTooltips();
42 } // namespace client
43 } // namespace aura