Commit 8a5bd590 authored by jackhou@chromium.org's avatar jackhou@chromium.org

[Mac] Hide all shims when Chrome is hidden.

Since hiding Chrome hides all apps, this informs the shims that their
app is hidden. This ensures that a unhide is fired when the shim is next
focused.

BUG=355397

Review URL: https://codereview.chromium.org/403743002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284622 0039d316-1c4b-4281-b951-d872f2087c98
parent 45f9e4ee
......@@ -227,9 +227,7 @@ AppShimHandler::Host* ExtensionAppShimHandler::FindHost(
// static
void ExtensionAppShimHandler::QuitAppForWindow(AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
ExtensionAppShimHandler* handler = GetInstance();
Host* host = handler->FindHost(
Profile::FromBrowserContext(app_window->browser_context()),
app_window->extension_id());
......@@ -244,9 +242,7 @@ void ExtensionAppShimHandler::QuitAppForWindow(AppWindow* app_window) {
}
void ExtensionAppShimHandler::HideAppForWindow(AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
ExtensionAppShimHandler* handler = GetInstance();
Profile* profile = Profile::FromBrowserContext(app_window->browser_context());
Host* host = handler->FindHost(profile, app_window->extension_id());
if (host)
......@@ -256,9 +252,7 @@ void ExtensionAppShimHandler::HideAppForWindow(AppWindow* app_window) {
}
void ExtensionAppShimHandler::FocusAppForWindow(AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
ExtensionAppShimHandler* handler = GetInstance();
Profile* profile = Profile::FromBrowserContext(app_window->browser_context());
const std::string& app_id = app_window->extension_id();
Host* host = handler->FindHost(profile, app_id);
......@@ -275,9 +269,7 @@ void ExtensionAppShimHandler::FocusAppForWindow(AppWindow* app_window) {
// static
bool ExtensionAppShimHandler::RequestUserAttentionForWindow(
AppWindow* app_window) {
ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler();
ExtensionAppShimHandler* handler = GetInstance();
Profile* profile = Profile::FromBrowserContext(app_window->browser_context());
Host* host = handler->FindHost(profile, app_window->extension_id());
if (host) {
......@@ -292,6 +284,19 @@ bool ExtensionAppShimHandler::RequestUserAttentionForWindow(
}
}
// static
void ExtensionAppShimHandler::OnChromeWillHide() {
// Send OnAppHide to all the shims so that they go into the hidden state.
// This is necessary so that when the shim is next focused, it will know to
// unhide.
ExtensionAppShimHandler* handler = GetInstance();
for (HostMap::iterator it = handler->hosts_.begin();
it != handler->hosts_.end();
++it) {
it->second->OnAppHide();
}
}
void ExtensionAppShimHandler::OnShimLaunch(
Host* host,
AppShimLaunchType launch_type,
......@@ -331,6 +336,13 @@ void ExtensionAppShimHandler::OnShimLaunch(
// Return now. OnAppLaunchComplete will be called when the app is activated.
}
// static
ExtensionAppShimHandler* ExtensionAppShimHandler::GetInstance() {
return g_browser_process->platform_part()
->app_shim_host_manager()
->extension_app_shim_handler();
}
void ExtensionAppShimHandler::OnProfileLoaded(
Host* host,
AppShimLaunchType launch_type,
......
......@@ -83,6 +83,9 @@ class ExtensionAppShimHandler : public AppShimHandler,
// request user attention. Returns false if there is no shim for this window.
static bool RequestUserAttentionForWindow(AppWindow* app_window);
// Called by AppControllerMac when Chrome hides.
static void OnChromeWillHide();
// AppShimHandler overrides:
virtual void OnShimLaunch(Host* host,
AppShimLaunchType launch_type,
......@@ -118,6 +121,9 @@ class ExtensionAppShimHandler : public AppShimHandler,
content::NotificationRegistrar& registrar() { return registrar_; }
private:
// Helper function to get the instance on the browser process.
static ExtensionAppShimHandler* GetInstance();
// This is passed to Delegate::LoadProfileAsync for shim-initiated launches
// where the profile was not yet loaded.
void OnProfileLoaded(Host* host,
......
......@@ -367,6 +367,10 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
MacStartupProfiler::WILL_FINISH_LAUNCHING);
}
- (void)applicationWillHide:(NSNotification*)notification {
apps::ExtensionAppShimHandler::OnChromeWillHide();
}
- (BOOL)tryToTerminateApplication:(NSApplication*)app {
// Check for in-process downloads, and prompt the user if they really want
// to quit (and thus cancel downloads). Only check if we're not already
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment