OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 return false; | 473 return false; |
474 | 474 |
475 ScopedCFTypeRef<LSSharedFileListItemRef> item(GetLoginItemForApp()); | 475 ScopedCFTypeRef<LSSharedFileListItemRef> item(GetLoginItemForApp()); |
476 if (!item.get()) { | 476 if (!item.get()) { |
477 LOG(ERROR) << "Process launched at Login but can't access Login Item List."; | 477 LOG(ERROR) << "Process launched at Login but can't access Login Item List."; |
478 return false; | 478 return false; |
479 } | 479 } |
480 return IsHiddenLoginItem(item); | 480 return IsHiddenLoginItem(item); |
481 } | 481 } |
482 | 482 |
483 // Definitionsfor the corresponding CF_TO_NS_CAST_DECL macros in mac_util.h. | |
Avi (use Gerrit)
2011/03/02 22:26:33
drive by: "Definitionsfor" needs a space.
dmac
2011/03/02 22:29:02
Done.
| |
484 #define CF_TO_NS_CAST_DEFN(TypeCF, TypeNS) \ | |
485 \ | |
486 TypeNS* CFToNSCast(TypeCF##Ref cf_val) { \ | |
487 DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \ | |
488 TypeNS* ns_val = \ | |
489 const_cast<TypeNS*>(reinterpret_cast<const TypeNS*>(cf_val)); \ | |
490 return ns_val; \ | |
491 } \ | |
492 \ | |
493 TypeCF##Ref NSToCFCast(TypeNS* ns_val) { \ | |
494 TypeCF##Ref cf_val = reinterpret_cast<TypeCF##Ref>(ns_val); \ | |
495 DCHECK(!cf_val || TypeCF##GetTypeID() == CFGetTypeID(cf_val)); \ | |
496 return cf_val; \ | |
497 } \ | |
498 | |
499 #define CF_TO_NS_MUTABLE_CAST_DEFN(name) \ | |
500 CF_TO_NS_CAST_DEFN(CF##name, NS##name) \ | |
501 \ | |
502 NSMutable##name* CFToNSCast(CFMutable##name##Ref cf_val) { \ | |
503 DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \ | |
504 NSMutable##name* ns_val = reinterpret_cast<NSMutable##name*>(cf_val); \ | |
505 return ns_val; \ | |
506 } \ | |
507 \ | |
508 CFMutable##name##Ref NSToCFCast(NSMutable##name* ns_val) { \ | |
509 CFMutable##name##Ref cf_val = \ | |
510 reinterpret_cast<CFMutable##name##Ref>(ns_val); \ | |
511 DCHECK(!cf_val || CF##name##GetTypeID() == CFGetTypeID(cf_val)); \ | |
512 return cf_val; \ | |
513 } \ | |
514 | |
515 CF_TO_NS_MUTABLE_CAST_DEFN(Array); | |
516 CF_TO_NS_MUTABLE_CAST_DEFN(AttributedString); | |
517 CF_TO_NS_CAST_DEFN(CFCalendar, NSCalendar); | |
518 CF_TO_NS_MUTABLE_CAST_DEFN(CharacterSet); | |
519 CF_TO_NS_MUTABLE_CAST_DEFN(Data); | |
520 CF_TO_NS_CAST_DEFN(CFDate, NSDate); | |
521 CF_TO_NS_MUTABLE_CAST_DEFN(Dictionary); | |
522 CF_TO_NS_CAST_DEFN(CFError, NSError); | |
523 CF_TO_NS_CAST_DEFN(CFLocale, NSLocale); | |
524 CF_TO_NS_CAST_DEFN(CFNumber, NSNumber); | |
525 CF_TO_NS_CAST_DEFN(CFRunLoopTimer, NSTimer); | |
526 CF_TO_NS_CAST_DEFN(CFTimeZone, NSTimeZone); | |
527 CF_TO_NS_MUTABLE_CAST_DEFN(Set); | |
528 CF_TO_NS_CAST_DEFN(CFReadStream, NSInputStream); | |
529 CF_TO_NS_CAST_DEFN(CFWriteStream, NSOutputStream); | |
530 CF_TO_NS_MUTABLE_CAST_DEFN(String); | |
531 CF_TO_NS_CAST_DEFN(CFURL, NSURL); | |
532 | |
483 } // namespace mac | 533 } // namespace mac |
484 } // namespace base | 534 } // namespace base |
535 | |
536 std::ostream& operator<<(std::ostream& o, const CFStringRef string) { | |
537 return o << base::SysCFStringRefToUTF8(string); | |
538 } | |
539 | |
540 std::ostream& operator<<(std::ostream& o, const CFErrorRef err) { | |
541 base::mac::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(err)); | |
542 base::mac::ScopedCFTypeRef<CFDictionaryRef> user_info( | |
543 CFErrorCopyUserInfo(err)); | |
544 CFStringRef errorDesc = NULL; | |
545 if (user_info.get()) { | |
546 errorDesc = reinterpret_cast<CFStringRef>( | |
547 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); | |
548 } | |
549 o << "Code: " << CFErrorGetCode(err) | |
550 << " Domain: " << CFErrorGetDomain(err) | |
551 << " Desc: " << desc.get(); | |
552 if(errorDesc) { | |
553 o << "(" << errorDesc << ")"; | |
554 } | |
555 return o; | |
556 } | |
OLD | NEW |