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

Side by Side Diff: chrome/app_shim/app_mode_loader_mac.mm

Issue 2390953003: [Mac Fix-It] Changed OpenApplicationWithPath to use NSWorkspace. (Closed)
Patch Set: Addressed review comments 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.mm ('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
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 // On Mac, shortcuts can't have command-line arguments. Instead, produce small 5 // On Mac, shortcuts can't have command-line arguments. Instead, produce small
6 // app bundles which locate the Chromium framework and load it, passing the 6 // app bundles which locate the Chromium framework and load it, passing the
7 // appropriate data. This is the code for such an app bundle. It should be kept 7 // appropriate data. This is the code for such an app bundle. It should be kept
8 // minimal and do as little work as possible (with as much work done on 8 // minimal and do as little work as possible (with as much work done on
9 // framework side as possible). 9 // framework side as possible).
10 10
11 #include <dlfcn.h> 11 #include <dlfcn.h>
12 12
13 #import <Cocoa/Cocoa.h> 13 #import <Cocoa/Cocoa.h>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/mac/foundation_util.h" 19 #include "base/mac/foundation_util.h"
20 #include "base/mac/launch_services_util.h" 20 #import "base/mac/launch_services_util.h"
21 #include "base/mac/scoped_nsautorelease_pool.h" 21 #include "base/mac/scoped_nsautorelease_pool.h"
22 #include "base/process/launch.h" 22 #include "base/process/launch.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/sys_string_conversions.h" 24 #include "base/strings/sys_string_conversions.h"
25 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #import "chrome/common/mac/app_mode_chrome_locator.h" 27 #import "chrome/common/mac/app_mode_chrome_locator.h"
28 #include "chrome/common/mac/app_mode_common.h" 28 #include "chrome/common/mac/app_mode_common.h"
29 29
30 namespace { 30 namespace {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // If the shim was launched directly (instead of by Chrome), first ask 175 // If the shim was launched directly (instead of by Chrome), first ask
176 // Chrome to launch the app. Chrome will launch the shim again, the same 176 // Chrome to launch the app. Chrome will launch the shim again, the same
177 // error will occur and be handled above. This approach allows the app to be 177 // error will occur and be handled above. This approach allows the app to be
178 // started without blocking on fixing the shim and guarantees that the 178 // started without blocking on fixing the shim and guarantees that the
179 // profile is loaded when Chrome receives --app-shim-error. 179 // profile is loaded when Chrome receives --app-shim-error.
180 command_line.AppendSwitchPath(switches::kProfileDirectory, 180 command_line.AppendSwitchPath(switches::kProfileDirectory,
181 info->profile_dir); 181 info->profile_dir);
182 command_line.AppendSwitchASCII(switches::kAppId, info->app_mode_id); 182 command_line.AppendSwitchASCII(switches::kAppId, info->app_mode_id);
183 } 183 }
184 // Launch the executable directly since base::mac::OpenApplicationWithPath 184 // Launch the executable directly since base::mac::OpenApplicationWithPath
185 // uses LSOpenApplication which doesn't pass command line arguments if the 185 // doesn't pass command line arguments if the application is already running.
186 // application is already running.
187 if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) { 186 if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) {
188 LOG(ERROR) << "Could not launch Chrome: " 187 LOG(ERROR) << "Could not launch Chrome: "
189 << command_line.GetCommandLineString(); 188 << command_line.GetCommandLineString();
190 return 1; 189 return 1;
191 } 190 }
192 191
193 return 0; 192 return 0;
194 } 193 }
195 194
196 } // namespace 195 } // namespace
197 196
198 __attribute__((visibility("default"))) 197 __attribute__((visibility("default")))
199 int main(int argc, char** argv) { 198 int main(int argc, char** argv) {
200 base::CommandLine::Init(argc, argv); 199 base::CommandLine::Init(argc, argv);
201 app_mode::ChromeAppModeInfo info; 200 app_mode::ChromeAppModeInfo info;
202 201
203 // Hard coded info parameters. 202 // Hard coded info parameters.
204 info.major_version = app_mode::kCurrentChromeAppModeInfoMajorVersion; 203 info.major_version = app_mode::kCurrentChromeAppModeInfoMajorVersion;
205 info.minor_version = app_mode::kCurrentChromeAppModeInfoMinorVersion; 204 info.minor_version = app_mode::kCurrentChromeAppModeInfoMinorVersion;
206 info.argc = argc; 205 info.argc = argc;
207 info.argv = argv; 206 info.argv = argv;
208 207
209 // Exit instead of returning to avoid the the removal of |main()| from stack 208 // Exit instead of returning to avoid the the removal of |main()| from stack
210 // backtraces under tail call optimization. 209 // backtraces under tail call optimization.
211 exit(LoadFrameworkAndStart(&info)); 210 exit(LoadFrameworkAndStart(&info));
212 } 211 }
OLDNEW
« no previous file with comments | « base/mac/launch_services_util.mm ('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