OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/mac/mac_util.h" | 5 #include "base/mac/mac_util.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #import <IOKit/IOKitLib.h> | 8 #import <IOKit/IOKitLib.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 DCHECK_GT(g_full_screen_requests[from_mode], 0); | 212 DCHECK_GT(g_full_screen_requests[from_mode], 0); |
213 DCHECK_GE(g_full_screen_requests[to_mode], 0); | 213 DCHECK_GE(g_full_screen_requests[to_mode], 0); |
214 g_full_screen_requests[from_mode] = | 214 g_full_screen_requests[from_mode] = |
215 std::max(g_full_screen_requests[from_mode] - 1, 0); | 215 std::max(g_full_screen_requests[from_mode] - 1, 0); |
216 g_full_screen_requests[to_mode] = | 216 g_full_screen_requests[to_mode] = |
217 std::max(g_full_screen_requests[to_mode] + 1, 1); | 217 std::max(g_full_screen_requests[to_mode] + 1, 1); |
218 SetUIMode(); | 218 SetUIMode(); |
219 } | 219 } |
220 | 220 |
221 bool AmIForeground() { | 221 bool AmIForeground() { |
222 ProcessSerialNumber foreground_psn = { 0 }; | 222 return [[NSApplication sharedApplication] isActive]; |
Nico
2016/10/05 14:19:39
Is [[NSRunningApplication currentApplication] isAc
Eugene But (OOO till 7-30)
2016/10/06 00:31:59
Yeah, that what I asked in the comments (should we
| |
223 OSErr err = GetFrontProcess(&foreground_psn); | |
224 if (err != noErr) { | |
225 OSSTATUS_DLOG(WARNING, err) << "GetFrontProcess"; | |
226 return false; | |
227 } | |
228 | |
229 ProcessSerialNumber my_psn = { 0, kCurrentProcess }; | |
230 | |
231 Boolean result = FALSE; | |
232 err = SameProcess(&foreground_psn, &my_psn, &result); | |
233 if (err != noErr) { | |
234 OSSTATUS_DLOG(WARNING, err) << "SameProcess"; | |
235 return false; | |
236 } | |
237 | |
238 return result; | |
239 } | 223 } |
240 | 224 |
241 bool SetFileBackupExclusion(const FilePath& file_path) { | 225 bool SetFileBackupExclusion(const FilePath& file_path) { |
242 NSString* file_path_ns = | 226 NSString* file_path_ns = |
243 [NSString stringWithUTF8String:file_path.value().c_str()]; | 227 [NSString stringWithUTF8String:file_path.value().c_str()]; |
244 NSURL* file_url = [NSURL fileURLWithPath:file_path_ns]; | 228 NSURL* file_url = [NSURL fileURLWithPath:file_path_ns]; |
245 | 229 |
246 // When excludeByPath is true the application must be running with root | 230 // When excludeByPath is true the application must be running with root |
247 // privileges (admin for 10.6 and earlier) but the URL does not have to | 231 // privileges (admin for 10.6 and earlier) but the URL does not have to |
248 // already exist. When excludeByPath is false the URL must already exist but | 232 // already exist. When excludeByPath is false the URL must already exist but |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 479 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
496 return false; | 480 return false; |
497 *type = ident.substr(0, number_loc); | 481 *type = ident.substr(0, number_loc); |
498 *major = major_tmp; | 482 *major = major_tmp; |
499 *minor = minor_tmp; | 483 *minor = minor_tmp; |
500 return true; | 484 return true; |
501 } | 485 } |
502 | 486 |
503 } // namespace mac | 487 } // namespace mac |
504 } // namespace base | 488 } // namespace base |
OLD | NEW |