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

Side by Side Diff: base/mac/mac_util.mm

Issue 2394733002: [Mac Fix-It] removed base::mac::AmIForeground function. (Closed)
Patch Set: Addressed review comment Created 4 years, 2 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
« no previous file with comments | « base/mac/mac_util.h ('k') | chrome/browser/mac/relauncher.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
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() {
222 ProcessSerialNumber foreground_psn = { 0 };
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 }
240
241 bool SetFileBackupExclusion(const FilePath& file_path) { 221 bool SetFileBackupExclusion(const FilePath& file_path) {
242 NSString* file_path_ns = 222 NSString* file_path_ns =
243 [NSString stringWithUTF8String:file_path.value().c_str()]; 223 [NSString stringWithUTF8String:file_path.value().c_str()];
244 NSURL* file_url = [NSURL fileURLWithPath:file_path_ns]; 224 NSURL* file_url = [NSURL fileURLWithPath:file_path_ns];
245 225
246 // When excludeByPath is true the application must be running with root 226 // 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 227 // 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 228 // already exist. When excludeByPath is false the URL must already exist but
249 // can be used in non-root (or admin as above) mode. We use false so that 229 // can be used in non-root (or admin as above) mode. We use false so that
250 // non-root (or admin) users don't get their TimeMachine drive filled up with 230 // non-root (or admin) users don't get their TimeMachine drive filled up with
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 475 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
496 return false; 476 return false;
497 *type = ident.substr(0, number_loc); 477 *type = ident.substr(0, number_loc);
498 *major = major_tmp; 478 *major = major_tmp;
499 *minor = minor_tmp; 479 *minor = minor_tmp;
500 return true; 480 return true;
501 } 481 }
502 482
503 } // namespace mac 483 } // namespace mac
504 } // namespace base 484 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/mac_util.h ('k') | chrome/browser/mac/relauncher.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698