Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: apps/app_shim/app_shim_host_mac.cc

Issue 12723011: Giving focus to an app shim brings windows belonging to that app to the foreground. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: apps/app_shim/app_shim_host_mac.cc
diff --git a/apps/app_shim/app_shim_host_mac.cc b/apps/app_shim/app_shim_host_mac.cc
index 8cff755a21ef674490d6cee2a904e1a9f439fb22..b2d577f3d5499bf21054a39c04679ed281293d7b 100644
--- a/apps/app_shim/app_shim_host_mac.cc
+++ b/apps/app_shim/app_shim_host_mac.cc
@@ -15,8 +15,10 @@
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/extensions/application_launch.h"
+#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/common/extensions/extension_constants.h"
#include "ipc/ipc_channel_proxy.h"
+#include "ui/base/cocoa/focus_window_set.h"
AppShimHost::AppShimHost()
: channel_(NULL), profile_(NULL) {
@@ -38,6 +40,7 @@ bool AppShimHost::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AppShimHost, message)
IPC_MESSAGE_HANDLER(AppShimHostMsg_LaunchApp, OnLaunchApp)
+ IPC_MESSAGE_HANDLER(AppShimHostMsg_FocusApp, OnFocus)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -55,6 +58,23 @@ void AppShimHost::OnLaunchApp(std::string profile_dir, std::string app_id) {
Send(new AppShimMsg_LaunchApp_Done(success));
}
+void AppShimHost::OnFocus() {
+ DCHECK(CalledOnValidThread());
+ if (!profile_)
+ return;
+ extensions::ShellWindowRegistry* registry =
+ extensions::ShellWindowRegistry::Get(profile_);
+ const std::set<ShellWindow*> windows =
+ registry->GetShellWindowsForApp(app_id_);
+ std::set<gfx::NativeWindow> native_windows;
+ for (std::set<ShellWindow*>::const_iterator i = windows.begin();
+ i != windows.end();
+ ++i) {
+ native_windows.insert((*i)->GetNativeWindow());
+ }
+ ui::FocusWindowSet(native_windows);
+}
+
bool AppShimHost::LaunchAppImpl(const std::string& profile_dir,
const std::string& app_id) {
DCHECK(CalledOnValidThread());

Powered by Google App Engine
This is Rietveld 408576698