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

Unified Diff: apps/app_shim/chrome_main_app_mode_mac.mm

Issue 66043003: Put app shim IPC socket in a temporary directory. (Mac) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 11 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/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..b52e4b5f12c890d5a0cec05051b3b077679669ef 100644
--- a/apps/app_shim/chrome_main_app_mode_mac.mm
+++ b/apps/app_shim/chrome_main_app_mode_mac.mm
@@ -14,6 +14,7 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
@@ -109,6 +110,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
tapted 2014/01/06 07:31:28 nit: I don't think this second sentence is true an
jackhou1 2014/01/07 05:24:36 Done.
+ // paths.
+ void CreateChannelAndSendLaunchApp(const base::FilePath& socket_path);
+
// Builds main menu bar items.
void SetUpMenu();
@@ -140,7 +146,8 @@ class AppShimController : public IPC::Listener {
// Terminates the app shim process.
void Close();
- IPC::ChannelProxy* channel_;
+ base::FilePath user_data_dir_;
+ scoped_ptr<IPC::ChannelProxy> channel_;
base::scoped_nsobject<AppShimDelegate> delegate_;
bool launch_app_done_;
bool ping_chrome_reply_received_;
@@ -149,8 +156,7 @@ class AppShimController : public IPC::Listener {
};
AppShimController::AppShimController()
- : channel_(NULL),
- delegate_([[AppShimDelegate alloc] init]),
+ : delegate_([[AppShimDelegate alloc] init]),
launch_app_done_(false),
ping_chrome_reply_received_(false) {
// Since AppShimController is created before the main message loop starts,
@@ -189,15 +195,29 @@ 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());
+
+ base::FilePath symlink_path =
+ user_data_dir_.Append(app_mode::kAppShimSocketName);
+
+ base::FilePath socket_path;
+ if (!base::ReadSymbolicLink(symlink_path, &socket_path)) {
+ // The path in the user data dir is not a symlink, try connecting directly.
+ CreateChannelAndSendLaunchApp(symlink_path);
+ return;
+ }
+
+ app_mode::VerifySocketPermissions(socket_path);
+
+ CreateChannelAndSendLaunchApp(socket_path);
+}
- base::FilePath socket_path =
- user_data_dir.Append(app_mode::kAppShimSocketName);
+void AppShimController::CreateChannelAndSendLaunchApp(
+ const base::FilePath& socket_path) {
IPC::ChannelHandle handle(socket_path.value());
- channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT,
- this, g_io_thread->message_loop_proxy().get());
+ channel_.reset(new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT,
+ this, g_io_thread->message_loop_proxy().get()));
bool launched_by_chrome =
CommandLine::ForCurrentProcess()->HasSwitch(

Powered by Google App Engine
This is Rietveld 408576698