Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
|
benwells
2014/11/21 00:52:00
Nit: no (c)
Sriram
2014/11/21 05:35:20
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 "chrome/browser/ui/views/apps/desktop_keyboard_capture.h" | |
| 6 #include "chrome/browser/ui/views/apps/keyboard_hook_handler.h" | |
| 7 | |
| 8 DesktopKeyboardCapture::DesktopKeyboardCapture(views::Widget* widget) | |
| 9 : widget_(widget), | |
| 10 is_registered_(false) { | |
| 11 widget_->AddObserver(this); | |
| 12 | |
| 13 if (widget_->IsActive()) | |
| 14 RegisterKeyboardHooks(); | |
| 15 } | |
| 16 | |
| 17 DesktopKeyboardCapture::~DesktopKeyboardCapture() { | |
| 18 if (is_registered_) | |
| 19 DeregisterKeyboardHooks(); | |
| 20 | |
| 21 widget_->RemoveObserver(this); | |
| 22 } | |
| 23 | |
| 24 void DesktopKeyboardCapture::RegisterKeyboardHooks() { | |
| 25 KeyboardHookHandler::GetInstance()->Register(widget_); | |
| 26 is_registered_ = true; | |
| 27 } | |
| 28 | |
| 29 void DesktopKeyboardCapture::DeregisterKeyboardHooks() { | |
| 30 KeyboardHookHandler::GetInstance()->Deregister(widget_); | |
| 31 is_registered_ = false; | |
| 32 } | |
| 33 | |
| 34 void DesktopKeyboardCapture::OnWidgetActivationChanged(views::Widget* widget, | |
| 35 bool active) { | |
| 36 if (active) { | |
| 37 RegisterKeyboardHooks(); | |
| 38 } else { | |
| 39 DeregisterKeyboardHooks(); | |
| 40 } | |
| 41 } | |
| OLD | NEW |