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 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 395 } |
396 return IsHiddenLoginItem(item); | 396 return IsHiddenLoginItem(item); |
397 } | 397 } |
398 | 398 |
399 bool RemoveQuarantineAttribute(const FilePath& file_path) { | 399 bool RemoveQuarantineAttribute(const FilePath& file_path) { |
400 const char kQuarantineAttrName[] = "com.apple.quarantine"; | 400 const char kQuarantineAttrName[] = "com.apple.quarantine"; |
401 int status = removexattr(file_path.value().c_str(), kQuarantineAttrName, 0); | 401 int status = removexattr(file_path.value().c_str(), kQuarantineAttrName, 0); |
402 return status == 0 || errno == ENOATTR; | 402 return status == 0 || errno == ENOATTR; |
403 } | 403 } |
404 | 404 |
| 405 bool CharacterIsPrintable(unichar c) { |
| 406 switch (c) { |
| 407 case 0xf728: // Delete |
| 408 return false; |
| 409 } |
| 410 return true; |
| 411 } |
| 412 |
| 413 bool StringIsPrintable(NSString* s) { |
| 414 if (s.length == 0) |
| 415 return true; |
| 416 for (NSUInteger i = 0; i < s.length; ++i) { |
| 417 if (CharacterIsPrintable([s characterAtIndex:i])) |
| 418 return true; |
| 419 } |
| 420 return false; |
| 421 } |
| 422 |
405 namespace { | 423 namespace { |
406 | 424 |
407 // Returns the running system's Darwin major version. Don't call this, it's | 425 // Returns the running system's Darwin major version. Don't call this, it's |
408 // an implementation detail and its result is meant to be cached by | 426 // an implementation detail and its result is meant to be cached by |
409 // MacOSXMinorVersion. | 427 // MacOSXMinorVersion. |
410 int DarwinMajorVersionInternal() { | 428 int DarwinMajorVersionInternal() { |
411 // base::OperatingSystemVersionNumbers calls Gestalt, which is a | 429 // base::OperatingSystemVersionNumbers calls Gestalt, which is a |
412 // higher-level operation than is needed. It might perform unnecessary | 430 // higher-level operation than is needed. It might perform unnecessary |
413 // operations. On 10.6, it was observed to be able to spawn threads (see | 431 // operations. On 10.6, it was observed to be able to spawn threads (see |
414 // http://crbug.com/53200). It might also read files or perform other | 432 // http://crbug.com/53200). It might also read files or perform other |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 616 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
599 return false; | 617 return false; |
600 *type = ident.substr(0, number_loc); | 618 *type = ident.substr(0, number_loc); |
601 *major = major_tmp; | 619 *major = major_tmp; |
602 *minor = minor_tmp; | 620 *minor = minor_tmp; |
603 return true; | 621 return true; |
604 } | 622 } |
605 | 623 |
606 } // namespace mac | 624 } // namespace mac |
607 } // namespace base | 625 } // namespace base |
OLD | NEW |