Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef CONTENT_BROWSER_COCOA_SYSTEM_HOTKEY_HELPER_MAC_H_ | |
| 6 #define CONTENT_BROWSER_COCOA_SYSTEM_HOTKEY_HELPER_MAC_H_ | |
| 7 | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 | |
| 11 #ifdef __OBJC__ | |
| 12 @class NSData; | |
| 13 #else | |
| 14 class NSData; | |
| 15 #endif | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class SystemHotkeyMap; | |
| 20 | |
| 21 class SystemHotkeyHelperMac { | |
|
Robert Sesek
2014/07/08 13:40:00
Does this need to be its own class? It's small eno
erikchen
2014/07/10 02:07:31
It would technically be possible to finesse the Sy
| |
| 22 public: | |
| 23 // Return pointer to the singleton instance for the current process. | |
| 24 static SystemHotkeyHelperMac* GetInstance(); | |
| 25 | |
| 26 // Loads the system hot keys after a brief delay, to reduce file system access | |
| 27 // immediately after launch. | |
| 28 void DeferredLoadSystemHotkeys(); | |
| 29 | |
| 30 // Guaranteed to not be NULL. | |
| 31 SystemHotkeyMap* map() { return map_.get(); } | |
| 32 | |
| 33 private: | |
| 34 friend struct DefaultSingletonTraits<SystemHotkeyHelperMac>; | |
| 35 | |
| 36 SystemHotkeyHelperMac(); | |
| 37 virtual ~SystemHotkeyHelperMac(); | |
| 38 | |
| 39 // Must be called from the UI thread. Invokes LoadFile from the FILE thread. | |
| 40 void LoadSystemHotkeys(); | |
| 41 | |
| 42 // Must be called from the FILE thread. Loads the file containing the system | |
| 43 // hotkeys into a NSData* object, and passes the result to FileDidLoad on the | |
| 44 // UI thread. | |
| 45 void LoadFile(); | |
| 46 | |
| 47 // Must be called from the UI thread. |data| should have a retain count of | |
| 48 // +1. This method will release |data|. Parses the system hotkeys from the | |
| 49 // plist stored in |data|. | |
| 50 void FileDidLoad(NSData* data); | |
| 51 | |
| 52 scoped_ptr<SystemHotkeyMap> map_; | |
|
Robert Sesek
2014/07/08 13:40:00
Any reason this needs to be a pointer instead of j
erikchen
2014/07/10 02:07:31
Yes, for it to be a member, I'd have to move the #
| |
| 53 base::WeakPtrFactory<SystemHotkeyHelperMac> weak_ptr_factory_; | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(SystemHotkeyHelperMac); | |
| 56 }; | |
| 57 | |
| 58 } // namespace content | |
| 59 | |
| 60 #endif // CONTENT_BROWSER_COCOA_SYSTEM_HOTKEY_HELPER_MAC_H_ | |
| OLD | NEW |