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

Unified Diff: ui/views/widget/desktop_aura/desktop_keyboard_capture_win.h

Issue 297123002: API proposal for chrome.app.window to intercept all keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build break pulling in TOT Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_keyboard_capture_win.h
diff --git a/ui/views/widget/desktop_aura/desktop_keyboard_capture_win.h b/ui/views/widget/desktop_aura/desktop_keyboard_capture_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..8ccef2c2502676a59cfb80cee9f6a815ce072dec
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_keyboard_capture_win.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
sky 2014/07/29 23:07:26 2014.
Sriram 2014/07/31 00:21:14 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_WIDGET_DESKTOP_KEYBOARD_CAPTURE_WIN_H_
+#define UI_VIEWS_WIDGET_DESKTOP_KEYBOARD_CAPTURE_WIN_H_
+
+#include <map>
+
+#include "base/containers/scoped_ptr_hash_map.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/views/views_export.h"
+
+namespace base {
+class Lock;
+class TaskRunner;
+}
+
+namespace views {
+
+class VIEWS_EXPORT DesktopKeyboardCaptureWin {
sky 2014/07/29 23:07:26 Please add class level descriptions and in general
sky 2014/07/29 23:07:26 I think this code would be less error prone if it
Sriram 2014/07/31 00:21:14 Done.
Sriram 2014/07/31 00:21:14 The registration should be done on a thread that w
sky 2014/07/31 15:21:22 I don't understand. I'm suggesting the following:
Sriram 2014/07/31 19:40:05 Done.
+ public:
+ static void Capture(HWND window_handle, base::TaskRunner* task_runner);
sky 2014/07/29 23:07:26 Why does this take a task_runner?
Sriram 2014/07/31 00:21:14 See above. On 2014/07/29 23:07:26, sky wrote:
sky 2014/07/31 15:21:22 And see my other comments about thread usage.
Sriram 2014/07/31 19:40:05 Done.
+ static void Release(HWND window_handle);
+
+ private:
+ // Low level keyboard hook processing related functions.
+ // Hook callback called from the OS.
+ static LRESULT CALLBACK
+ KeyboardHook(int code, WPARAM w_param, LPARAM l_param);
+
+ static bool IsKeyUp(WPARAM w_param);
+ static bool IsBitSet(ULONG value, ULONG mask);
+ static DWORD RemoveLocationOnKeycode(DWORD vk_code);
+ static bool UpdateThreadKeyboardState();
+ static LPARAM GetLParamFromHookStruct(WPARAM w_param,
+ KBDLLHOOKSTRUCT hook_struct);
+
+ // Registration list related functions.
+ static bool AddToRegistrationList(HWND handle);
+ static void RegisterExistingHandle(HWND handle);
+ static bool IsRegistered(HWND handle);
+
+ class KeyboardInterceptRegistration;
+ static base::Lock registration_lock_;
sky 2014/07/29 23:07:26 statics should only be POD (see style guide).
Sriram 2014/07/31 00:21:14 Done.
+ static base::ScopedPtrHashMap<HWND, KeyboardInterceptRegistration>
+ registrations_;
+};
+}
+
+#endif // UI_VIEWS_WIDGET_DESKTOP_KEYBOARD_CAPTURE_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698