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

Side by Side Diff: chrome/browser/extensions/global_shortcut_listener_win.cc

Issue 64273008: [Windows] Finish global and non-global media keys support on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/global_shortcut_listener_win.h" 5 #include "chrome/browser/extensions/global_shortcut_listener_win.h"
6 6
7 #include "base/win/win_util.h" 7 #include "base/win/win_util.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "ui/base/accelerators/accelerator.h" 9 #include "ui/base/accelerators/accelerator.h"
10 #include "ui/events/event_constants.h" 10 #include "ui/events/event_constants.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 modifiers |= (LOWORD(lparam) & MOD_CONTROL) ? ui::EF_CONTROL_DOWN : 0; 65 modifiers |= (LOWORD(lparam) & MOD_CONTROL) ? ui::EF_CONTROL_DOWN : 0;
66 ui::Accelerator accelerator( 66 ui::Accelerator accelerator(
67 ui::KeyboardCodeForWindowsKeyCode(key_code), modifiers); 67 ui::KeyboardCodeForWindowsKeyCode(key_code), modifiers);
68 68
69 instance.Get().NotifyKeyPressed(accelerator); 69 instance.Get().NotifyKeyPressed(accelerator);
70 } 70 }
71 71
72 void GlobalShortcutListenerWin::RegisterAccelerator( 72 void GlobalShortcutListenerWin::RegisterAccelerator(
73 const ui::Accelerator& accelerator, 73 const ui::Accelerator& accelerator,
74 GlobalShortcutListener::Observer* observer) { 74 GlobalShortcutListener::Observer* observer) {
75 if (hotkey_ids_.find(accelerator) != hotkey_ids_.end())
76 return; // The shortcut has been registered.
Finnur 2013/11/12 16:27:54 Perhaps document that this is because some shortcu
zhchbin 2013/11/13 05:01:57 Done.
77
75 int modifiers = 0; 78 int modifiers = 0;
76 modifiers |= accelerator.IsShiftDown() ? MOD_SHIFT : 0; 79 modifiers |= accelerator.IsShiftDown() ? MOD_SHIFT : 0;
77 modifiers |= accelerator.IsCtrlDown() ? MOD_CONTROL : 0; 80 modifiers |= accelerator.IsCtrlDown() ? MOD_CONTROL : 0;
78 modifiers |= accelerator.IsAltDown() ? MOD_ALT : 0; 81 modifiers |= accelerator.IsAltDown() ? MOD_ALT : 0;
79 static int hotkey_id = 0; 82 static int hotkey_id = 0;
80 bool success = !!RegisterHotKey( 83 bool success = !!RegisterHotKey(
81 gfx::SingletonHwnd::GetInstance()->hwnd(), 84 gfx::SingletonHwnd::GetInstance()->hwnd(),
82 hotkey_id, 85 hotkey_id,
83 modifiers, 86 modifiers,
84 accelerator.key_code()); 87 accelerator.key_code());
(...skipping 22 matching lines...) Expand all
107 gfx::SingletonHwnd::GetInstance()->hwnd(), it->second); 110 gfx::SingletonHwnd::GetInstance()->hwnd(), it->second);
108 // This call should always succeed, as long as we pass in the right HWND and 111 // This call should always succeed, as long as we pass in the right HWND and
109 // an id we've used to register before. 112 // an id we've used to register before.
110 DCHECK(success); 113 DCHECK(success);
111 114
112 hotkey_ids_.erase(it); 115 hotkey_ids_.erase(it);
113 GlobalShortcutListener::UnregisterAccelerator(accelerator, observer); 116 GlobalShortcutListener::UnregisterAccelerator(accelerator, observer);
114 } 117 }
115 118
116 } // namespace extensions 119 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698