Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
varunjain
2013/08/29 21:22:56
nit: 2013
sky
2013/08/29 21:27:41
Done.
| |
| 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/views/widget/desktop_aura/scoped_tooltip_client.h" | |
| 6 | |
| 7 #include "ui/aura/root_window.h" | |
| 8 #include "ui/views/corewm/tooltip_controller.h" | |
| 9 | |
| 10 namespace views { | |
| 11 | |
| 12 // static | |
| 13 corewm::TooltipController* ScopedTooltipClient::tooltip_controller_ = NULL; | |
| 14 | |
| 15 // static | |
| 16 int ScopedTooltipClient::scoped_tooltip_client_count_ = 0; | |
| 17 | |
| 18 ScopedTooltipClient::ScopedTooltipClient(aura::RootWindow* root_window) | |
| 19 : root_window_(root_window) { | |
| 20 if (scoped_tooltip_client_count_++ == 0) { | |
| 21 tooltip_controller_ = | |
| 22 new corewm::TooltipController(gfx::SCREEN_TYPE_NATIVE); | |
| 23 } | |
| 24 aura::client::SetTooltipClient(root_window_, tooltip_controller_); | |
| 25 root_window_->AddPreTargetHandler(tooltip_controller_); | |
| 26 } | |
| 27 | |
| 28 ScopedTooltipClient::~ScopedTooltipClient() { | |
| 29 root_window_->RemovePreTargetHandler(tooltip_controller_); | |
| 30 aura::client::SetTooltipClient(root_window_, NULL); | |
| 31 if (--scoped_tooltip_client_count_ == 0) { | |
| 32 delete tooltip_controller_; | |
| 33 tooltip_controller_ = NULL; | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 } // namespace views | |
| OLD | NEW |