| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <stdio.h> | 12 #include <stdio.h> |
| 13 #include <stdlib.h> | 13 #include <stdlib.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 | 15 |
| 16 #include <CoreFoundation/CoreFoundation.h> | 16 #include <CoreFoundation/CoreFoundation.h> |
| 17 #import <Foundation/Foundation.h> | 17 #import <Foundation/Foundation.h> |
| 18 | 18 |
| 19 #include "chrome/common/app_mode_common_mac.h" | 19 #include "chrome/common/mac/app_mode_common.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Checks that condition |x| is true. If not, outputs |msg| (together with | 23 // Checks that condition |x| is true. If not, outputs |msg| (together with |
| 24 // source filename and line number) and exits. | 24 // source filename and line number) and exits. |
| 25 #define CHECK_MSG(x, msg) if (!(x)) check_msg_helper(__FILE__, __LINE__, msg); | 25 #define CHECK_MSG(x, msg) if (!(x)) check_msg_helper(__FILE__, __LINE__, msg); |
| 26 void check_msg_helper(const char* file, int line, const char* msg) { | 26 void check_msg_helper(const char* file, int line, const char* msg) { |
| 27 fprintf(stderr, "%s (%d): %s\n", file, line, msg); | 27 fprintf(stderr, "%s (%d): %s\n", file, line, msg); |
| 28 exit(1); | 28 exit(1); |
| 29 } | 29 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 typedef int (*StartFun)(const app_mode::ChromeAppModeInfo*); | 143 typedef int (*StartFun)(const app_mode::ChromeAppModeInfo*); |
| 144 StartFun ChromeAppModeStart = (StartFun)dlsym(cr_dylib, "ChromeAppModeStart"); | 144 StartFun ChromeAppModeStart = (StartFun)dlsym(cr_dylib, "ChromeAppModeStart"); |
| 145 CHECK_MSG(ChromeAppModeStart, "couldn't get entry point"); | 145 CHECK_MSG(ChromeAppModeStart, "couldn't get entry point"); |
| 146 | 146 |
| 147 // Exit instead of returning to avoid the the removal of |main()| from stack | 147 // Exit instead of returning to avoid the the removal of |main()| from stack |
| 148 // backtraces under tail call optimization. | 148 // backtraces under tail call optimization. |
| 149 int rv = ChromeAppModeStart(&info); | 149 int rv = ChromeAppModeStart(&info); |
| 150 exit(rv); | 150 exit(rv); |
| 151 } | 151 } |
| OLD | NEW |