Chromium Code Reviews| Index: apps/app_shim/chrome_main_app_mode_mac.mm |
| diff --git a/apps/app_shim/chrome_main_app_mode_mac.mm b/apps/app_shim/chrome_main_app_mode_mac.mm |
| index 2c13ba23c29ec3de0afd7e68c465542fb17e6ced..5258dead7c7509cc4ef78d712c0d0d4a6ffc5c3a 100644 |
| --- a/apps/app_shim/chrome_main_app_mode_mac.mm |
| +++ b/apps/app_shim/chrome_main_app_mode_mac.mm |
| @@ -109,6 +109,11 @@ class AppShimController : public IPC::Listener { |
| // Connects to Chrome and sends a LaunchApp message. |
| void Init(); |
| + // Create a channel from |socket_path_| and send a LaunchApp message. |
| + // This may be called multiple times at startup to try to connect to different |
| + // paths. |
| + void CreateChannelAndSendLaunchApp(); |
| + |
| // Builds main menu bar items. |
| void SetUpMenu(); |
| @@ -140,6 +145,8 @@ class AppShimController : public IPC::Listener { |
| // Terminates the app shim process. |
| void Close(); |
| + base::FilePath user_data_dir_; |
| + base::FilePath socket_path_; |
|
tapted
2013/11/21 11:12:05
can this be an argument to CreateChannelAndSendLau
jackhou1
2013/11/22 00:20:40
Done.
|
| IPC::ChannelProxy* channel_; |
| base::scoped_nsobject<AppShimDelegate> delegate_; |
| bool launch_app_done_; |
| @@ -189,13 +196,19 @@ void AppShimController::Init() { |
| // The user_data_dir for shims actually contains the app_data_path. |
| // I.e. <user_data_dir>/<profile_dir>/Web Applications/_crx_extensionid/ |
| - base::FilePath user_data_dir = |
| - g_info->user_data_dir.DirName().DirName().DirName(); |
| - CHECK(!user_data_dir.empty()); |
| + user_data_dir_ = g_info->user_data_dir.DirName().DirName().DirName(); |
| + CHECK(!user_data_dir_.empty()); |
| + |
| + // Connect to the short socket path first. |
| + base::FilePath udd_plus_socket_name = |
| + user_data_dir_.Append(app_mode::kAppShimSocketName); |
| + socket_path_ = app_mode::GetShortSocketPath(udd_plus_socket_name); |
| + |
| + CreateChannelAndSendLaunchApp(); |
| +} |
| - base::FilePath socket_path = |
| - user_data_dir.Append(app_mode::kAppShimSocketName); |
| - IPC::ChannelHandle handle(socket_path.value()); |
| +void AppShimController::CreateChannelAndSendLaunchApp() { |
| + IPC::ChannelHandle handle(socket_path_.value()); |
| channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, |
| this, g_io_thread->message_loop_proxy().get()); |
| @@ -278,6 +291,15 @@ bool AppShimController::OnMessageReceived(const IPC::Message& message) { |
| } |
| void AppShimController::OnChannelError() { |
| + // On failure, try to connect to the long socket path. |
| + base::FilePath udd_plus_socket_name = |
| + user_data_dir_.Append(app_mode::kAppShimSocketName); |
| + if (socket_path_ != udd_plus_socket_name) { |
|
tapted
2013/11/21 11:12:05
I think we shouldn't try this if we ever successfu
jackhou1
2013/11/22 00:20:40
Done.
|
| + socket_path_ = udd_plus_socket_name; |
| + CreateChannelAndSendLaunchApp(); |
| + return; |
| + } |
| + |
| Close(); |
| } |