summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 11:06:37 +0000
committerjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 11:06:37 +0000
commit732c3b5f4cd39b150902df4fea50e4a3e67a8db7 (patch)
treecfbc69b6e013854eafa10a630865f11c9970d514 /apps
parent3b5e88dd5481f9b97445f860a6cc3809d8bc6ac4 (diff)
downloadchromium_src-732c3b5f4cd39b150902df4fea50e4a3e67a8db7.zip
chromium_src-732c3b5f4cd39b150902df4fea50e4a3e67a8db7.tar.gz
chromium_src-732c3b5f4cd39b150902df4fea50e4a3e67a8db7.tar.bz2
Add Hide to app menu.
This adds "Hide <app>" to the app menu that is shown when an app window has focus. This also enables the Cmd+H shortcut. This also adds an IPC message to instruct the shim to hide. This also adds a command ID for Hide and a corresponding tag to MainMenu.xib. BUG=168080, 276052 TEST=Start an app. Press Cmd+H or select Hide from the main menu. The app should hide. Clicking the app's dock icon, or Cmd+Tab to the app should show it again. Review URL: https://chromiumcodereview.appspot.com/23514021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r--apps/app_shim/app_shim_handler_mac.h2
-rw-r--r--apps/app_shim/app_shim_host_mac.cc4
-rw-r--r--apps/app_shim/app_shim_host_mac.h1
-rw-r--r--apps/app_shim/app_shim_messages.h3
-rw-r--r--apps/app_shim/app_shim_quit_interactive_uitest_mac.mm1
-rw-r--r--apps/app_shim/chrome_main_app_mode_mac.mm8
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac.cc12
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac.h2
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac_unittest.cc1
9 files changed, 34 insertions, 0 deletions
diff --git a/apps/app_shim/app_shim_handler_mac.h b/apps/app_shim/app_shim_handler_mac.h
index bb908f9..e442e64 100644
--- a/apps/app_shim/app_shim_handler_mac.h
+++ b/apps/app_shim/app_shim_handler_mac.h
@@ -24,6 +24,8 @@ class AppShimHandler {
virtual void OnAppLaunchComplete(AppShimLaunchResult result) = 0;
// Invoked when the app is closed in the browser process.
virtual void OnAppClosed() = 0;
+ // Invoked when the app should be hidden.
+ virtual void OnAppHide() = 0;
// Invoked when the app is requesting user attention.
virtual void OnAppRequestUserAttention() = 0;
diff --git a/apps/app_shim/app_shim_host_mac.cc b/apps/app_shim/app_shim_host_mac.cc
index aba1a58..6762873 100644
--- a/apps/app_shim/app_shim_host_mac.cc
+++ b/apps/app_shim/app_shim_host_mac.cc
@@ -114,6 +114,10 @@ void AppShimHost::OnAppClosed() {
Close();
}
+void AppShimHost::OnAppHide() {
+ Send(new AppShimMsg_Hide);
+}
+
void AppShimHost::OnAppRequestUserAttention() {
Send(new AppShimMsg_RequestUserAttention);
}
diff --git a/apps/app_shim/app_shim_host_mac.h b/apps/app_shim/app_shim_host_mac.h
index 9c3c948..e7eabf7 100644
--- a/apps/app_shim/app_shim_host_mac.h
+++ b/apps/app_shim/app_shim_host_mac.h
@@ -65,6 +65,7 @@ class AppShimHost : public IPC::Listener,
// apps::AppShimHandler::Host overrides:
virtual void OnAppLaunchComplete(apps::AppShimLaunchResult result) OVERRIDE;
virtual void OnAppClosed() OVERRIDE;
+ virtual void OnAppHide() OVERRIDE;
virtual void OnAppRequestUserAttention() OVERRIDE;
virtual base::FilePath GetProfilePath() const OVERRIDE;
virtual std::string GetAppId() const OVERRIDE;
diff --git a/apps/app_shim/app_shim_messages.h b/apps/app_shim/app_shim_messages.h
index e0fd299..26a0263 100644
--- a/apps/app_shim/app_shim_messages.h
+++ b/apps/app_shim/app_shim_messages.h
@@ -25,6 +25,9 @@ IPC_ENUM_TRAITS_MAX_VALUE(apps::AppShimFocusType,
IPC_MESSAGE_CONTROL1(AppShimMsg_LaunchApp_Done,
apps::AppShimLaunchResult /* launch result */)
+// Instructs the shim to hide the app.
+IPC_MESSAGE_CONTROL0(AppShimMsg_Hide)
+
// Instructs the shim to request user attention.
IPC_MESSAGE_CONTROL0(AppShimMsg_RequestUserAttention)
diff --git a/apps/app_shim/app_shim_quit_interactive_uitest_mac.mm b/apps/app_shim/app_shim_quit_interactive_uitest_mac.mm
index 4a74457..2651f61 100644
--- a/apps/app_shim/app_shim_quit_interactive_uitest_mac.mm
+++ b/apps/app_shim/app_shim_quit_interactive_uitest_mac.mm
@@ -39,6 +39,7 @@ class FakeHost : public apps::AppShimHandler::Host {
virtual void OnAppClosed() OVERRIDE {
handler_->OnShimClose(this);
}
+ virtual void OnAppHide() OVERRIDE {}
virtual void OnAppRequestUserAttention() OVERRIDE {}
virtual base::FilePath GetProfilePath() const OVERRIDE {
return profile_path_;
diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm
index 3ca7c3f..09d7ab7 100644
--- a/apps/app_shim/chrome_main_app_mode_mac.mm
+++ b/apps/app_shim/chrome_main_app_mode_mac.mm
@@ -99,6 +99,9 @@ class AppShimController : public IPC::Listener {
// shim process should die.
void OnLaunchAppDone(apps::AppShimLaunchResult result);
+ // Hide this app.
+ void OnHide();
+
// Requests user attention.
void OnRequestUserAttention();
@@ -191,6 +194,7 @@ bool AppShimController::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AppShimController, message)
IPC_MESSAGE_HANDLER(AppShimMsg_LaunchApp_Done, OnLaunchAppDone)
+ IPC_MESSAGE_HANDLER(AppShimMsg_Hide, OnHide)
IPC_MESSAGE_HANDLER(AppShimMsg_RequestUserAttention, OnRequestUserAttention)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -211,6 +215,10 @@ void AppShimController::OnLaunchAppDone(apps::AppShimLaunchResult result) {
launch_app_done_ = true;
}
+void AppShimController::OnHide() {
+ [NSApp hide:nil];
+}
+
void AppShimController::OnRequestUserAttention() {
[NSApp requestUserAttention:NSInformationalRequest];
}
diff --git a/apps/app_shim/extension_app_shim_handler_mac.cc b/apps/app_shim/extension_app_shim_handler_mac.cc
index 7e26027..86929fd 100644
--- a/apps/app_shim/extension_app_shim_handler_mac.cc
+++ b/apps/app_shim/extension_app_shim_handler_mac.cc
@@ -183,6 +183,18 @@ void ExtensionAppShimHandler::QuitAppForWindow(ShellWindow* shell_window) {
}
}
+void ExtensionAppShimHandler::HideAppForWindow(ShellWindow* shell_window) {
+ ExtensionAppShimHandler* handler =
+ g_browser_process->platform_part()->app_shim_host_manager()->
+ extension_app_shim_handler();
+ Profile* profile = shell_window->profile();
+ Host* host = handler->FindHost(profile, shell_window->extension_id());
+ if (host)
+ host->OnAppHide();
+ else
+ SetAppHidden(profile, shell_window->extension_id(), true);
+}
+
// static
bool ExtensionAppShimHandler::RequestUserAttentionForWindow(
ShellWindow* shell_window) {
diff --git a/apps/app_shim/extension_app_shim_handler_mac.h b/apps/app_shim/extension_app_shim_handler_mac.h
index f707232..07f0527 100644
--- a/apps/app_shim/extension_app_shim_handler_mac.h
+++ b/apps/app_shim/extension_app_shim_handler_mac.h
@@ -69,6 +69,8 @@ class ExtensionAppShimHandler : public AppShimHandler,
static void QuitAppForWindow(ShellWindow* shell_window);
+ static void HideAppForWindow(ShellWindow* shell_window);
+
// Brings the window to the front without showing it and instructs the shim to
// request user attention. Returns false if there is no shim for this window.
static bool RequestUserAttentionForWindow(ShellWindow* shell_window);
diff --git a/apps/app_shim/extension_app_shim_handler_mac_unittest.cc b/apps/app_shim/extension_app_shim_handler_mac_unittest.cc
index c51a017a..0b46f10 100644
--- a/apps/app_shim/extension_app_shim_handler_mac_unittest.cc
+++ b/apps/app_shim/extension_app_shim_handler_mac_unittest.cc
@@ -102,6 +102,7 @@ class FakeHost : public apps::AppShimHandler::Host {
handler_->OnShimClose(this);
++close_count_;
}
+ virtual void OnAppHide() OVERRIDE {}
virtual void OnAppRequestUserAttention() OVERRIDE {}
virtual base::FilePath GetProfilePath() const OVERRIDE {
return profile_path_;