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

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

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/ui/views/apps/keyboard_hook_handler.h" 5 #include "chrome/browser/ui/views/apps/keyboard_hook_handler.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void Register(HWND window_handle); 161 void Register(HWND window_handle);
162 162
163 // Release the request for all keyboard events. 163 // Release the request for all keyboard events.
164 void Deregister(HWND window_handle); 164 void Deregister(HWND window_handle);
165 165
166 // Get singleton instance. 166 // Get singleton instance.
167 static LowLevelHookHandler* GetInstance(); 167 static LowLevelHookHandler* GetInstance();
168 168
169 private: 169 private:
170 // Private constructor/destructor so it is accessible only 170 // Private constructor/destructor so it is accessible only
171 // DefaultSingletonTraits. 171 // base::DefaultSingletonTraits.
172 friend struct DefaultSingletonTraits<LowLevelHookHandler>; 172 friend struct base::DefaultSingletonTraits<LowLevelHookHandler>;
173 LowLevelHookHandler(); 173 LowLevelHookHandler();
174 174
175 ~LowLevelHookHandler(); 175 ~LowLevelHookHandler();
176 176
177 // Low level keyboard hook processing related functions. 177 // Low level keyboard hook processing related functions.
178 // Hook callback called from the OS. 178 // Hook callback called from the OS.
179 static LRESULT CALLBACK 179 static LRESULT CALLBACK
180 KeyboardHook(int code, WPARAM w_param, LPARAM l_param); 180 KeyboardHook(int code, WPARAM w_param, LPARAM l_param);
181 181
182 // Low level keyboard hook handler. 182 // Low level keyboard hook handler.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 // static 258 // static
259 LRESULT CALLBACK LowLevelHookHandler::MessageFilterHook(int code, 259 LRESULT CALLBACK LowLevelHookHandler::MessageFilterHook(int code,
260 WPARAM w_param, 260 WPARAM w_param,
261 LPARAM l_param) { 261 LPARAM l_param) {
262 return GetInstance()->HandleMessageFilterHook(code, w_param, l_param); 262 return GetInstance()->HandleMessageFilterHook(code, w_param, l_param);
263 } 263 }
264 264
265 // static 265 // static
266 LowLevelHookHandler* LowLevelHookHandler::GetInstance() { 266 LowLevelHookHandler* LowLevelHookHandler::GetInstance() {
267 return Singleton<LowLevelHookHandler, 267 return base::Singleton<LowLevelHookHandler, base::DefaultSingletonTraits<
268 DefaultSingletonTraits<LowLevelHookHandler>>::get(); 268 LowLevelHookHandler>>::get();
269 } 269 }
270 270
271 void LowLevelHookHandler::Register(HWND window_handle) { 271 void LowLevelHookHandler::Register(HWND window_handle) {
272 if (registrations_.contains(window_handle)) 272 if (registrations_.contains(window_handle))
273 return; 273 return;
274 274
275 if (!EnableHooks()) 275 if (!EnableHooks())
276 return; 276 return;
277 277
278 scoped_ptr<KeyboardInterceptRegistration> registration( 278 scoped_ptr<KeyboardInterceptRegistration> registration(
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 409 }
410 return 1; 410 return 1;
411 } 411 }
412 } 412 }
413 413
414 return CallNextHookEx(NULL, code, w_param, l_param); 414 return CallNextHookEx(NULL, code, w_param, l_param);
415 } 415 }
416 } // namespace 416 } // namespace
417 417
418 KeyboardHookHandler* KeyboardHookHandler::GetInstance() { 418 KeyboardHookHandler* KeyboardHookHandler::GetInstance() {
419 return Singleton<KeyboardHookHandler, 419 return base::Singleton<KeyboardHookHandler, base::DefaultSingletonTraits<
420 DefaultSingletonTraits<KeyboardHookHandler>>::get(); 420 KeyboardHookHandler>>::get();
421 } 421 }
422 422
423 void KeyboardHookHandler::Register(views::Widget* widget) { 423 void KeyboardHookHandler::Register(views::Widget* widget) {
424 LowLevelHookHandler::GetInstance()->Register(GetWindowHandle(widget)); 424 LowLevelHookHandler::GetInstance()->Register(GetWindowHandle(widget));
425 } 425 }
426 426
427 void KeyboardHookHandler::Deregister(views::Widget* widget) { 427 void KeyboardHookHandler::Deregister(views::Widget* widget) {
428 LowLevelHookHandler::GetInstance()->Deregister(GetWindowHandle(widget)); 428 LowLevelHookHandler::GetInstance()->Deregister(GetWindowHandle(widget));
429 } 429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698