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

Side by Side Diff: apps/app_shim/chrome_main_app_mode_mac.mm

Issue 461303002: [Mac] Bounce app shims when app windows request attention. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update FakeHost in test. Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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, one can't make shortcuts with command-line arguments. Instead, we 5 // On Mac, one can't make shortcuts with command-line arguments. Instead, we
6 // produce small app bundles which locate the Chromium framework and load it, 6 // produce small app bundles which locate the Chromium framework and load it,
7 // passing the appropriate data. This is the entry point into the framework for 7 // passing the appropriate data. This is the entry point into the framework for
8 // those app bundles. 8 // those app bundles.
9 9
10 #import <Cocoa/Cocoa.h> 10 #import <Cocoa/Cocoa.h>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 // If Chrome failed to launch the app, |success| will be false and the app 125 // If Chrome failed to launch the app, |success| will be false and the app
126 // shim process should die. 126 // shim process should die.
127 void OnLaunchAppDone(apps::AppShimLaunchResult result); 127 void OnLaunchAppDone(apps::AppShimLaunchResult result);
128 128
129 // Hide this app. 129 // Hide this app.
130 void OnHide(); 130 void OnHide();
131 131
132 // Requests user attention. 132 // Requests user attention.
133 void OnRequestUserAttention(); 133 void OnRequestUserAttention();
134 void OnSetUserAttention(apps::AppShimAttentionType attention_type);
134 135
135 // Terminates the app shim process. 136 // Terminates the app shim process.
136 void Close(); 137 void Close();
137 138
138 base::FilePath user_data_dir_; 139 base::FilePath user_data_dir_;
139 scoped_ptr<IPC::ChannelProxy> channel_; 140 scoped_ptr<IPC::ChannelProxy> channel_;
140 base::scoped_nsobject<AppShimDelegate> delegate_; 141 base::scoped_nsobject<AppShimDelegate> delegate_;
141 bool launch_app_done_; 142 bool launch_app_done_;
142 bool ping_chrome_reply_received_; 143 bool ping_chrome_reply_received_;
144 NSInteger attention_request_id_;
143 145
144 DISALLOW_COPY_AND_ASSIGN(AppShimController); 146 DISALLOW_COPY_AND_ASSIGN(AppShimController);
145 }; 147 };
146 148
147 AppShimController::AppShimController() 149 AppShimController::AppShimController()
148 : delegate_([[AppShimDelegate alloc] init]), 150 : delegate_([[AppShimDelegate alloc] init]),
149 launch_app_done_(false), 151 launch_app_done_(false),
150 ping_chrome_reply_received_(false) { 152 ping_chrome_reply_received_(false),
153 attention_request_id_(0) {
151 // Since AppShimController is created before the main message loop starts, 154 // Since AppShimController is created before the main message loop starts,
152 // NSApp will not be set, so use sharedApplication. 155 // NSApp will not be set, so use sharedApplication.
153 [[NSApplication sharedApplication] setDelegate:delegate_]; 156 [[NSApplication sharedApplication] setDelegate:delegate_];
154 } 157 }
155 158
156 AppShimController::~AppShimController() { 159 AppShimController::~AppShimController() {
157 // Un-set the delegate since NSApplication does not retain it. 160 // Un-set the delegate since NSApplication does not retain it.
158 [[NSApplication sharedApplication] setDelegate:nil]; 161 [[NSApplication sharedApplication] setDelegate:nil];
159 } 162 }
160 163
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void AppShimController::SendQuitApp() { 278 void AppShimController::SendQuitApp() {
276 channel_->Send(new AppShimHostMsg_QuitApp); 279 channel_->Send(new AppShimHostMsg_QuitApp);
277 } 280 }
278 281
279 bool AppShimController::OnMessageReceived(const IPC::Message& message) { 282 bool AppShimController::OnMessageReceived(const IPC::Message& message) {
280 bool handled = true; 283 bool handled = true;
281 IPC_BEGIN_MESSAGE_MAP(AppShimController, message) 284 IPC_BEGIN_MESSAGE_MAP(AppShimController, message)
282 IPC_MESSAGE_HANDLER(AppShimMsg_LaunchApp_Done, OnLaunchAppDone) 285 IPC_MESSAGE_HANDLER(AppShimMsg_LaunchApp_Done, OnLaunchAppDone)
283 IPC_MESSAGE_HANDLER(AppShimMsg_Hide, OnHide) 286 IPC_MESSAGE_HANDLER(AppShimMsg_Hide, OnHide)
284 IPC_MESSAGE_HANDLER(AppShimMsg_RequestUserAttention, OnRequestUserAttention) 287 IPC_MESSAGE_HANDLER(AppShimMsg_RequestUserAttention, OnRequestUserAttention)
288 IPC_MESSAGE_HANDLER(AppShimMsg_SetUserAttention, OnSetUserAttention)
285 IPC_MESSAGE_UNHANDLED(handled = false) 289 IPC_MESSAGE_UNHANDLED(handled = false)
286 IPC_END_MESSAGE_MAP() 290 IPC_END_MESSAGE_MAP()
287 291
288 return handled; 292 return handled;
289 } 293 }
290 294
291 void AppShimController::OnChannelError() { 295 void AppShimController::OnChannelError() {
292 Close(); 296 Close();
293 } 297 }
294 298
295 void AppShimController::OnLaunchAppDone(apps::AppShimLaunchResult result) { 299 void AppShimController::OnLaunchAppDone(apps::AppShimLaunchResult result) {
296 if (result != apps::APP_SHIM_LAUNCH_SUCCESS) { 300 if (result != apps::APP_SHIM_LAUNCH_SUCCESS) {
297 Close(); 301 Close();
298 return; 302 return;
299 } 303 }
300 304
301 std::vector<base::FilePath> files; 305 std::vector<base::FilePath> files;
302 if ([delegate_ getFilesToOpenAtStartup:&files]) 306 if ([delegate_ getFilesToOpenAtStartup:&files])
303 SendFocusApp(apps::APP_SHIM_FOCUS_OPEN_FILES, files); 307 SendFocusApp(apps::APP_SHIM_FOCUS_OPEN_FILES, files);
304 308
305 launch_app_done_ = true; 309 launch_app_done_ = true;
306 } 310 }
307 311
308 void AppShimController::OnHide() { 312 void AppShimController::OnHide() {
309 [NSApp hide:nil]; 313 [NSApp hide:nil];
310 } 314 }
311 315
312 void AppShimController::OnRequestUserAttention() { 316 void AppShimController::OnRequestUserAttention() {
313 [NSApp requestUserAttention:NSInformationalRequest]; 317 OnSetUserAttention(apps::APP_SHIM_ATTENTION_INFORMATIONAL);
318 }
319
320 void AppShimController::OnSetUserAttention(
321 apps::AppShimAttentionType attention_type) {
322 switch (attention_type) {
323 case apps::APP_SHIM_ATTENTION_CANCEL:
324 [NSApp cancelUserAttentionRequest:attention_request_id_];
325 attention_request_id_ = 0;
326 break;
327 case apps::APP_SHIM_ATTENTION_CRITICAL:
328 attention_request_id_ = [NSApp requestUserAttention:NSCriticalRequest];
329 break;
330 case apps::APP_SHIM_ATTENTION_INFORMATIONAL:
331 attention_request_id_ =
332 [NSApp requestUserAttention:NSInformationalRequest];
333 break;
334 case apps::APP_SHIM_ATTENTION_NUM_TYPES:
335 NOTREACHED();
336 }
314 } 337 }
315 338
316 void AppShimController::Close() { 339 void AppShimController::Close() {
317 [delegate_ terminateNow]; 340 [delegate_ terminateNow];
318 } 341 }
319 342
320 bool AppShimController::SendFocusApp(apps::AppShimFocusType focus_type, 343 bool AppShimController::SendFocusApp(apps::AppShimFocusType focus_type,
321 const std::vector<base::FilePath>& files) { 344 const std::vector<base::FilePath>& files) {
322 if (launch_app_done_) { 345 if (launch_app_done_) {
323 channel_->Send(new AppShimHostMsg_FocusApp(focus_type, files)); 346 channel_->Send(new AppShimHostMsg_FocusApp(focus_type, files));
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // minute. 684 // minute.
662 main_message_loop.PostTask( 685 main_message_loop.PostTask(
663 FROM_HERE, 686 FROM_HERE,
664 base::Bind(&AppShimController::Init, 687 base::Bind(&AppShimController::Init,
665 base::Unretained(&controller))); 688 base::Unretained(&controller)));
666 } 689 }
667 690
668 main_message_loop.Run(); 691 main_message_loop.Run();
669 return 0; 692 return 0;
670 } 693 }
OLDNEW
« no previous file with comments | « apps/app_shim/app_shim_quit_interactive_uitest_mac.mm ('k') | apps/app_shim/extension_app_shim_handler_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698