Close to a working Squirrel shortcut.

This commit is contained in:
CharlieHess 2017-01-25 02:19:22 -08:00 committed by Kevin Sawicki
parent 39b6bcb621
commit 0a6a8192b6
2 changed files with 17 additions and 13 deletions

View file

@ -98,9 +98,8 @@ class Browser : public WindowListObserver {
bool restore_state = false;
bool opened_at_login = false;
bool opened_as_hidden = false;
mate::Arguments* start_args;
};
void SetLoginItemSettings(LoginItemSettings settings);
void SetLoginItemSettings(LoginItemSettings settings, mate::Arguments* start_args);
LoginItemSettings GetLoginItemSettings();
#if defined(OS_MACOSX)

View file

@ -252,7 +252,8 @@ bool Browser::SetBadgeCount(int count) {
return false;
}
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
void Browser::SetLoginItemSettings(LoginItemSettings settings,
mate::Arguments* start_args) {
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
@ -260,24 +261,28 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
base::FilePath appDir, execPath;
if (PathService::Get(base::DIR_EXE, &appDir) &&
PathService::Get(base::FILE_EXE, &execPath)) {
base::FilePath updatePath = appDir.Append(
FILE_PATH_LITERAL("..\\Update.exe"));
base::FilePath updatePath = appDir
.Append(FILE_PATH_LITERAL("..\\Update.exe"));
base::string16 updateDotExe(updatePath.value());
base::string16 appName(execPath.BaseName().value());
if (GetFileAttributesW(updateDotExe.c_str()) != INVALID_FILE_ATTRIBUTES) {
base::string16* args = base::StringPrintf(L" --processStart \"%s\"",
appName.c_str());
base::string16 appStartArg(base::StringPrintf(L"--processStart \"%s\"",
appName.c_str()));
base::string16 formattedStartArgs(L"");
std::vector<base::string16> startArgs;
if (settings.start_args->GetNext(&startArgs) && !startArgs.empty()) {
args += base::StringPrintf(L" --process-start-args \"%s\"",
base::JoinString(startArgs, L" "));
if (start_args->GetNext(&startArgs) && !startArgs.empty()) {
formattedStartArgs =
base::StringPrintf(L"--process-start-args \"%s\"",
base::JoinString(startArgs, L" ").c_str());
}
base::string16* regEntry = base::StringPrintf(L"\"%s\" %s \"%%1\"",
base::string16 regEntry(base::StringPrintf(L"\"%s\" %s %s",
updateDotExe.c_str(),
args.c_str());
appStartArg.c_str(),
formattedStartArgs.c_str()));
key.WriteValue(GetAppUserModelID(), regEntry.c_str());
} else {