Index: chrome/app/chrome_main_app_mode_mac.mm |
diff --git a/chrome/app/chrome_main_app_mode_mac.mm b/chrome/app/chrome_main_app_mode_mac.mm |
index a75f38da0fc895a5ae0c5ed6dd30226ff37594b7..f4a4134a46bb4fb343c7992ef36916dc5cf17319 100644 |
--- a/chrome/app/chrome_main_app_mode_mac.mm |
+++ b/chrome/app/chrome_main_app_mode_mac.mm |
@@ -51,6 +51,7 @@ class AppShimController : public IPC::Listener { |
// shim process should die. |
void OnLaunchAppDone(bool success); |
+ void OnDidActivateApplicationNotification(NSNotification* notification); |
koz (OOO until 15th September)
2013/03/18 03:33:12
comment and newline after this
jeremya
2013/03/18 04:54:05
Done, plus changed the function to only be called
|
// Quits the app shim process. |
void Quit(); |
@@ -95,14 +96,31 @@ void AppShimController::OnChannelError() { |
} |
void AppShimController::OnLaunchAppDone(bool success) { |
- if (!success) |
+ if (!success) { |
Quit(); |
+ return; |
+ } |
+ [[[NSWorkspace sharedWorkspace] notificationCenter] |
+ addObserverForName:NSWorkspaceDidActivateApplicationNotification |
+ object:nil |
+ queue:nil |
+ usingBlock:^(NSNotification* notification) { |
+ OnDidActivateApplicationNotification(notification); |
+ }]; |
} |
void AppShimController::Quit() { |
[NSApp terminate:nil]; |
} |
+void AppShimController::OnDidActivateApplicationNotification( |
+ NSNotification* notification) { |
+ NSRunningApplication* activated_app = |
+ [[notification userInfo] objectForKey:NSWorkspaceApplicationKey]; |
+ if ([activated_app isEqual:[NSRunningApplication currentApplication]]) |
+ channel_->Send(new AppShimHostMsg_FocusApp); |
+} |
+ |
//----------------------------------------------------------------------------- |
// A ReplyEventHandler is a helper class to send an Apple Event to a process |