Index: chrome/browser/platform_util_mac.mm |
diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm |
index 20afdcd498551dc62f38e74f641dbd444b5b4003..260748d1a55f034eeff644673aaaaf6bef3007b1 100644 |
--- a/chrome/browser/platform_util_mac.mm |
+++ b/chrome/browser/platform_util_mac.mm |
@@ -8,11 +8,14 @@ |
#import <Cocoa/Cocoa.h> |
#include <CoreServices/CoreServices.h> |
+#include "base/bind.h" |
+#include "base/file_util.h" |
#include "base/files/file_path.h" |
#include "base/logging.h" |
#include "base/mac/mac_logging.h" |
#include "base/mac/scoped_aedesc.h" |
#include "base/strings/sys_string_conversions.h" |
+#include "content/public/browser/browser_thread.h" |
#include "url/gurl.h" |
namespace platform_util { |
@@ -32,7 +35,7 @@ void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) { |
// 2. Silent no-op for unassociated file types: http://crbug.com/50263 |
// Instead, an AppleEvent is constructed to tell the Finder to open the |
// document. |
-void OpenItem(Profile* profile, const base::FilePath& full_path) { |
+void OpenFile(Profile* profile, const base::FilePath& full_path) { |
DCHECK([NSThread isMainThread]); |
NSString* path_string = base::SysUTF8ToNSString(full_path.value()); |
if (!path_string) |
@@ -46,7 +49,7 @@ void OpenItem(Profile* profile, const base::FilePath& full_path) { |
sizeof(finderCreatorCode), // dataSize |
address.OutPointer()); // result |
if (status != noErr) { |
- OSSTATUS_LOG(WARNING, status) << "Could not create OpenItem() AE target"; |
+ OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE target"; |
return; |
} |
@@ -59,7 +62,7 @@ void OpenItem(Profile* profile, const base::FilePath& full_path) { |
kAnyTransactionID, // transactionID |
theEvent.OutPointer()); // result |
if (status != noErr) { |
- OSSTATUS_LOG(WARNING, status) << "Could not create OpenItem() AE event"; |
+ OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE event"; |
return; |
} |
@@ -70,7 +73,7 @@ void OpenItem(Profile* profile, const base::FilePath& full_path) { |
false, // isRecord |
fileList.OutPointer()); // resultList |
if (status != noErr) { |
- OSSTATUS_LOG(WARNING, status) << "Could not create OpenItem() AE file list"; |
+ OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE file list"; |
return; |
} |
@@ -86,11 +89,11 @@ void OpenItem(Profile* profile, const base::FilePath& full_path) { |
sizeof(pathRef)); // dataSize |
if (status != noErr) { |
OSSTATUS_LOG(WARNING, status) |
- << "Could not add file path to AE list in OpenItem()"; |
+ << "Could not add file path to AE list in OpenFile()"; |
return; |
} |
} else { |
- LOG(WARNING) << "Could not get FSRef for path URL in OpenItem()"; |
+ LOG(WARNING) << "Could not get FSRef for path URL in OpenFile()"; |
return; |
} |
@@ -100,7 +103,7 @@ void OpenItem(Profile* profile, const base::FilePath& full_path) { |
fileList); // theAEDesc |
if (status != noErr) { |
OSSTATUS_LOG(WARNING, status) |
- << "Could not put the AE file list the path in OpenItem()"; |
+ << "Could not put the AE file list the path in OpenFile()"; |
return; |
} |
@@ -115,10 +118,28 @@ void OpenItem(Profile* profile, const base::FilePath& full_path) { |
NULL); // filterProc |
if (status != noErr) { |
OSSTATUS_LOG(WARNING, status) |
- << "Could not send AE to Finder in OpenItem()"; |
+ << "Could not send AE to Finder in OpenFile()"; |
} |
} |
+namespace { |
+ |
+void OpenFolderOnBlockingThread(const base::FilePath& full_path) { |
+ if (!base::DirectoryExists(full_path)) |
+ return; |
+ NSString* path = base::SysUTF8ToNSString(full_path.value()); |
+ if (!path) |
+ return; |
+ [[NSWorkspace sharedWorkspace] openFile:path withApplication:@"Finder"]; |
+} |
+ |
+} // namespace |
+ |
+void OpenFolder(Profile* profile, const base::FilePath& full_path) { |
+ content::BrowserThread::PostBlockingPoolTask( |
+ FROM_HERE, base::Bind(&OpenFolderOnBlockingThread, full_path)); |
+} |
+ |
void OpenExternal(Profile* profile, const GURL& url) { |
DCHECK([NSThread isMainThread]); |
NSString* url_string = base::SysUTF8ToNSString(url.spec()); |