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

Side by Side Diff: content/browser/cocoa/system_hotkey_helper_mac.mm

Issue 374643002: Mac: Enable delegated renderer by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 "content/browser/cocoa/system_hotkey_helper_mac.h"
6
7 #include "base/bind.h"
8 #include "base/files/file_path.h"
9 #include "base/mac/foundation_util.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram.h"
12 #include "content/browser/cocoa/system_hotkey_map.h"
13 #include "content/public/browser/browser_thread.h"
14
15 namespace {
16
17 NSString* kSystemHotkeyPlistExtension =
18 @"/Preferences/com.apple.symbolichotkeys.plist";
19
20 // Amount of time to delay loading the hotkeys in seconds.
21 const int kLoadHotkeysDelaySeconds = 10;
22
23 } // namespace
24
25 namespace content {
26
27 // static
28 SystemHotkeyHelperMac* SystemHotkeyHelperMac::GetInstance() {
29 return Singleton<SystemHotkeyHelperMac>::get();
30 }
31
32 void SystemHotkeyHelperMac::DeferredLoadSystemHotkeys() {
33 BrowserThread::PostDelayedTask(
34 BrowserThread::FILE,
35 FROM_HERE,
36 base::Bind(&SystemHotkeyHelperMac::LoadSystemHotkeys,
37 base::Unretained(this)),
38 base::TimeDelta::FromSeconds(kLoadHotkeysDelaySeconds));
39 }
40
41 SystemHotkeyHelperMac::SystemHotkeyHelperMac() : map_(new SystemHotkeyMap) {
42 }
43
44 SystemHotkeyHelperMac::~SystemHotkeyHelperMac() {
45 }
46
47 void SystemHotkeyHelperMac::LoadSystemHotkeys() {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
49
50 std::string library_path(base::mac::GetUserLibraryPath().value());
51 NSString* expanded_file_path =
52 [NSString stringWithFormat:@"%s%@",
53 library_path.c_str(),
54 kSystemHotkeyPlistExtension];
55
56 // Loads the file into memory.
57 NSData* data = [NSData dataWithContentsOfFile:expanded_file_path];
58 // Intentionally create the object with +1 retain count, as FileDidLoad
59 // will destroy the object.
60 NSDictionary* dictionary = [SystemHotkeyMap::DictionaryFromData(data) retain];
61
62 BrowserThread::PostTask(BrowserThread::UI,
63 FROM_HERE,
64 base::Bind(&SystemHotkeyHelperMac::FileDidLoad,
65 base::Unretained(this),
66 dictionary));
67 }
68
69 void SystemHotkeyHelperMac::FileDidLoad(NSDictionary* dictionary) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
71
72 bool success = map()->ParseDictionary(dictionary);
73 UMA_HISTOGRAM_BOOLEAN("OSX.SystemHotkeyMap.LoadSuccess", success);
74 [dictionary release];
75 }
76
77 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cocoa/system_hotkey_helper_mac.h ('k') | content/browser/cocoa/system_hotkey_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698