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 #ifndef UI_WM_PUBLIC_SCOPED_TOOLTIP_DISABLER_H_
6 #define UI_WM_PUBLIC_SCOPED_TOOLTIP_DISABLER_H_
7 
8 #include "base/macros.h"
9 #include "ui/aura/window_observer.h"
10 #include "ui/wm/public/wm_public_export.h"
11 
12 namespace wm {
13 
14 // Use to temporarily disable tooltips.
15 class WM_PUBLIC_EXPORT ScopedTooltipDisabler : aura::WindowObserver {
16  public:
17   // Disables tooltips on |window| (does nothing if |window| is NULL). Tooltips
18   // are reenabled from the destructor when there are no most outstanding
19   // ScopedTooltipDisablers for |window|.
20   explicit ScopedTooltipDisabler(aura::Window* window);
21   ~ScopedTooltipDisabler() override;
22 
23  private:
24   // Reenables the tooltips on the TooltipClient.
25   void EnableTooltips();
26 
27   // aura::WindowObserver:
28   void OnWindowDestroying(aura::Window* window) override;
29 
30   // The RootWindow to disable Tooltips on; NULL if the Window passed to the
31   // constructor was not in a root or the root has been destroyed.
32   aura::Window* root_;
33 
34   DISALLOW_COPY_AND_ASSIGN(ScopedTooltipDisabler);
35 };
36 
37 }  // namespace wm
38 
39 #endif  // UI_WM_PUBLIC_SCOPED_TOOLTIP_DISABLER_H_
40