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

Unified Diff: chrome/browser/platform_util_mac.mm

Issue 2137453003: mac: Remove IsOSMavericksOrLater() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cfallocator_1012
Patch Set: rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | content/app/mac/mac_init.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/platform_util_mac.mm
diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm
index 507b23bd23ab8a6cb21a9eb051c33b8e78e0efd2..cb0c3096ddb7cad41bf734498f21136748322875 100644
--- a/chrome/browser/platform_util_mac.mm
+++ b/chrome/browser/platform_util_mac.mm
@@ -4,17 +4,13 @@
#include "chrome/browser/platform_util.h"
-#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
-#include <CoreServices/CoreServices.h>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/mac/mac_logging.h"
-#import "base/mac/mac_util.h"
-#include "base/mac/scoped_aedesc.h"
#import "base/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/platform_util_internal.h"
@@ -41,104 +37,17 @@ void OpenFileOnMainThread(const base::FilePath& full_path) {
// properly handle Finder activation for quarantined files
// (http://crbug.com/32921) and unassociated file types
// (http://crbug.com/50263).
- if (base::mac::IsOSMavericksOrLater()) {
- NSURL* url = [NSURL fileURLWithPath:path_string];
- if (!url)
- return;
-
- const NSWorkspaceLaunchOptions launch_options =
- NSWorkspaceLaunchAsync | NSWorkspaceLaunchWithErrorPresentation;
- [[NSWorkspace sharedWorkspace] openURLs:@[ url ]
- withAppBundleIdentifier:nil
- options:launch_options
- additionalEventParamDescriptor:nil
- launchIdentifiers:NULL];
- return;
- }
-
- // On older OSes, both LaunchServices and NSWorkspace will fail silently for
- // the two cases described above. On those platforms, use an AppleEvent to
- // instruct the Finder to open the file.
-
- // Create the target of this AppleEvent, the Finder.
- base::mac::ScopedAEDesc<AEAddressDesc> address;
- const OSType finderCreatorCode = 'MACS';
- OSErr status = AECreateDesc(typeApplSignature, // type
- &finderCreatorCode, // data
- sizeof(finderCreatorCode), // dataSize
- address.OutPointer()); // result
- if (status != noErr) {
- OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE target";
- return;
- }
-
- // Build the AppleEvent data structure that instructs Finder to open files.
- base::mac::ScopedAEDesc<AppleEvent> theEvent;
- status = AECreateAppleEvent(kCoreEventClass, // theAEEventClass
- kAEOpenDocuments, // theAEEventID
- address, // target
- kAutoGenerateReturnID, // returnID
- kAnyTransactionID, // transactionID
- theEvent.OutPointer()); // result
- if (status != noErr) {
- OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE event";
- return;
- }
-
- // Create the list of files (only ever one) to open.
- base::mac::ScopedAEDesc<AEDescList> fileList;
- status = AECreateList(NULL, // factoringPtr
- 0, // factoredSize
- false, // isRecord
- fileList.OutPointer()); // resultList
- if (status != noErr) {
- OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE file list";
- return;
- }
-
- // Add the single path to the file list. C-style cast to avoid both a
- // static_cast and a const_cast to get across the toll-free bridge.
- CFURLRef pathURLRef = (CFURLRef)[NSURL fileURLWithPath:path_string];
- FSRef pathRef;
- if (CFURLGetFSRef(pathURLRef, &pathRef)) {
- status = AEPutPtr(fileList.OutPointer(), // theAEDescList
- 0, // index
- typeFSRef, // typeCode
- &pathRef, // dataPtr
- sizeof(pathRef)); // dataSize
- if (status != noErr) {
- OSSTATUS_LOG(WARNING, status)
- << "Could not add file path to AE list in OpenFile()";
- return;
- }
- } else {
- LOG(WARNING) << "Could not get FSRef for path URL in OpenFile()";
+ NSURL* url = [NSURL fileURLWithPath:path_string];
+ if (!url)
return;
- }
- // Attach the file list to the AppleEvent.
- status = AEPutParamDesc(theEvent.OutPointer(), // theAppleEvent
- keyDirectObject, // theAEKeyword
- fileList); // theAEDesc
- if (status != noErr) {
- OSSTATUS_LOG(WARNING, status)
- << "Could not put the AE file list the path in OpenFile()";
- return;
- }
-
- // Send the actual event. Do not care about the reply.
- base::mac::ScopedAEDesc<AppleEvent> reply;
- status = AESend(theEvent, // theAppleEvent
- reply.OutPointer(), // reply
- kAENoReply + kAEAlwaysInteract, // sendMode
- kAENormalPriority, // sendPriority
- kAEDefaultTimeout, // timeOutInTicks
- NULL, // idleProc
- NULL); // filterProc
- if (status != noErr) {
- OSSTATUS_LOG(WARNING, status)
- << "Could not send AE to Finder in OpenFile()";
- }
+ const NSWorkspaceLaunchOptions launch_options =
+ NSWorkspaceLaunchAsync | NSWorkspaceLaunchWithErrorPresentation;
+ [[NSWorkspace sharedWorkspace] openURLs:@[ url ]
+ withAppBundleIdentifier:nil
+ options:launch_options
+ additionalEventParamDescriptor:nil
+ launchIdentifiers:NULL];
}
namespace internal {
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | content/app/mac/mac_init.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698