#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#include "ui/views/linux_ui/linux_ui.h"
+#endif
+
using content::BrowserThread;
namespace {
const char kLockDelimiter = '-';
+const base::FilePath::CharType kSingletonCookieFilename[] =
+ FILE_PATH_LITERAL("SingletonCookie");
+
+const base::FilePath::CharType kSingletonLockFilename[] = FILE_PATH_LITERAL("SingletonLock");
+const base::FilePath::CharType kSingletonSocketFilename[] =
+ FILE_PATH_LITERAL("SingletonSocket");
+
// Set the close-on-exec bit on a file descriptor.
// Returns 0 on success, -1 on failure.
int SetCloseOnExec(int fd) {
bool DisplayProfileInUseError(const base::FilePath& lock_path,
const std::string& hostname,
int pid) {
- base::string16 error = l10n_util::GetStringFUTF16(
- IDS_PROFILE_IN_USE_POSIX,
- base::IntToString16(pid),
- base::ASCIIToUTF16(hostname));
- LOG(ERROR) << error;
-
- if (g_disable_prompt)
- return false;
-
-#if defined(OS_LINUX)
- base::string16 relaunch_button_text = l10n_util::GetStringUTF16(
- IDS_PROFILE_IN_USE_LINUX_RELAUNCH);
- return ShowProcessSingletonDialog(error, relaunch_button_text);
-#elif defined(OS_MACOSX)
- // On Mac, always usurp the lock.
+ // TODO: yolo
return true;
-#endif
-
- NOTREACHED();
- return false;
}
bool IsChromeProcess(pid_t pid) {
base::FilePath other_chrome_path(base::GetProcessExecutablePath(pid));
+
+ auto command_line = base::CommandLine::ForCurrentProcess();
+ base::FilePath exec_path(command_line->GetProgram());
+ PathService::Get(base::FILE_EXE, &exec_path);
+
return (!other_chrome_path.empty() &&
other_chrome_path.BaseName() ==
- base::FilePath(chrome::kBrowserProcessExecutableName));
+ exec_path.BaseName());
}
// A helper class to hold onto a socket.
if (cookie.empty())
return false;
base::FilePath remote_cookie = socket_target.DirName().
- Append(chrome::kSingletonCookieFilename);
+ Append(kSingletonCookieFilename);
// Verify the cookie before connecting.
if (!CheckCookie(remote_cookie, cookie))
return false;
: notification_callback_(notification_callback),
current_pid_(base::GetCurrentProcId()),
watcher_(new LinuxWatcher(this)) {
- socket_path_ = user_data_dir.Append(chrome::kSingletonSocketFilename);
- lock_path_ = user_data_dir.Append(chrome::kSingletonLockFilename);
- cookie_path_ = user_data_dir.Append(chrome::kSingletonCookieFilename);
+ socket_path_ = user_data_dir.Append(kSingletonSocketFilename);
+ lock_path_ = user_data_dir.Append(kSingletonLockFilename);
+ cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
kill_callback_ = base::Bind(&ProcessSingleton::KillProcess,
base::Unretained(this));
// Setup the socket symlink and the two cookies.
base::FilePath socket_target_path =
- socket_dir_.path().Append(chrome::kSingletonSocketFilename);
+ socket_dir_.path().Append(kSingletonSocketFilename);
base::FilePath cookie(GenerateCookie());
base::FilePath remote_cookie_path =
- socket_dir_.path().Append(chrome::kSingletonCookieFilename);
+ socket_dir_.path().Append(kSingletonCookieFilename);
UnlinkPath(socket_path_);
UnlinkPath(cookie_path_);
if (!SymlinkPath(socket_target_path, socket_path_) ||