| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 CHECK(cr_bundle_id) << "couldn't get browser bundle ID"; | 44 CHECK(cr_bundle_id) << "couldn't get browser bundle ID"; |
| 45 | 45 |
| 46 // First check if Chrome exists at the last known location. | 46 // First check if Chrome exists at the last known location. |
| 47 base::FilePath cr_bundle_path; | 47 base::FilePath cr_bundle_path; |
| 48 NSString* cr_bundle_path_ns = | 48 NSString* cr_bundle_path_ns = |
| 49 [CFToNSCast(CFCastStrict<CFStringRef>(CFPreferencesCopyAppValue( | 49 [CFToNSCast(CFCastStrict<CFStringRef>(CFPreferencesCopyAppValue( |
| 50 NSToCFCast(app_mode::kLastRunAppBundlePathPrefsKey), | 50 NSToCFCast(app_mode::kLastRunAppBundlePathPrefsKey), |
| 51 NSToCFCast(cr_bundle_id)))) autorelease]; | 51 NSToCFCast(cr_bundle_id)))) autorelease]; |
| 52 cr_bundle_path = base::mac::NSStringToFilePath(cr_bundle_path_ns); | 52 cr_bundle_path = base::mac::NSStringToFilePath(cr_bundle_path_ns); |
| 53 bool found_bundle = | 53 bool found_bundle = |
| 54 !cr_bundle_path.empty() && file_util::DirectoryExists(cr_bundle_path); | 54 !cr_bundle_path.empty() && base::DirectoryExists(cr_bundle_path); |
| 55 | 55 |
| 56 if (!found_bundle) { | 56 if (!found_bundle) { |
| 57 // If no such bundle path exists, try to search by bundle ID. | 57 // If no such bundle path exists, try to search by bundle ID. |
| 58 if (!app_mode::FindBundleById(cr_bundle_id, &cr_bundle_path)) { | 58 if (!app_mode::FindBundleById(cr_bundle_id, &cr_bundle_path)) { |
| 59 // TODO(jeremy): Display UI to allow user to manually locate the Chrome | 59 // TODO(jeremy): Display UI to allow user to manually locate the Chrome |
| 60 // bundle. | 60 // bundle. |
| 61 LOG(FATAL) << "Failed to locate bundle by identifier"; | 61 LOG(FATAL) << "Failed to locate bundle by identifier"; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 typedef int (*StartFun)(const app_mode::ChromeAppModeInfo*); | 122 typedef int (*StartFun)(const app_mode::ChromeAppModeInfo*); |
| 123 StartFun ChromeAppModeStart = (StartFun)dlsym(cr_dylib, "ChromeAppModeStart"); | 123 StartFun ChromeAppModeStart = (StartFun)dlsym(cr_dylib, "ChromeAppModeStart"); |
| 124 CHECK(ChromeAppModeStart) << "couldn't get entry point"; | 124 CHECK(ChromeAppModeStart) << "couldn't get entry point"; |
| 125 | 125 |
| 126 // Exit instead of returning to avoid the the removal of |main()| from stack | 126 // Exit instead of returning to avoid the the removal of |main()| from stack |
| 127 // backtraces under tail call optimization. | 127 // backtraces under tail call optimization. |
| 128 int rv = ChromeAppModeStart(&info); | 128 int rv = ChromeAppModeStart(&info); |
| 129 exit(rv); | 129 exit(rv); |
| 130 } | 130 } |
| OLD | NEW |