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 // 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 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (!ChromeAppModeStart) | 142 if (!ChromeAppModeStart) |
143 LOG(ERROR) << "Couldn't get entry point: " << dlerror(); | 143 LOG(ERROR) << "Couldn't get entry point: " << dlerror(); |
144 } else { | 144 } else { |
145 LOG(ERROR) << "Couldn't load framework: " << dlerror(); | 145 LOG(ERROR) << "Couldn't load framework: " << dlerror(); |
146 } | 146 } |
147 | 147 |
148 if (ChromeAppModeStart) | 148 if (ChromeAppModeStart) |
149 return ChromeAppModeStart(info); | 149 return ChromeAppModeStart(info); |
150 | 150 |
151 LOG(ERROR) << "Loading Chrome failed, launching Chrome with command line"; | 151 LOG(ERROR) << "Loading Chrome failed, launching Chrome with command line"; |
152 CommandLine command_line(executable_path); | 152 base::CommandLine command_line(executable_path); |
153 // The user_data_dir from the plist is actually the app data dir. | 153 // The user_data_dir from the plist is actually the app data dir. |
154 command_line.AppendSwitchPath( | 154 command_line.AppendSwitchPath( |
155 switches::kUserDataDir, | 155 switches::kUserDataDir, |
156 info->user_data_dir.DirName().DirName().DirName()); | 156 info->user_data_dir.DirName().DirName().DirName()); |
157 if (CommandLine::ForCurrentProcess()->HasSwitch( | 157 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
158 app_mode::kLaunchedByChromeProcessId) || | 158 app_mode::kLaunchedByChromeProcessId) || |
159 info->app_mode_id == app_mode::kAppListModeId) { | 159 info->app_mode_id == app_mode::kAppListModeId) { |
160 // Pass --app-shim-error to have Chrome rebuild this shim. | 160 // Pass --app-shim-error to have Chrome rebuild this shim. |
161 // If Chrome has rebuilt this shim once already, then rebuilding doesn't fix | 161 // If Chrome has rebuilt this shim once already, then rebuilding doesn't fix |
162 // the problem, so don't try again. | 162 // the problem, so don't try again. |
163 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 163 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
164 app_mode::kLaunchedAfterRebuild)) { | 164 app_mode::kLaunchedAfterRebuild)) { |
165 command_line.AppendSwitchPath(app_mode::kAppShimError, | 165 command_line.AppendSwitchPath(app_mode::kAppShimError, |
166 app_mode_bundle_path); | 166 app_mode_bundle_path); |
167 } | 167 } |
168 } else { | 168 } else { |
169 // If the shim was launched directly (instead of by Chrome), first ask | 169 // If the shim was launched directly (instead of by Chrome), first ask |
170 // Chrome to launch the app. Chrome will launch the shim again, the same | 170 // Chrome to launch the app. Chrome will launch the shim again, the same |
171 // error will occur and be handled above. This approach allows the app to be | 171 // error will occur and be handled above. This approach allows the app to be |
172 // started without blocking on fixing the shim and guarantees that the | 172 // started without blocking on fixing the shim and guarantees that the |
173 // profile is loaded when Chrome receives --app-shim-error. | 173 // profile is loaded when Chrome receives --app-shim-error. |
(...skipping 10 matching lines...) Expand all Loading... |
184 return 1; | 184 return 1; |
185 } | 185 } |
186 | 186 |
187 return 0; | 187 return 0; |
188 } | 188 } |
189 | 189 |
190 } // namespace | 190 } // namespace |
191 | 191 |
192 __attribute__((visibility("default"))) | 192 __attribute__((visibility("default"))) |
193 int main(int argc, char** argv) { | 193 int main(int argc, char** argv) { |
194 CommandLine::Init(argc, argv); | 194 base::CommandLine::Init(argc, argv); |
195 app_mode::ChromeAppModeInfo info; | 195 app_mode::ChromeAppModeInfo info; |
196 | 196 |
197 // Hard coded info parameters. | 197 // Hard coded info parameters. |
198 info.major_version = app_mode::kCurrentChromeAppModeInfoMajorVersion; | 198 info.major_version = app_mode::kCurrentChromeAppModeInfoMajorVersion; |
199 info.minor_version = app_mode::kCurrentChromeAppModeInfoMinorVersion; | 199 info.minor_version = app_mode::kCurrentChromeAppModeInfoMinorVersion; |
200 info.argc = argc; | 200 info.argc = argc; |
201 info.argv = argv; | 201 info.argv = argv; |
202 | 202 |
203 // Exit instead of returning to avoid the the removal of |main()| from stack | 203 // Exit instead of returning to avoid the the removal of |main()| from stack |
204 // backtraces under tail call optimization. | 204 // backtraces under tail call optimization. |
205 exit(LoadFrameworkAndStart(&info)); | 205 exit(LoadFrameworkAndStart(&info)); |
206 } | 206 } |
OLD | NEW |