Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/browser/ui/views/apps/desktop_keyboard_capture.cc

Issue 1316013004: Remove "API proposal for chrome.app.window to intercept all keys." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to TOT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "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), is_registered_(false) {
10 widget_->AddObserver(this);
11
12 if (widget_->IsActive())
13 RegisterKeyboardHooks();
14 }
15
16 DesktopKeyboardCapture::~DesktopKeyboardCapture() {
17 if (is_registered_)
18 DeregisterKeyboardHooks();
19
20 widget_->RemoveObserver(this);
21 }
22
23 void DesktopKeyboardCapture::RegisterKeyboardHooks() {
24 KeyboardHookHandler::GetInstance()->Register(widget_);
25 is_registered_ = true;
26 }
27
28 void DesktopKeyboardCapture::DeregisterKeyboardHooks() {
29 KeyboardHookHandler::GetInstance()->Deregister(widget_);
30 is_registered_ = false;
31 }
32
33 void DesktopKeyboardCapture::OnWidgetActivationChanged(views::Widget* widget,
34 bool active) {
35 if (active) {
36 RegisterKeyboardHooks();
37 } else {
38 DeregisterKeyboardHooks();
39 }
40 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/apps/desktop_keyboard_capture.h ('k') | chrome/browser/ui/views/apps/keyboard_hook_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698