| 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;
|
|
|