Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom launch path in app.setLoginItemSettings #8515

Merged
merged 17 commits into from
Feb 6, 2017

Conversation

CharlieHess
Copy link
Contributor

This PR fixes #6901. It leverages the fine work by @MarshallOfSound in #6858 to add support for custom executables and command-line arguments in app.setLoginItemSettings. This allows it to properly support Squirrel.Windows, which needs to point to Update.exe instead of process.execPath. I've updated the documentation to include an example.

}
}

return settings;
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

docs/api/app.md Outdated
@@ -778,7 +786,7 @@ Returns `Object`:
**Note:** This API has no effect on
[MAS builds][mas-builds].

### `app.setLoginItemSettings(settings)` _macOS_ _Windows_
### `app.setLoginItemSettings(settings[, path, args])` _macOS_ _Windows_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new optional arguments feel like they could just be properties of the settings object, any feelings towards including them there vs. separate arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially tried to bolt them on but ran into issues with the Mate converter. Someone better than me at V8 could probably work it out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CharlieHess I pushed up a commit to bolt them on, let me know what you think.

if (launch_args.empty()) {
base::string16 formatString = includeOriginalArg ?
L"\"%s\" \"%%1\"" :
L"\"%s\"";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CharlieHess is there a reason the path needs to be quoted here for login item settings path?

I ask because I'm wondering if this breaks backwards compatibility for people that previously used setLoginItemSettings which did not quote the path value in the old implementation. After this change, if they called getLoginItemSettings the paths would not match because it is not expected the registry value to be quoted when in previous releases it did not quote it.

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinsawicki I think it's still consistent. It was quoted before:

*exe = base::StringPrintf(L"\"%s\" \"%%1\"", exe->c_str());

The command line args were never quoted though:

L"\"%s\" %s \"%%1\""
L"\"%s\" %s"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But before GetLoginItemSettings wasn't calling this though, it was just using PathService::Get(base::FILE_EXE, &path) and comparing the value directly to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you call GetLoginItemSettings with no arguments (as before), ReadAppCommandLine will just dish to PathService and the behavior is the same (otherwise our existing unit tests would be failing, right?). I'll confirm tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess tests wouldn't cover backwards compatibility, though. 😞 I'll take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinsawicki yeah after closer inspection it was definitely not backwards compatible. Good catch. I've reworked it to avoid quoting the path in setLoginItemSettings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Will merge once the CI completes.

@kevinsawicki kevinsawicki merged commit 1835751 into master Feb 6, 2017
@kevinsawicki
Copy link
Contributor

Great work on this @CharlieHess 👍 🚢

@kevinsawicki kevinsawicki deleted the auto-launch-squirrel-support branch February 6, 2017 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow settings of custom exe and arguments when using the setLoginItem API
2 participants