fix: getLoginItemSettings() on windows (#26515)
* find by exe, detect taskmgr enable/disable * tests
This commit is contained in:
parent
2b4ce387bc
commit
dbe0f06c3d
2 changed files with 166 additions and 14 deletions
|
@ -196,19 +196,30 @@ std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
|
|||
const Browser::LoginItemSettings& options) {
|
||||
std::vector<Browser::LaunchItem> launch_items;
|
||||
|
||||
while (it->Valid()) {
|
||||
base::string16 exe = options.path;
|
||||
if (FormatCommandLineString(&exe, options.args)) {
|
||||
base::FilePath lookup_exe_path;
|
||||
if (options.path.empty()) {
|
||||
base::string16 process_exe_path;
|
||||
GetProcessExecPath(&process_exe_path);
|
||||
lookup_exe_path =
|
||||
base::CommandLine::FromString(process_exe_path).GetProgram();
|
||||
} else {
|
||||
lookup_exe_path = base::CommandLine::FromString(options.path).GetProgram();
|
||||
}
|
||||
|
||||
if (!lookup_exe_path.empty()) {
|
||||
while (it->Valid()) {
|
||||
base::CommandLine registry_launch_cmd =
|
||||
base::CommandLine::FromString(it->Value());
|
||||
base::FilePath registry_launch_path = registry_launch_cmd.GetProgram();
|
||||
bool exe_match = base::FilePath::CompareEqualIgnoreCase(
|
||||
lookup_exe_path.value(), registry_launch_path.value());
|
||||
|
||||
// add launch item to vector if it has a matching path (case-insensitive)
|
||||
if ((base::CompareCaseInsensitiveASCII(it->Value(), exe.c_str())) == 0) {
|
||||
if (exe_match) {
|
||||
Browser::LaunchItem launch_item;
|
||||
base::string16 launch_path = options.path;
|
||||
if (launch_path.empty()) {
|
||||
GetProcessExecPath(&launch_path);
|
||||
}
|
||||
launch_item.name = it->Name();
|
||||
launch_item.path = launch_path;
|
||||
launch_item.args = options.args;
|
||||
launch_item.path = registry_launch_path.value();
|
||||
launch_item.args = registry_launch_cmd.GetArgs();
|
||||
launch_item.scope = scope;
|
||||
launch_item.enabled = true;
|
||||
|
||||
|
@ -249,8 +260,8 @@ std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
|
|||
reinterpret_cast<char*>(binary_accepted_alt));
|
||||
std::string reg_startup_binary(
|
||||
reinterpret_cast<char*>(startup_binary));
|
||||
launch_item.enabled = (reg_binary == reg_startup_binary) ||
|
||||
(reg_binary == reg_binary_alt);
|
||||
launch_item.enabled = (reg_startup_binary == reg_binary) ||
|
||||
(reg_startup_binary == reg_binary_alt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,8 +270,8 @@ std::vector<Browser::LaunchItem> GetLoginItemSettingsHelper(
|
|||
*executable_will_launch_at_login || launch_item.enabled;
|
||||
launch_items.push_back(launch_item);
|
||||
}
|
||||
it->operator++();
|
||||
}
|
||||
it->operator++();
|
||||
}
|
||||
return launch_items;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue