diff options
author | jackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-03 03:45:00 +0000 |
---|---|---|
committer | jackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-03 03:45:00 +0000 |
commit | 22e0e8a30359118e29f96544da7c1bd21dd48e33 (patch) | |
tree | bcfb9061a3e9c35350a6f28f961220bc0f06b77c /apps | |
parent | fce50255402b235a8f9fe4b1122915d22c58e834 (diff) | |
download | chromium_src-22e0e8a30359118e29f96544da7c1bd21dd48e33.zip chromium_src-22e0e8a30359118e29f96544da7c1bd21dd48e33.tar.gz chromium_src-22e0e8a30359118e29f96544da7c1bd21dd48e33.tar.bz2 |
Hide and show app windows when the shim is hidden/shown.
This adds a new IPC message for hiding/showing the app. It currently
only works while Chrome is shown. Hiding Chrome hides all windows and
any time a Chrome window gains focus, Chrome becomes unhidden. To make
it work as desired, we'd have to override the built-in NSApp hide/unhide
behaviour and manage it ourselves.
BUG=168080
TEST=Start an app.
Right click its shim -> Hide.
The apps windows should disappear with Chrome still visible.
Click the shim (or right click -> Show).
Th apps windows should reappear in the order they were previously.
Review URL: https://chromiumcodereview.appspot.com/17999002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_shim/app_shim_handler_mac.h | 3 | ||||
-rw-r--r-- | apps/app_shim/app_shim_host_mac.cc | 8 | ||||
-rw-r--r-- | apps/app_shim/app_shim_host_mac.h | 2 | ||||
-rw-r--r-- | apps/app_shim/app_shim_host_mac_unittest.cc | 4 | ||||
-rw-r--r-- | apps/app_shim/app_shim_messages.h | 4 | ||||
-rw-r--r-- | apps/app_shim/extension_app_shim_handler_mac.cc | 15 | ||||
-rw-r--r-- | apps/app_shim/extension_app_shim_handler_mac.h | 1 |
7 files changed, 37 insertions, 0 deletions
diff --git a/apps/app_shim/app_shim_handler_mac.h b/apps/app_shim/app_shim_handler_mac.h index 9a6d73c..7b3fea3 100644 --- a/apps/app_shim/app_shim_handler_mac.h +++ b/apps/app_shim/app_shim_handler_mac.h @@ -59,6 +59,9 @@ class AppShimHandler { // Invoked by the shim host when the shim process receives a focus event. virtual void OnShimFocus(Host* host, AppShimFocusType focus_type) = 0; + // Invoked by the shim host when the shim process is hidden or shown. + virtual void OnShimSetHidden(Host* host, bool hidden) = 0; + // Invoked by the shim host when the shim process receives a quit event. virtual void OnShimQuit(Host* host) = 0; diff --git a/apps/app_shim/app_shim_host_mac.cc b/apps/app_shim/app_shim_host_mac.cc index 8c4c89d..8f45c6d 100644 --- a/apps/app_shim/app_shim_host_mac.cc +++ b/apps/app_shim/app_shim_host_mac.cc @@ -46,6 +46,7 @@ bool AppShimHost::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(AppShimHost, message) IPC_MESSAGE_HANDLER(AppShimHostMsg_LaunchApp, OnLaunchApp) IPC_MESSAGE_HANDLER(AppShimHostMsg_FocusApp, OnFocus) + IPC_MESSAGE_HANDLER(AppShimHostMsg_SetAppHidden, OnSetHidden) IPC_MESSAGE_HANDLER(AppShimHostMsg_QuitApp, OnQuit) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -88,6 +89,13 @@ void AppShimHost::OnFocus(apps::AppShimFocusType focus_type) { handler->OnShimFocus(this, focus_type); } +void AppShimHost::OnSetHidden(bool hidden) { + DCHECK(CalledOnValidThread()); + apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); + if (handler) + handler->OnShimSetHidden(this, hidden); +} + void AppShimHost::OnQuit() { DCHECK(CalledOnValidThread()); apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); diff --git a/apps/app_shim/app_shim_host_mac.h b/apps/app_shim/app_shim_host_mac.h index 9bb2438..f654396 100644 --- a/apps/app_shim/app_shim_host_mac.h +++ b/apps/app_shim/app_shim_host_mac.h @@ -57,6 +57,8 @@ class AppShimHost : public IPC::Listener, // Called when the app shim process notifies that the app was focused. void OnFocus(apps::AppShimFocusType focus_type); + void OnSetHidden(bool hidden); + // Called when the app shim process notifies that the app should quit. void OnQuit(); diff --git a/apps/app_shim/app_shim_host_mac_unittest.cc b/apps/app_shim/app_shim_host_mac_unittest.cc index ccc9a50..bb8d2d7 100644 --- a/apps/app_shim/app_shim_host_mac_unittest.cc +++ b/apps/app_shim/app_shim_host_mac_unittest.cc @@ -88,10 +88,14 @@ class AppShimHostTest : public testing::Test, } virtual void OnShimClose(Host* host) OVERRIDE { ++close_count_; } + virtual void OnShimFocus(Host* host, apps::AppShimFocusType focus_type) OVERRIDE { ++focus_count_; } + + virtual void OnShimSetHidden(Host* host, bool hidden) OVERRIDE {} + virtual void OnShimQuit(Host* host) OVERRIDE { ++quit_count_; } bool fail_launch_; diff --git a/apps/app_shim/app_shim_messages.h b/apps/app_shim/app_shim_messages.h index c6958e5..457e940 100644 --- a/apps/app_shim/app_shim_messages.h +++ b/apps/app_shim/app_shim_messages.h @@ -38,6 +38,10 @@ IPC_MESSAGE_CONTROL3(AppShimHostMsg_LaunchApp, IPC_MESSAGE_CONTROL1(AppShimHostMsg_FocusApp, apps::AppShimFocusType /* focus type */) +// Sent when the app shim is hidden or unhidden. +IPC_MESSAGE_CONTROL1(AppShimHostMsg_SetAppHidden, + bool /* hidden */) + // Sent when the shim process receives a request to terminate. Once all of the // app's windows have closed, and the extension is unloaded, the AppShimHost // closes the channel. The shim process then completes the terminate request diff --git a/apps/app_shim/extension_app_shim_handler_mac.cc b/apps/app_shim/extension_app_shim_handler_mac.cc index 4694650..13114e5 100644 --- a/apps/app_shim/extension_app_shim_handler_mac.cc +++ b/apps/app_shim/extension_app_shim_handler_mac.cc @@ -205,6 +205,21 @@ void ExtensionAppShimHandler::OnShimFocus(Host* host, } } +void ExtensionAppShimHandler::OnShimSetHidden(Host* host, bool hidden) { + DCHECK(delegate_->ProfileExistsForPath(host->GetProfilePath())); + Profile* profile = delegate_->ProfileForPath(host->GetProfilePath()); + + const ShellWindowList windows = + delegate_->GetWindows(profile, host->GetAppId()); + for (ShellWindowList::const_reverse_iterator it = windows.rbegin(); + it != windows.rend(); ++it) { + if (hidden) + (*it)->GetBaseWindow()->Hide(); + else + (*it)->GetBaseWindow()->ShowInactive(); + } +} + void ExtensionAppShimHandler::OnShimQuit(Host* host) { DCHECK(delegate_->ProfileExistsForPath(host->GetProfilePath())); Profile* profile = delegate_->ProfileForPath(host->GetProfilePath()); diff --git a/apps/app_shim/extension_app_shim_handler_mac.h b/apps/app_shim/extension_app_shim_handler_mac.h index 257fb39..c2b6e3c 100644 --- a/apps/app_shim/extension_app_shim_handler_mac.h +++ b/apps/app_shim/extension_app_shim_handler_mac.h @@ -64,6 +64,7 @@ class ExtensionAppShimHandler : public AppShimHandler, virtual bool OnShimLaunch(Host* host, AppShimLaunchType launch_type) OVERRIDE; virtual void OnShimClose(Host* host) OVERRIDE; virtual void OnShimFocus(Host* host, AppShimFocusType focus_type) OVERRIDE; + virtual void OnShimSetHidden(Host* host, bool hidden) OVERRIDE; virtual void OnShimQuit(Host* host) OVERRIDE; // AppLifetimeMonitor::Observer overrides: |