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

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

Issue 9346013: Publish app shortcuts on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 10 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
OLDNEW
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
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // Optional, so okay if it's NULL. 103 // Optional, so okay if it's NULL.
104 info.app_mode_bundle_path = NSStringToFSCString([app_bundle bundlePath]); 104 info.app_mode_bundle_path = NSStringToFSCString([app_bundle bundlePath]);
105 105
106 // Read information about the this app shortcut from the Info.plist. 106 // Read information about the this app shortcut from the Info.plist.
107 // Don't check for null-ness on optional items. 107 // Don't check for null-ness on optional items.
108 NSDictionary* info_plist = [app_bundle infoDictionary]; 108 NSDictionary* info_plist = [app_bundle infoDictionary];
109 CHECK_MSG(info_plist, "couldn't get loader Info.plist"); 109 CHECK_MSG(info_plist, "couldn't get loader Info.plist");
110 110
111 info.app_mode_id = NSStringToUTF8CString( 111 info.app_mode_id = NSStringToUTF8CString(
112 [info_plist objectForKey:@"CrAppModeShortcutID"]); 112 [info_plist objectForKey:app_mode::kCrAppModeShortcutIDKey]);
113 CHECK_MSG(info.app_mode_id, "couldn't get app shortcut ID"); 113 CHECK_MSG(info.app_mode_id, "couldn't get app shortcut ID");
114 114
115 info.app_mode_short_name = NSStringToUTF8CString( 115 info.app_mode_short_name = NSStringToUTF8CString(
116 [info_plist objectForKey:@"CrAppModeShortcutShortName"]); 116 [info_plist objectForKey:app_mode::kCrAppModeShortcutShortNameKey]);
117 117
118 info.app_mode_name = NSStringToUTF8CString( 118 info.app_mode_name = NSStringToUTF8CString(
119 [info_plist objectForKey:@"CrAppModeShortcutName"]); 119 [info_plist objectForKey:app_mode::kCrAppModeShortcutNameKey]);
120 120
121 info.app_mode_url = NSStringToUTF8CString( 121 info.app_mode_url = NSStringToUTF8CString(
122 [info_plist objectForKey:@"CrAppModeShortcutURL"]); 122 [info_plist objectForKey:app_mode::kCrAppModeShortcutURLKey]);
123 CHECK_MSG(info.app_mode_url, "couldn't get app shortcut URL"); 123 CHECK_MSG(info.app_mode_url, "couldn't get app shortcut URL");
124 124
125 // Get the framework path. 125 // Get the framework path.
126 NSString* cr_bundle_exe = 126 NSString* cr_bundle_exe =
127 [cr_bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]; 127 [cr_bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
128 NSString* cr_framework_path = 128 NSString* cr_framework_path =
129 [cr_versioned_path stringByAppendingPathComponent: 129 [cr_versioned_path stringByAppendingPathComponent:
130 [cr_bundle_exe stringByAppendingString:@" Framework.framework"]]; 130 [cr_bundle_exe stringByAppendingString:@" Framework.framework"]];
131 cr_framework_path = 131 cr_framework_path =
132 [cr_framework_path stringByAppendingPathComponent: 132 [cr_framework_path stringByAppendingPathComponent:
133 [cr_bundle_exe stringByAppendingString:@" Framework"]]; 133 [cr_bundle_exe stringByAppendingString:@" Framework"]];
134 134
135 // Open the framework. 135 // Open the framework.
136 void* cr_dylib = dlopen([cr_framework_path fileSystemRepresentation], 136 void* cr_dylib = dlopen([cr_framework_path fileSystemRepresentation],
137 RTLD_LAZY); 137 RTLD_LAZY);
138 CHECK_MSG(cr_dylib, "couldn't load framework"); 138 CHECK_MSG(cr_dylib, "couldn't load framework");
139 139
140 // Drain the pool as late as possible. 140 // Drain the pool as late as possible.
141 [pool drain]; 141 [pool drain];
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698