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

Unified Diff: apps/app_shim/app_shim_host_mac.cc

Issue 14579006: Start app shim when app launched. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comment Created 7 years, 7 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_host_mac_unittest.cc » ('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 07c9903b6f2f320d05f3323b37d2aa9b01bb3d05..7ae2dd69b0ba373a9b54cc50eb0085808cc275e6 100644
--- a/apps/app_shim/app_shim_host_mac.cc
+++ b/apps/app_shim/app_shim_host_mac.cc
@@ -63,7 +63,9 @@ bool AppShimHost::Send(IPC::Message* message) {
return channel_->Send(message);
}
-void AppShimHost::OnLaunchApp(std::string profile_dir, std::string app_id) {
+void AppShimHost::OnLaunchApp(base::FilePath profile_dir,
+ std::string app_id,
+ apps::AppShimLaunchType launch_type) {
DCHECK(CalledOnValidThread());
DCHECK(!profile_);
if (profile_) {
@@ -72,10 +74,15 @@ void AppShimHost::OnLaunchApp(std::string profile_dir, std::string app_id) {
return;
}
- profile_ = FetchProfileForDirectory(profile_dir);
+ if (!(profile_ = FetchProfileForDirectory(profile_dir))) {
+ Send(new AppShimMsg_LaunchApp_Done(false));
+ return;
+ }
+
app_id_ = app_id;
+
apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_);
- bool success = handler && handler->OnShimLaunch(this);
+ bool success = handler && handler->OnShimLaunch(this, launch_type);
Send(new AppShimMsg_LaunchApp_Done(success));
}
@@ -93,24 +100,22 @@ void AppShimHost::OnQuit() {
handler->OnShimQuit(this);
}
-Profile* AppShimHost::FetchProfileForDirectory(const std::string& profile_dir) {
+Profile* AppShimHost::FetchProfileForDirectory(
+ const base::FilePath& profile_dir) {
ProfileManager* profileManager = g_browser_process->profile_manager();
- // Even though the name of this function is "unsafe", there's no security
- // issue here -- the check for the profile name in the profile info cache
- // ensures that we never access any directory that isn't a known profile.
- base::FilePath path = base::FilePath::FromUTF8Unsafe(profile_dir);
- path = profileManager->user_data_dir().Append(path);
+ // Check for the profile name in the profile info cache to ensure that we
+ // never access any directory that isn't a known profile.
+ base::FilePath path = profileManager->user_data_dir().Append(profile_dir);
ProfileInfoCache& cache = profileManager->GetProfileInfoCache();
- // 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 '"
- << profile_dir << "'.";
+ << profile_dir.value() << "'.";
return NULL;
}
Profile* profile = profileManager->GetProfile(path);
if (!profile) {
- LOG(ERROR) << "Couldn't get profile for directory '" << profile_dir << "'.";
+ LOG(ERROR) << "Couldn't get profile for directory '"
+ << profile_dir.value() << "'.";
return NULL;
}
return profile;
« no previous file with comments | « apps/app_shim/app_shim_host_mac.h ('k') | apps/app_shim/app_shim_host_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698