Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 virtual void OnChannelError() OVERRIDE; | 123 virtual void OnChannelError() OVERRIDE; |
| 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(apps::AppShimAttentionType attention_type); |
| 134 | 134 |
| 135 // Terminates the app shim process. | 135 // Terminates the app shim process. |
| 136 void Close(); | 136 void Close(); |
| 137 | 137 |
| 138 base::FilePath user_data_dir_; | 138 base::FilePath user_data_dir_; |
| 139 scoped_ptr<IPC::ChannelProxy> channel_; | 139 scoped_ptr<IPC::ChannelProxy> channel_; |
| 140 base::scoped_nsobject<AppShimDelegate> delegate_; | 140 base::scoped_nsobject<AppShimDelegate> delegate_; |
| 141 bool launch_app_done_; | 141 bool launch_app_done_; |
| 142 bool ping_chrome_reply_received_; | 142 bool ping_chrome_reply_received_; |
| 143 NSInteger attention_request_id_; | |
| 143 | 144 |
| 144 DISALLOW_COPY_AND_ASSIGN(AppShimController); | 145 DISALLOW_COPY_AND_ASSIGN(AppShimController); |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 AppShimController::AppShimController() | 148 AppShimController::AppShimController() |
| 148 : delegate_([[AppShimDelegate alloc] init]), | 149 : delegate_([[AppShimDelegate alloc] init]), |
| 149 launch_app_done_(false), | 150 launch_app_done_(false), |
| 150 ping_chrome_reply_received_(false) { | 151 ping_chrome_reply_received_(false) { |
|
tapted
2014/08/13 03:37:08
initialize attention_request_id_
jackhou1
2014/08/13 05:53:46
Done.
| |
| 151 // Since AppShimController is created before the main message loop starts, | 152 // Since AppShimController is created before the main message loop starts, |
| 152 // NSApp will not be set, so use sharedApplication. | 153 // NSApp will not be set, so use sharedApplication. |
| 153 [[NSApplication sharedApplication] setDelegate:delegate_]; | 154 [[NSApplication sharedApplication] setDelegate:delegate_]; |
| 154 } | 155 } |
| 155 | 156 |
| 156 AppShimController::~AppShimController() { | 157 AppShimController::~AppShimController() { |
| 157 // Un-set the delegate since NSApplication does not retain it. | 158 // Un-set the delegate since NSApplication does not retain it. |
| 158 [[NSApplication sharedApplication] setDelegate:nil]; | 159 [[NSApplication sharedApplication] setDelegate:nil]; |
| 159 } | 160 } |
| 160 | 161 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 if ([delegate_ getFilesToOpenAtStartup:&files]) | 303 if ([delegate_ getFilesToOpenAtStartup:&files]) |
| 303 SendFocusApp(apps::APP_SHIM_FOCUS_OPEN_FILES, files); | 304 SendFocusApp(apps::APP_SHIM_FOCUS_OPEN_FILES, files); |
| 304 | 305 |
| 305 launch_app_done_ = true; | 306 launch_app_done_ = true; |
| 306 } | 307 } |
| 307 | 308 |
| 308 void AppShimController::OnHide() { | 309 void AppShimController::OnHide() { |
| 309 [NSApp hide:nil]; | 310 [NSApp hide:nil]; |
| 310 } | 311 } |
| 311 | 312 |
| 312 void AppShimController::OnRequestUserAttention() { | 313 void AppShimController::OnRequestUserAttention( |
| 313 [NSApp requestUserAttention:NSInformationalRequest]; | 314 apps::AppShimAttentionType attention_type) { |
| 315 switch (attention_type) { | |
| 316 case apps::APP_SHIM_ATTENTION_CANCEL: | |
| 317 [NSApp cancelUserAttentionRequest:attention_request_id_]; | |
| 318 attention_request_id_ = 0; | |
| 319 break; | |
| 320 case apps::APP_SHIM_ATTENTION_CRITICAL: | |
| 321 attention_request_id_ = [NSApp requestUserAttention:NSCriticalRequest]; | |
| 322 break; | |
| 323 case apps::APP_SHIM_ATTENTION_INFORMATIONAL: | |
| 324 attention_request_id_ = | |
| 325 [NSApp requestUserAttention:NSInformationalRequest]; | |
| 326 default: | |
| 327 break; | |
|
tapted
2014/08/13 03:37:08
maybe
case apps::APP_SHIM_ATTENTION_NUM_TYPES:
jackhou1
2014/08/13 05:53:45
Done.
| |
| 328 } | |
| 314 } | 329 } |
| 315 | 330 |
| 316 void AppShimController::Close() { | 331 void AppShimController::Close() { |
| 317 [delegate_ terminateNow]; | 332 [delegate_ terminateNow]; |
| 318 } | 333 } |
| 319 | 334 |
| 320 bool AppShimController::SendFocusApp(apps::AppShimFocusType focus_type, | 335 bool AppShimController::SendFocusApp(apps::AppShimFocusType focus_type, |
| 321 const std::vector<base::FilePath>& files) { | 336 const std::vector<base::FilePath>& files) { |
| 322 if (launch_app_done_) { | 337 if (launch_app_done_) { |
| 323 channel_->Send(new AppShimHostMsg_FocusApp(focus_type, files)); | 338 channel_->Send(new AppShimHostMsg_FocusApp(focus_type, files)); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 // minute. | 675 // minute. |
| 661 main_message_loop.PostTask( | 676 main_message_loop.PostTask( |
| 662 FROM_HERE, | 677 FROM_HERE, |
| 663 base::Bind(&AppShimController::Init, | 678 base::Bind(&AppShimController::Init, |
| 664 base::Unretained(&controller))); | 679 base::Unretained(&controller))); |
| 665 } | 680 } |
| 666 | 681 |
| 667 main_message_loop.Run(); | 682 main_message_loop.Run(); |
| 668 return 0; | 683 return 0; |
| 669 } | 684 } |
| OLD | NEW |