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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 12623005: [mac] App shims (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: -> _mac Created 7 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/chrome_main_app_mode_mac.mm ('k') | chrome/browser/browser_process_impl.h » ('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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 @interface AppController (Private) 178 @interface AppController (Private)
179 - (void)initMenuState; 179 - (void)initMenuState;
180 - (void)initProfileMenu; 180 - (void)initProfileMenu;
181 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; 181 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item;
182 - (void)registerServicesMenuTypesTo:(NSApplication*)app; 182 - (void)registerServicesMenuTypesTo:(NSApplication*)app;
183 - (void)openUrls:(const std::vector<GURL>&)urls; 183 - (void)openUrls:(const std::vector<GURL>&)urls;
184 - (void)getUrl:(NSAppleEventDescriptor*)event 184 - (void)getUrl:(NSAppleEventDescriptor*)event
185 withReply:(NSAppleEventDescriptor*)reply; 185 withReply:(NSAppleEventDescriptor*)reply;
186 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event; 186 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event;
187 - (void)launchPlatformApp:(NSAppleEventDescriptor*)event
188 withReply:(NSAppleEventDescriptor*)reply;
189 - (void)windowLayeringDidChange:(NSNotification*)inNotification; 187 - (void)windowLayeringDidChange:(NSNotification*)inNotification;
190 - (void)windowChangedToProfile:(Profile*)profile; 188 - (void)windowChangedToProfile:(Profile*)profile;
191 - (void)checkForAnyKeyWindows; 189 - (void)checkForAnyKeyWindows;
192 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; 190 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount;
193 - (BOOL)shouldQuitWithInProgressDownloads; 191 - (BOOL)shouldQuitWithInProgressDownloads;
194 - (void)executeApplication:(id)sender; 192 - (void)executeApplication:(id)sender;
195 @end 193 @end
196 194
197 @implementation AppController 195 @implementation AppController
198 196
(...skipping 11 matching lines...) Expand all
210 andEventID:kAEGetURL]; 208 andEventID:kAEGetURL];
211 [em setEventHandler:self 209 [em setEventHandler:self
212 andSelector:@selector(submitCloudPrintJob:) 210 andSelector:@selector(submitCloudPrintJob:)
213 forEventClass:cloud_print::kAECloudPrintClass 211 forEventClass:cloud_print::kAECloudPrintClass
214 andEventID:cloud_print::kAECloudPrintClass]; 212 andEventID:cloud_print::kAECloudPrintClass];
215 [em setEventHandler:self 213 [em setEventHandler:self
216 andSelector:@selector(getUrl:withReply:) 214 andSelector:@selector(getUrl:withReply:)
217 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates 215 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates
218 andEventID:'OURL']; // back to the Spyglass days. 216 andEventID:'OURL']; // back to the Spyglass days.
219 217
220 [em setEventHandler:self
221 andSelector:@selector(launchPlatformApp:withReply:)
222 forEventClass:app_mode::kAEChromeAppClass
223 andEventID:app_mode::kAEChromeAppLaunch];
224
225 // Register for various window layering changes. We use these to update 218 // Register for various window layering changes. We use these to update
226 // various UI elements (command-key equivalents, etc) when the frontmost 219 // various UI elements (command-key equivalents, etc) when the frontmost
227 // window changes. 220 // window changes.
228 NSNotificationCenter* notificationCenter = 221 NSNotificationCenter* notificationCenter =
229 [NSNotificationCenter defaultCenter]; 222 [NSNotificationCenter defaultCenter];
230 [notificationCenter 223 [notificationCenter
231 addObserver:self 224 addObserver:self
232 selector:@selector(windowLayeringDidChange:) 225 selector:@selector(windowLayeringDidChange:)
233 name:NSWindowDidBecomeKeyNotification 226 name:NSWindowDidBecomeKeyNotification
234 object:nil]; 227 object:nil];
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] 1132 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject]
1140 stringValue]; 1133 stringValue];
1141 1134
1142 GURL gurl(base::SysNSStringToUTF8(urlStr)); 1135 GURL gurl(base::SysNSStringToUTF8(urlStr));
1143 std::vector<GURL> gurlVector; 1136 std::vector<GURL> gurlVector;
1144 gurlVector.push_back(gurl); 1137 gurlVector.push_back(gurl);
1145 1138
1146 [self openUrls:gurlVector]; 1139 [self openUrls:gurlVector];
1147 } 1140 }
1148 1141
1149 - (void)launchPlatformApp:(NSAppleEventDescriptor*)event
1150 withReply:(NSAppleEventDescriptor*)reply {
1151 NSString* appId =
1152 [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
1153 NSString* profileDir =
1154 [[event paramDescriptorForKeyword:app_mode::kAEProfileDirKey]
1155 stringValue];
1156
1157 ProfileManager* profileManager = g_browser_process->profile_manager();
1158 base::FilePath path = base::FilePath(base::SysNSStringToUTF8(profileDir));
1159 path = profileManager->user_data_dir().Append(path);
1160 Profile* profile = profileManager->GetProfile(path);
1161 if (!profile) {
1162 LOG(ERROR) << "Unable to locate a suitable profile for profile directory '"
1163 << profileDir << "' while trying to load app with id '"
1164 << appId << "'.";
1165 return;
1166 }
1167 ExtensionServiceInterface* extensionService =
1168 extensions::ExtensionSystem::Get(profile)->extension_service();
1169 const extensions::Extension* extension =
1170 extensionService->GetExtensionById(
1171 base::SysNSStringToUTF8(appId), false);
1172 if (!extension) {
1173 LOG(ERROR) << "Shortcut attempted to launch nonexistent app with id '"
1174 << base::SysNSStringToUTF8(appId) << "'.";
1175 return;
1176 }
1177 chrome::OpenApplication(chrome::AppLaunchParams(
1178 profile, extension, extension_misc::LAUNCH_NONE, NEW_WINDOW));
1179 }
1180
1181 // Apple Event handler that receives print event from service 1142 // Apple Event handler that receives print event from service
1182 // process, gets the required data and launches Print dialog. 1143 // process, gets the required data and launches Print dialog.
1183 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event { 1144 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event {
1184 // Pull parameter list out of Apple Event. 1145 // Pull parameter list out of Apple Event.
1185 NSAppleEventDescriptor* paramList = 1146 NSAppleEventDescriptor* paramList =
1186 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass]; 1147 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass];
1187 1148
1188 if (paramList != nil) { 1149 if (paramList != nil) {
1189 // Pull required fields out of parameter list. 1150 // Pull required fields out of parameter list.
1190 NSString* mime = [[paramList descriptorAtIndex:1] stringValue]; 1151 NSString* mime = [[paramList descriptorAtIndex:1] stringValue];
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 1318
1358 //--------------------------------------------------------------------------- 1319 //---------------------------------------------------------------------------
1359 1320
1360 namespace app_controller_mac { 1321 namespace app_controller_mac {
1361 1322
1362 bool IsOpeningNewWindow() { 1323 bool IsOpeningNewWindow() {
1363 return g_is_opening_new_window; 1324 return g_is_opening_new_window;
1364 } 1325 }
1365 1326
1366 } // namespace app_controller_mac 1327 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « chrome/app/chrome_main_app_mode_mac.mm ('k') | chrome/browser/browser_process_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698