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

Unified Diff: apps/app_shim/app_shim_host_mac.cc

Issue 14514003: Make OSX App Launcher Launchable from the Dock. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase off cl14603002 Created 7 years, 8 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
« no previous file with comments | « apps/app_shim/app_shim_host_mac.h ('k') | apps/app_shim/app_shim_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b2d577f3d5499bf21054a39c04679ed281293d7b..4d2f16ec40eb9142225aa3aeef6896b2c391f015 100644
--- a/apps/app_shim/app_shim_host_mac.cc
+++ b/apps/app_shim/app_shim_host_mac.cc
@@ -14,6 +14,8 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/app_list/app_list_service.h"
+#include "chrome/browser/ui/app_list/app_list_service_mac.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -21,11 +23,15 @@
#include "ui/base/cocoa/focus_window_set.h"
AppShimHost::AppShimHost()
- : channel_(NULL), profile_(NULL) {
+ : channel_(NULL), profile_(NULL), is_app_list_(false) {
}
AppShimHost::~AppShimHost() {
DCHECK(CalledOnValidThread());
+ if (is_app_list_) {
+ chrome::RemoveAppListDismissObserver(this);
+ AppListService::Get()->DismissAppList();
+ }
}
void AppShimHost::ServeChannel(const IPC::ChannelHandle& handle) {
@@ -40,6 +46,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_LaunchAppList, OnLaunchAppList)
IPC_MESSAGE_HANDLER(AppShimHostMsg_FocusApp, OnFocus)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -47,6 +54,10 @@ bool AppShimHost::OnMessageReceived(const IPC::Message& message) {
return handled;
}
+void AppShimHost::OnChannelError() {
+ Close();
+}
+
bool AppShimHost::Send(IPC::Message* message) {
DCHECK(channel_.get());
return channel_->Send(message);
@@ -58,8 +69,19 @@ void AppShimHost::OnLaunchApp(std::string profile_dir, std::string app_id) {
Send(new AppShimMsg_LaunchApp_Done(success));
}
+void AppShimHost::OnLaunchAppList() {
+ DCHECK(CalledOnValidThread());
+ is_app_list_ = true;
+ AppListService::Get()->ShowForSavedProfile();
+ chrome::AddAppListDismissObserver(this);
+ Send(new AppShimMsg_LaunchApp_Done(true));
+}
+
void AppShimHost::OnFocus() {
DCHECK(CalledOnValidThread());
+ if (is_app_list_)
+ AppListService::Get()->DismissAppList();
+
if (!profile_)
return;
extensions::ShellWindowRegistry* registry =
@@ -82,6 +104,7 @@ bool AppShimHost::LaunchAppImpl(const std::string& profile_dir,
// Only one app launch message per channel.
return false;
}
+
if (!extensions::Extension::IdIsValid(app_id)) {
LOG(ERROR) << "Bad app ID from app shim launch message.";
return false;
@@ -112,7 +135,8 @@ Profile* AppShimHost::FetchProfileForDirectory(const std::string& profile_dir) {
// This ensures that the given profile path is acutally a profile that we
// already know about.
if (cache.GetIndexOfProfileWithPath(path) == std::string::npos) {
- LOG(ERROR) << "Requested directory is not a known profile.";
+ LOG(ERROR) << "Requested directory is not a known profile '"
+ << profile_dir << "'.";
return NULL;
}
Profile* profile = profileManager->GetProfile(path);
@@ -167,6 +191,12 @@ void AppShimHost::Observe(int type,
}
}
+void AppShimHost::OnAppListDismissed() {
+ DCHECK(is_app_list_);
+ Send(new AppShimMsg_AppListDismissed());
+ Close();
+}
+
void AppShimHost::Close() {
DCHECK(CalledOnValidThread());
delete this;
« no previous file with comments | « apps/app_shim/app_shim_host_mac.h ('k') | apps/app_shim/app_shim_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698