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

Side by Side Diff: mac/foundation_util.mm

Issue 2050803003: Update to Chromium //base at Chromium commit e3a753f17bac62738b0dbf0b36510f767b081e4b. (Closed) Base URL: https://github.com/domokit/base.git@master
Patch Set: Created 4 years, 6 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 | « mac/foundation_util.h ('k') | mac/foundation_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/foundation_util.h" 5 #include "base/mac/foundation_util.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/mac/bundle_locations.h" 12 #include "base/mac/bundle_locations.h"
13 #include "base/mac/mac_logging.h" 13 #include "base/mac/mac_logging.h"
14 #include "base/numerics/safe_conversions.h"
14 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
15 16
16 #if !defined(OS_IOS) 17 #if !defined(OS_IOS)
17 extern "C" { 18 extern "C" {
18 CFTypeID SecACLGetTypeID(); 19 CFTypeID SecACLGetTypeID();
19 CFTypeID SecTrustedApplicationGetTypeID(); 20 CFTypeID SecTrustedApplicationGetTypeID();
20 Boolean _CFIsObjC(CFTypeID typeID, CFTypeRef obj); 21 Boolean _CFIsObjC(CFTypeID typeID, CFTypeRef obj);
21 } // extern "C" 22 } // extern "C"
22 #endif 23 #endif
23 24
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 return nil; 424 return nil;
424 return [NSString stringWithUTF8String:path.value().c_str()]; 425 return [NSString stringWithUTF8String:path.value().c_str()];
425 } 426 }
426 427
427 FilePath NSStringToFilePath(NSString* str) { 428 FilePath NSStringToFilePath(NSString* str) {
428 if (![str length]) 429 if (![str length])
429 return FilePath(); 430 return FilePath();
430 return FilePath([str fileSystemRepresentation]); 431 return FilePath([str fileSystemRepresentation]);
431 } 432 }
432 433
434 bool CFRangeToNSRange(CFRange range, NSRange* range_out) {
435 if (base::IsValueInRangeForNumericType<decltype(range_out->location)>(
436 range.location) &&
437 base::IsValueInRangeForNumericType<decltype(range_out->length)>(
438 range.length) &&
439 base::IsValueInRangeForNumericType<decltype(range_out->location)>(
440 range.location + range.length)) {
441 *range_out = NSMakeRange(range.location, range.length);
442 return true;
443 }
444 return false;
445 }
446
433 } // namespace mac 447 } // namespace mac
434 } // namespace base 448 } // namespace base
435 449
436 std::ostream& operator<<(std::ostream& o, const CFStringRef string) { 450 std::ostream& operator<<(std::ostream& o, const CFStringRef string) {
437 return o << base::SysCFStringRefToUTF8(string); 451 return o << base::SysCFStringRefToUTF8(string);
438 } 452 }
439 453
440 std::ostream& operator<<(std::ostream& o, const CFErrorRef err) { 454 std::ostream& operator<<(std::ostream& o, const CFErrorRef err) {
441 base::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(err)); 455 base::ScopedCFTypeRef<CFStringRef> desc(CFErrorCopyDescription(err));
442 base::ScopedCFTypeRef<CFDictionaryRef> user_info(CFErrorCopyUserInfo(err)); 456 base::ScopedCFTypeRef<CFDictionaryRef> user_info(CFErrorCopyUserInfo(err));
443 CFStringRef errorDesc = NULL; 457 CFStringRef errorDesc = NULL;
444 if (user_info.get()) { 458 if (user_info.get()) {
445 errorDesc = reinterpret_cast<CFStringRef>( 459 errorDesc = reinterpret_cast<CFStringRef>(
446 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); 460 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey));
447 } 461 }
448 o << "Code: " << CFErrorGetCode(err) 462 o << "Code: " << CFErrorGetCode(err)
449 << " Domain: " << CFErrorGetDomain(err) 463 << " Domain: " << CFErrorGetDomain(err)
450 << " Desc: " << desc.get(); 464 << " Desc: " << desc.get();
451 if(errorDesc) { 465 if(errorDesc) {
452 o << "(" << errorDesc << ")"; 466 o << "(" << errorDesc << ")";
453 } 467 }
454 return o; 468 return o;
455 } 469 }
OLDNEW
« no previous file with comments | « mac/foundation_util.h ('k') | mac/foundation_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698