summaryrefslogtreecommitdiffstats
path: root/chrome/app/chrome_main_app_mode_mac.mm
diff options
context:
space:
mode:
authorjeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-19 03:04:54 +0000
committerjeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-19 03:04:54 +0000
commit433739c4481fee1967d815207863a9a06fd18db2 (patch)
tree3125aac15a5d07a4eefeb22b78949a1e0d6da2f8 /chrome/app/chrome_main_app_mode_mac.mm
parent54f4375a328737e904ea36aa65d7e892e4129ddc (diff)
downloadchromium_src-433739c4481fee1967d815207863a9a06fd18db2.zip
chromium_src-433739c4481fee1967d815207863a9a06fd18db2.tar.gz
chromium_src-433739c4481fee1967d815207863a9a06fd18db2.tar.bz2
Giving focus to an app shim brings windows belonging to that app to the foreground.
When the user either clicks on the app shim's icon in the dock or selects it with Cmd+Tab, we send a message to Chrome to ask it to bring that app's windows to the front. BUG=138733, 168080 Review URL: https://codereview.chromium.org/12723011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188926 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/chrome_main_app_mode_mac.mm')
-rw-r--r--chrome/app/chrome_main_app_mode_mac.mm22
1 files changed, 21 insertions, 1 deletions
diff --git a/chrome/app/chrome_main_app_mode_mac.mm b/chrome/app/chrome_main_app_mode_mac.mm
index a75f38d..513aad2 100644
--- a/chrome/app/chrome_main_app_mode_mac.mm
+++ b/chrome/app/chrome_main_app_mode_mac.mm
@@ -51,6 +51,10 @@ class AppShimController : public IPC::Listener {
// shim process should die.
void OnLaunchAppDone(bool success);
+ // Called when the app is activated, either by the user clicking on it in the
+ // dock or by Cmd+Tabbing to it.
+ void OnDidActivateApplication();
+
// Quits the app shim process.
void Quit();
@@ -95,14 +99,30 @@ 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) {
+ NSRunningApplication* activated_app =
+ [[notification userInfo] objectForKey:NSWorkspaceApplicationKey];
+ if ([activated_app isEqual:[NSRunningApplication currentApplication]])
+ OnDidActivateApplication();
+ }];
}
void AppShimController::Quit() {
[NSApp terminate:nil];
}
+void AppShimController::OnDidActivateApplication() {
+ channel_->Send(new AppShimHostMsg_FocusApp);
+}
+
//-----------------------------------------------------------------------------
// A ReplyEventHandler is a helper class to send an Apple Event to a process