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

Side by Side Diff: base/mac/launch_services_util.mm

Issue 2398853002: Remove deprecated APIs from OpenApplicationWithPath. (Closed)
Patch Set: More cleanup. Created 4 years, 2 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 | « base/mac/launch_services_util.cc ('k') | chrome/app_shim/chrome_main_app_mode_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/mac/launch_services_util.h"
6
7 #import <AppKit/AppKit.h>
8
9 #include "base/logging.h"
10 #include "base/mac/mac_logging.h"
11 #include "base/mac/mac_util.h"
12 #include "base/mac/scoped_cftyperef.h"
13 #include "base/mac/scoped_nsobject.h"
14 #include "base/strings/sys_string_conversions.h"
15
16 namespace base {
17 namespace mac {
18
19 bool OpenApplicationWithPath(const base::FilePath& bundle_path,
20 const CommandLine& command_line,
21 NSWorkspaceLaunchOptions launch_flags,
22 NSAppleEventDescriptor* descriptor,
23 pid_t* pid) {
24 const std::vector<std::string>& argv = command_line.argv();
25 int argc = argv.size();
26 base::scoped_nsobject<NSMutableArray> launch_args(
27 [[NSMutableArray alloc] initWithCapacity:argc - 1]);
28
29 for (int i = 1; i < argc; ++i) {
30 const std::string& arg(argv[i]);
31 [launch_args addObject:base::SysUTF8ToNSString(arg)];
32 }
33
34 NSURL* url =
35 [NSURL fileURLWithPath:base::SysUTF8ToNSString(bundle_path.value())];
36 base::scoped_nsobject<NSMutableDictionary> configuration(
37 [[NSMutableDictionary alloc] init]);
38 [configuration setObject:launch_args
39 forKey:NSWorkspaceLaunchConfigurationArguments];
40 if (descriptor)
41 [configuration setObject:descriptor
42 forKey:NSWorkspaceLaunchConfigurationAppleEvent];
43
44 NSError* error = nil;
45 NSRunningApplication* application =
46 [[NSWorkspace sharedWorkspace] launchApplicationAtURL:url
47 options:launch_flags
48 configuration:configuration
49 error:&error];
50
51 if (error) {
52 const char* error_description = [[error description] UTF8String];
53 LOG(ERROR) << "Failed to launch application: "
54 << (error_description ? error_description : "");
55 return false;
56 }
57 if (pid)
58 *pid = [application processIdentifier];
59 return true;
60 }
61
62 } // namespace mac
63 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/launch_services_util.cc ('k') | chrome/app_shim/chrome_main_app_mode_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698