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

Unified 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: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: apps/app_shim/chrome_main_app_mode_mac.mm
diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm
index 18b8f9e1cfdbca32b371e69ba850be1f2bc33587..d7265b71e819fa9259e07c79de5fa614c1b0adb3 100644
--- a/apps/app_shim/chrome_main_app_mode_mac.mm
+++ b/apps/app_shim/chrome_main_app_mode_mac.mm
@@ -131,6 +131,7 @@ class AppShimController : public IPC::Listener {
// Requests user attention.
void OnRequestUserAttention();
tapted 2014/08/13 06:53:15 since this shim is "always" newer, I don't think t
jackhou1 2014/08/14 04:24:51 The shim is newer, so the older Chrome might send
tapted 2014/08/14 04:38:51 ohhhhh of course..
+ void OnSetUserAttention(apps::AppShimAttentionType attention_type);
// Terminates the app shim process.
void Close();
@@ -140,6 +141,7 @@ class AppShimController : public IPC::Listener {
base::scoped_nsobject<AppShimDelegate> delegate_;
bool launch_app_done_;
bool ping_chrome_reply_received_;
+ NSInteger attention_request_id_;
DISALLOW_COPY_AND_ASSIGN(AppShimController);
};
@@ -147,7 +149,8 @@ class AppShimController : public IPC::Listener {
AppShimController::AppShimController()
: delegate_([[AppShimDelegate alloc] init]),
launch_app_done_(false),
- ping_chrome_reply_received_(false) {
+ ping_chrome_reply_received_(false),
+ attention_request_id_(0) {
// Since AppShimController is created before the main message loop starts,
// NSApp will not be set, so use sharedApplication.
[[NSApplication sharedApplication] setDelegate:delegate_];
@@ -282,6 +285,7 @@ bool AppShimController::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(AppShimMsg_LaunchApp_Done, OnLaunchAppDone)
IPC_MESSAGE_HANDLER(AppShimMsg_Hide, OnHide)
IPC_MESSAGE_HANDLER(AppShimMsg_RequestUserAttention, OnRequestUserAttention)
+ IPC_MESSAGE_HANDLER(AppShimMsg_SetUserAttention, OnSetUserAttention)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -310,7 +314,25 @@ void AppShimController::OnHide() {
}
void AppShimController::OnRequestUserAttention() {
- [NSApp requestUserAttention:NSInformationalRequest];
+ OnSetUserAttention(apps::APP_SHIM_ATTENTION_INFORMATIONAL);
+}
+
+void AppShimController::OnSetUserAttention(
+ apps::AppShimAttentionType attention_type) {
+ switch (attention_type) {
+ case apps::APP_SHIM_ATTENTION_CANCEL:
+ [NSApp cancelUserAttentionRequest:attention_request_id_];
+ attention_request_id_ = 0;
+ break;
+ case apps::APP_SHIM_ATTENTION_CRITICAL:
+ attention_request_id_ = [NSApp requestUserAttention:NSCriticalRequest];
+ break;
+ case apps::APP_SHIM_ATTENTION_INFORMATIONAL:
+ attention_request_id_ =
+ [NSApp requestUserAttention:NSInformationalRequest];
+ case apps::APP_SHIM_ATTENTION_NUM_TYPES:
tapted 2014/08/13 06:53:15 You need a break; before this :o
jackhou1 2014/08/14 04:24:51 Done.
+ NOTREACHED();
+ }
}
void AppShimController::Close() {

Powered by Google App Engine
This is Rietveld 408576698