| 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 "chrome/browser/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 6 | 6 |
| 7 #include "apps/saved_files_service.h" | 7 #include "apps/saved_files_service.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // directory, and should be whitelisted. | 78 // directory, and should be whitelisted. |
| 79 const int kWhitelistedPaths[] = { | 79 const int kWhitelistedPaths[] = { |
| 80 chrome::DIR_DEFAULT_DOWNLOADS_SAFE, | 80 chrome::DIR_DEFAULT_DOWNLOADS_SAFE, |
| 81 }; | 81 }; |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 #if defined(OS_MACOSX) | 84 #if defined(OS_MACOSX) |
| 85 // Retrieves the localized display name for the base name of the given path. | 85 // Retrieves the localized display name for the base name of the given path. |
| 86 // If the path is not localized, this will just return the base name. | 86 // If the path is not localized, this will just return the base name. |
| 87 std::string GetDisplayBaseName(const base::FilePath& path) { | 87 std::string GetDisplayBaseName(const base::FilePath& path) { |
| 88 base::mac::ScopedCFTypeRef<CFURLRef> url( | 88 base::ScopedCFTypeRef<CFURLRef> url(CFURLCreateFromFileSystemRepresentation( |
| 89 CFURLCreateFromFileSystemRepresentation( | 89 NULL, (const UInt8*)path.value().c_str(), path.value().length(), true)); |
| 90 NULL, | |
| 91 (const UInt8*)path.value().c_str(), | |
| 92 path.value().length(), | |
| 93 true)); | |
| 94 if (!url) | 90 if (!url) |
| 95 return path.BaseName().value(); | 91 return path.BaseName().value(); |
| 96 | 92 |
| 97 CFStringRef str; | 93 CFStringRef str; |
| 98 if (LSCopyDisplayNameForURL(url, &str) != noErr) | 94 if (LSCopyDisplayNameForURL(url, &str) != noErr) |
| 99 return path.BaseName().value(); | 95 return path.BaseName().value(); |
| 100 | 96 |
| 101 std::string result(base::SysCFStringRefToUTF8(str)); | 97 std::string result(base::SysCFStringRefToUTF8(str)); |
| 102 CFRelease(str); | 98 CFRelease(str); |
| 103 return result; | 99 return result; |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 // ID that was passed to restoreEntry. | 837 // ID that was passed to restoreEntry. |
| 842 RegisterFileSystemAndSendResponseWithIdOverride( | 838 RegisterFileSystemAndSendResponseWithIdOverride( |
| 843 file_entry->path, | 839 file_entry->path, |
| 844 file_entry->writable ? WRITABLE : READ_ONLY, | 840 file_entry->writable ? WRITABLE : READ_ONLY, |
| 845 file_entry->id); | 841 file_entry->id); |
| 846 } | 842 } |
| 847 return true; | 843 return true; |
| 848 } | 844 } |
| 849 | 845 |
| 850 } // namespace extensions | 846 } // namespace extensions |
| OLD | NEW |