| 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 #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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 @interface AppController (Private) | 176 @interface AppController (Private) |
| 177 - (void)initMenuState; | 177 - (void)initMenuState; |
| 178 - (void)initProfileMenu; | 178 - (void)initProfileMenu; |
| 179 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; | 179 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; |
| 180 - (void)registerServicesMenuTypesTo:(NSApplication*)app; | 180 - (void)registerServicesMenuTypesTo:(NSApplication*)app; |
| 181 - (void)openUrls:(const std::vector<GURL>&)urls; | 181 - (void)openUrls:(const std::vector<GURL>&)urls; |
| 182 - (void)getUrl:(NSAppleEventDescriptor*)event | 182 - (void)getUrl:(NSAppleEventDescriptor*)event |
| 183 withReply:(NSAppleEventDescriptor*)reply; | 183 withReply:(NSAppleEventDescriptor*)reply; |
| 184 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event; | 184 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event; |
| 185 - (void)launchPlatformApp:(NSAppleEventDescriptor*)event | |
| 186 withReply:(NSAppleEventDescriptor*)reply; | |
| 187 - (void)windowLayeringDidChange:(NSNotification*)inNotification; | 185 - (void)windowLayeringDidChange:(NSNotification*)inNotification; |
| 188 - (void)windowChangedToProfile:(Profile*)profile; | 186 - (void)windowChangedToProfile:(Profile*)profile; |
| 189 - (void)checkForAnyKeyWindows; | 187 - (void)checkForAnyKeyWindows; |
| 190 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; | 188 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; |
| 191 - (BOOL)shouldQuitWithInProgressDownloads; | 189 - (BOOL)shouldQuitWithInProgressDownloads; |
| 192 - (void)executeApplication:(id)sender; | 190 - (void)executeApplication:(id)sender; |
| 193 @end | 191 @end |
| 194 | 192 |
| 195 @implementation AppController | 193 @implementation AppController |
| 196 | 194 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 208 andEventID:kAEGetURL]; | 206 andEventID:kAEGetURL]; |
| 209 [em setEventHandler:self | 207 [em setEventHandler:self |
| 210 andSelector:@selector(submitCloudPrintJob:) | 208 andSelector:@selector(submitCloudPrintJob:) |
| 211 forEventClass:cloud_print::kAECloudPrintClass | 209 forEventClass:cloud_print::kAECloudPrintClass |
| 212 andEventID:cloud_print::kAECloudPrintClass]; | 210 andEventID:cloud_print::kAECloudPrintClass]; |
| 213 [em setEventHandler:self | 211 [em setEventHandler:self |
| 214 andSelector:@selector(getUrl:withReply:) | 212 andSelector:@selector(getUrl:withReply:) |
| 215 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates | 213 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates |
| 216 andEventID:'OURL']; // back to the Spyglass days. | 214 andEventID:'OURL']; // back to the Spyglass days. |
| 217 | 215 |
| 218 [em setEventHandler:self | |
| 219 andSelector:@selector(launchPlatformApp:withReply:) | |
| 220 forEventClass:app_mode::kAEChromeAppClass | |
| 221 andEventID:app_mode::kAEChromeAppLaunch]; | |
| 222 | |
| 223 // Register for various window layering changes. We use these to update | 216 // Register for various window layering changes. We use these to update |
| 224 // various UI elements (command-key equivalents, etc) when the frontmost | 217 // various UI elements (command-key equivalents, etc) when the frontmost |
| 225 // window changes. | 218 // window changes. |
| 226 NSNotificationCenter* notificationCenter = | 219 NSNotificationCenter* notificationCenter = |
| 227 [NSNotificationCenter defaultCenter]; | 220 [NSNotificationCenter defaultCenter]; |
| 228 [notificationCenter | 221 [notificationCenter |
| 229 addObserver:self | 222 addObserver:self |
| 230 selector:@selector(windowLayeringDidChange:) | 223 selector:@selector(windowLayeringDidChange:) |
| 231 name:NSWindowDidBecomeKeyNotification | 224 name:NSWindowDidBecomeKeyNotification |
| 232 object:nil]; | 225 object:nil]; |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] | 1123 NSString* urlStr = [[event paramDescriptorForKeyword:keyDirectObject] |
| 1131 stringValue]; | 1124 stringValue]; |
| 1132 | 1125 |
| 1133 GURL gurl(base::SysNSStringToUTF8(urlStr)); | 1126 GURL gurl(base::SysNSStringToUTF8(urlStr)); |
| 1134 std::vector<GURL> gurlVector; | 1127 std::vector<GURL> gurlVector; |
| 1135 gurlVector.push_back(gurl); | 1128 gurlVector.push_back(gurl); |
| 1136 | 1129 |
| 1137 [self openUrls:gurlVector]; | 1130 [self openUrls:gurlVector]; |
| 1138 } | 1131 } |
| 1139 | 1132 |
| 1140 - (void)launchPlatformApp:(NSAppleEventDescriptor*)event | |
| 1141 withReply:(NSAppleEventDescriptor*)reply { | |
| 1142 NSString* appId = | |
| 1143 [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; | |
| 1144 NSString* profileDir = | |
| 1145 [[event paramDescriptorForKeyword:app_mode::kAEProfileDirKey] | |
| 1146 stringValue]; | |
| 1147 | |
| 1148 ProfileManager* profileManager = g_browser_process->profile_manager(); | |
| 1149 base::FilePath path = base::FilePath(base::SysNSStringToUTF8(profileDir)); | |
| 1150 path = profileManager->user_data_dir().Append(path); | |
| 1151 Profile* profile = profileManager->GetProfile(path); | |
| 1152 if (!profile) { | |
| 1153 LOG(ERROR) << "Unable to locate a suitable profile for profile directory '" | |
| 1154 << profileDir << "' while trying to load app with id '" | |
| 1155 << appId << "'."; | |
| 1156 return; | |
| 1157 } | |
| 1158 ExtensionServiceInterface* extensionService = | |
| 1159 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
| 1160 const extensions::Extension* extension = | |
| 1161 extensionService->GetExtensionById( | |
| 1162 base::SysNSStringToUTF8(appId), false); | |
| 1163 if (!extension) { | |
| 1164 LOG(ERROR) << "Shortcut attempted to launch nonexistent app with id '" | |
| 1165 << base::SysNSStringToUTF8(appId) << "'."; | |
| 1166 return; | |
| 1167 } | |
| 1168 chrome::OpenApplication(chrome::AppLaunchParams( | |
| 1169 profile, extension, extension_misc::LAUNCH_NONE, NEW_WINDOW)); | |
| 1170 } | |
| 1171 | |
| 1172 // Apple Event handler that receives print event from service | 1133 // Apple Event handler that receives print event from service |
| 1173 // process, gets the required data and launches Print dialog. | 1134 // process, gets the required data and launches Print dialog. |
| 1174 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event { | 1135 - (void)submitCloudPrintJob:(NSAppleEventDescriptor*)event { |
| 1175 // Pull parameter list out of Apple Event. | 1136 // Pull parameter list out of Apple Event. |
| 1176 NSAppleEventDescriptor* paramList = | 1137 NSAppleEventDescriptor* paramList = |
| 1177 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass]; | 1138 [event paramDescriptorForKeyword:cloud_print::kAECloudPrintClass]; |
| 1178 | 1139 |
| 1179 if (paramList != nil) { | 1140 if (paramList != nil) { |
| 1180 // Pull required fields out of parameter list. | 1141 // Pull required fields out of parameter list. |
| 1181 NSString* mime = [[paramList descriptorAtIndex:1] stringValue]; | 1142 NSString* mime = [[paramList descriptorAtIndex:1] stringValue]; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 | 1309 |
| 1349 //--------------------------------------------------------------------------- | 1310 //--------------------------------------------------------------------------- |
| 1350 | 1311 |
| 1351 namespace app_controller_mac { | 1312 namespace app_controller_mac { |
| 1352 | 1313 |
| 1353 bool IsOpeningNewWindow() { | 1314 bool IsOpeningNewWindow() { |
| 1354 return g_is_opening_new_window; | 1315 return g_is_opening_new_window; |
| 1355 } | 1316 } |
| 1356 | 1317 |
| 1357 } // namespace app_controller_mac | 1318 } // namespace app_controller_mac |
| OLD | NEW |