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

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

Issue 1849343003: mac: Remove IsOSSnowLeopard(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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') | base/mac/mac_util_unittest.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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 parent_info.processInfoLength = sizeof(parent_info); 351 parent_info.processInfoLength = sizeof(parent_info);
352 if (GetProcessInformation(&info.processLauncher, &parent_info) == noErr) 352 if (GetProcessInformation(&info.processLauncher, &parent_info) == noErr)
353 return parent_info.processSignature == 'lgnw'; 353 return parent_info.processSignature == 'lgnw';
354 } 354 }
355 return false; 355 return false;
356 } 356 }
357 357
358 bool WasLaunchedAsLoginItemRestoreState() { 358 bool WasLaunchedAsLoginItemRestoreState() {
359 // "Reopen windows..." option was added for Lion. Prior OS versions should 359 // "Reopen windows..." option was added for Lion. Prior OS versions should
360 // not have this behavior. 360 // not have this behavior.
361 if (IsOSSnowLeopard() || !WasLaunchedAsLoginOrResumeItem()) 361 if (!WasLaunchedAsLoginOrResumeItem())
362 return false; 362 return false;
363 363
364 CFStringRef app = CFSTR("com.apple.loginwindow"); 364 CFStringRef app = CFSTR("com.apple.loginwindow");
365 CFStringRef save_state = CFSTR("TALLogoutSavesState"); 365 CFStringRef save_state = CFSTR("TALLogoutSavesState");
366 ScopedCFTypeRef<CFPropertyListRef> plist( 366 ScopedCFTypeRef<CFPropertyListRef> plist(
367 CFPreferencesCopyAppValue(save_state, app)); 367 CFPreferencesCopyAppValue(save_state, app));
368 // According to documentation, com.apple.loginwindow.plist does not exist on a 368 // According to documentation, com.apple.loginwindow.plist does not exist on a
369 // fresh installation until the user changes a login window setting. The 369 // fresh installation until the user changes a login window setting. The
370 // "reopen windows" option is checked by default, so the plist would exist had 370 // "reopen windows" option is checked by default, so the plist would exist had
371 // the user unchecked it. 371 // the user unchecked it.
372 // https://developer.apple.com/library/mac/documentation/macosx/conceptual/bps ystemstartup/chapters/CustomLogin.html 372 // https://developer.apple.com/library/mac/documentation/macosx/conceptual/bps ystemstartup/chapters/CustomLogin.html
373 if (!plist) 373 if (!plist)
374 return true; 374 return true;
375 375
376 if (CFBooleanRef restore_state = base::mac::CFCast<CFBooleanRef>(plist)) 376 if (CFBooleanRef restore_state = base::mac::CFCast<CFBooleanRef>(plist))
377 return CFBooleanGetValue(restore_state); 377 return CFBooleanGetValue(restore_state);
378 378
379 return false; 379 return false;
380 } 380 }
381 381
382 bool WasLaunchedAsHiddenLoginItem() { 382 bool WasLaunchedAsHiddenLoginItem() {
383 if (!WasLaunchedAsLoginOrResumeItem()) 383 if (!WasLaunchedAsLoginOrResumeItem())
384 return false; 384 return false;
385 385
386 ScopedCFTypeRef<LSSharedFileListItemRef> item(GetLoginItemForApp()); 386 ScopedCFTypeRef<LSSharedFileListItemRef> item(GetLoginItemForApp());
387 if (!item.get()) { 387 if (!item.get()) {
388 // Lion can launch items for the resume feature. So log an error only for 388 // OS X can launch items for the resume feature.
389 // Snow Leopard or earlier.
390 if (IsOSSnowLeopard())
391 DLOG(ERROR) <<
392 "Process launched at Login but can't access Login Item List.";
393
394 return false; 389 return false;
395 } 390 }
396 return IsHiddenLoginItem(item); 391 return IsHiddenLoginItem(item);
397 } 392 }
398 393
399 bool RemoveQuarantineAttribute(const FilePath& file_path) { 394 bool RemoveQuarantineAttribute(const FilePath& file_path) {
400 const char kQuarantineAttrName[] = "com.apple.quarantine"; 395 const char kQuarantineAttrName[] = "com.apple.quarantine";
401 int status = removexattr(file_path.value().c_str(), kQuarantineAttrName, 0); 396 int status = removexattr(file_path.value().c_str(), kQuarantineAttrName, 0);
402 return status == 0 || errno == ENOATTR; 397 return status == 0 || errno == ENOATTR;
403 } 398 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 SNOW_LEOPARD_MINOR_VERSION = 6, 476 SNOW_LEOPARD_MINOR_VERSION = 6,
482 LION_MINOR_VERSION = 7, 477 LION_MINOR_VERSION = 7,
483 MOUNTAIN_LION_MINOR_VERSION = 8, 478 MOUNTAIN_LION_MINOR_VERSION = 8,
484 MAVERICKS_MINOR_VERSION = 9, 479 MAVERICKS_MINOR_VERSION = 9,
485 YOSEMITE_MINOR_VERSION = 10, 480 YOSEMITE_MINOR_VERSION = 10,
486 EL_CAPITAN_MINOR_VERSION = 11, 481 EL_CAPITAN_MINOR_VERSION = 11,
487 }; 482 };
488 483
489 } // namespace 484 } // namespace
490 485
491 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
492 bool IsOSSnowLeopard() {
493 return MacOSXMinorVersion() == SNOW_LEOPARD_MINOR_VERSION;
494 }
495 #endif
496
497 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7) 486 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7)
498 bool IsOSLion() { 487 bool IsOSLion() {
499 return MacOSXMinorVersion() == LION_MINOR_VERSION; 488 return MacOSXMinorVersion() == LION_MINOR_VERSION;
500 } 489 }
501 #endif 490 #endif
502 491
503 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) 492 #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
504 bool IsOSLionOrLater() { 493 bool IsOSLionOrLater() {
505 return MacOSXMinorVersion() >= LION_MINOR_VERSION; 494 return MacOSXMinorVersion() >= LION_MINOR_VERSION;
506 } 495 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 587 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
599 return false; 588 return false;
600 *type = ident.substr(0, number_loc); 589 *type = ident.substr(0, number_loc);
601 *major = major_tmp; 590 *major = major_tmp;
602 *minor = minor_tmp; 591 *minor = minor_tmp;
603 return true; 592 return true;
604 } 593 }
605 594
606 } // namespace mac 595 } // namespace mac
607 } // namespace base 596 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/mac_util.h ('k') | base/mac/mac_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698