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

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

Issue 9416012: Mac: Generate App Mode Loader bundle + cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased against trunk Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/app_mode-Info.plist ('k') | chrome/app/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
(...skipping 21 matching lines...) Expand all
32 using base::mac::NSToCFCast; 32 using base::mac::NSToCFCast;
33 33
34 base::mac::ScopedNSAutoreleasePool scoped_pool; 34 base::mac::ScopedNSAutoreleasePool scoped_pool;
35 35
36 // Get the current main bundle, i.e., that of the app loader that's running. 36 // Get the current main bundle, i.e., that of the app loader that's running.
37 NSBundle* app_bundle = [NSBundle mainBundle]; 37 NSBundle* app_bundle = [NSBundle mainBundle];
38 CHECK(app_bundle) << "couldn't get loader bundle"; 38 CHECK(app_bundle) << "couldn't get loader bundle";
39 39
40 // ** 1: Get path to outer Chrome bundle. 40 // ** 1: Get path to outer Chrome bundle.
41 // Get the bundle ID of the browser that created this app bundle. 41 // Get the bundle ID of the browser that created this app bundle.
42 NSString* cr_bundle_id = [app_bundle 42 NSString* cr_bundle_id = base::mac::ObjCCast<NSString>(
43 objectForInfoDictionaryKey:app_mode::kBrowserBundleIDKey]; 43 [app_bundle objectForInfoDictionaryKey:app_mode::kBrowserBundleIDKey]);
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 FilePath cr_bundle_path; 47 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 =
(...skipping 11 matching lines...) Expand all
65 // ** 2: Read information from the Chrome bundle. 65 // ** 2: Read information from the Chrome bundle.
66 string16 raw_version_str; 66 string16 raw_version_str;
67 FilePath version_path; 67 FilePath version_path;
68 FilePath framework_shlib_path; 68 FilePath framework_shlib_path;
69 if (!app_mode::GetChromeBundleInfo(cr_bundle_path, &raw_version_str, 69 if (!app_mode::GetChromeBundleInfo(cr_bundle_path, &raw_version_str,
70 &version_path, &framework_shlib_path)) { 70 &version_path, &framework_shlib_path)) {
71 LOG(FATAL) << "Couldn't ready Chrome bundle info"; 71 LOG(FATAL) << "Couldn't ready Chrome bundle info";
72 } 72 }
73 73
74 // ** 3: Fill in ChromeAppModeInfo. 74 // ** 3: Fill in ChromeAppModeInfo.
75 info->chrome_outer_bundle_path = cr_bundle_path;
75 info->chrome_versioned_path = version_path; 76 info->chrome_versioned_path = version_path;
76 info->app_mode_bundle_path = 77 info->app_mode_bundle_path =
77 base::mac::NSStringToFilePath([app_bundle bundlePath]); 78 base::mac::NSStringToFilePath([app_bundle bundlePath]);
78 79
79 // Read information about the this app shortcut from the Info.plist. 80 // Read information about the this app shortcut from the Info.plist.
80 // Don't check for null-ness on optional items. 81 // Don't check for null-ness on optional items.
81 NSDictionary* info_plist = [app_bundle infoDictionary]; 82 NSDictionary* info_plist = [app_bundle infoDictionary];
82 CHECK(info_plist) << "couldn't get loader Info.plist"; 83 CHECK(info_plist) << "couldn't get loader Info.plist";
83 84
84 info->app_mode_id = SysNSStringToUTF8( 85 info->app_mode_id = SysNSStringToUTF8(
85 [info_plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); 86 [info_plist objectForKey:app_mode::kCrAppModeShortcutIDKey]);
86 CHECK(info->app_mode_id.size()) << "couldn't get app shortcut ID"; 87 CHECK(info->app_mode_id.size()) << "couldn't get app shortcut ID";
87 88
88 info->app_mode_short_name = SysNSStringToUTF16( 89 info->app_mode_short_name = SysNSStringToUTF16(
89 [info_plist objectForKey:app_mode::kCrAppModeShortcutShortNameKey]); 90 [info_plist objectForKey:app_mode::kCrAppModeShortcutShortNameKey]);
90 91
91 info->app_mode_name = SysNSStringToUTF16( 92 info->app_mode_name = SysNSStringToUTF16(
92 [info_plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); 93 [info_plist objectForKey:app_mode::kCrAppModeShortcutNameKey]);
93 94
94 info->app_mode_url = SysNSStringToUTF8( 95 info->app_mode_url = SysNSStringToUTF8(
95 [info_plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); 96 [info_plist objectForKey:app_mode::kCrAppModeShortcutURLKey]);
96 CHECK(info->app_mode_url.size()) << "couldn't get app shortcut URL";
97 97
98 info->user_data_dir = base::mac::NSStringToFilePath( 98 info->user_data_dir = base::mac::NSStringToFilePath(
99 [info_plist objectForKey:app_mode::kCrAppModeUserDataDirKey]); 99 [info_plist objectForKey:app_mode::kCrAppModeUserDataDirKey]);
100 100
101 info->extension_path = base::mac::NSStringToFilePath( 101 info->extension_path = base::mac::NSStringToFilePath(
102 [info_plist objectForKey:app_mode::kCrAppModeExtensionPathKey]); 102 [info_plist objectForKey:app_mode::kCrAppModeExtensionPathKey]);
103 103
104 // Open the framework. 104 // Open the framework.
105 *cr_dylib = dlopen(framework_shlib_path.value().c_str(), RTLD_LAZY); 105 *cr_dylib = dlopen(framework_shlib_path.value().c_str(), RTLD_LAZY);
106 CHECK(cr_dylib) << "couldn't load framework: " << dlerror(); 106 CHECK(cr_dylib) << "couldn't load framework: " << dlerror();
(...skipping 17 matching lines...) Expand all
124 124
125 typedef int (*StartFun)(const app_mode::ChromeAppModeInfo*); 125 typedef int (*StartFun)(const app_mode::ChromeAppModeInfo*);
126 StartFun ChromeAppModeStart = (StartFun)dlsym(cr_dylib, "ChromeAppModeStart"); 126 StartFun ChromeAppModeStart = (StartFun)dlsym(cr_dylib, "ChromeAppModeStart");
127 CHECK(ChromeAppModeStart) << "couldn't get entry point"; 127 CHECK(ChromeAppModeStart) << "couldn't get entry point";
128 128
129 // Exit instead of returning to avoid the the removal of |main()| from stack 129 // Exit instead of returning to avoid the the removal of |main()| from stack
130 // backtraces under tail call optimization. 130 // backtraces under tail call optimization.
131 int rv = ChromeAppModeStart(&info); 131 int rv = ChromeAppModeStart(&info);
132 exit(rv); 132 exit(rv);
133 } 133 }
OLDNEW
« no previous file with comments | « chrome/app/app_mode-Info.plist ('k') | chrome/app/chrome_main_app_mode_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698