This is rubbish let's pull the escape hatch.
Make all these arguments user-provided instead.
This commit is contained in:
parent
0a6a8192b6
commit
62c8a00347
2 changed files with 14 additions and 42 deletions
|
@ -99,8 +99,8 @@ class Browser : public WindowListObserver {
|
||||||
bool opened_at_login = false;
|
bool opened_at_login = false;
|
||||||
bool opened_as_hidden = false;
|
bool opened_as_hidden = false;
|
||||||
};
|
};
|
||||||
void SetLoginItemSettings(LoginItemSettings settings, mate::Arguments* start_args);
|
void SetLoginItemSettings(LoginItemSettings settings, mate::Arguments* args);
|
||||||
LoginItemSettings GetLoginItemSettings();
|
LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// Hide the application.
|
// Hide the application.
|
||||||
|
|
|
@ -43,7 +43,7 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
bool ReadAppCommandLine(mate::Arguments* args, base::string16* exe) {
|
||||||
// Executable Path
|
// Executable Path
|
||||||
if (!args->GetNext(exe)) {
|
if (!args->GetNext(exe)) {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
|
@ -155,7 +155,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
base::string16 exe;
|
base::string16 exe;
|
||||||
if (!GetProtocolLaunchPath(args, &exe))
|
if (!ReadAppCommandLine(args, &exe))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (keyVal == exe) {
|
if (keyVal == exe) {
|
||||||
|
@ -189,7 +189,7 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
base::string16 exe;
|
base::string16 exe;
|
||||||
if (!GetProtocolLaunchPath(args, &exe))
|
if (!ReadAppCommandLine(args, &exe))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Main Registry Key
|
// Main Registry Key
|
||||||
|
@ -219,7 +219,7 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
base::string16 exe;
|
base::string16 exe;
|
||||||
if (!GetProtocolLaunchPath(args, &exe))
|
if (!ReadAppCommandLine(args, &exe))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Main Registry Key
|
// Main Registry Key
|
||||||
|
@ -253,58 +253,30 @@ bool Browser::SetBadgeCount(int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::SetLoginItemSettings(LoginItemSettings settings,
|
void Browser::SetLoginItemSettings(LoginItemSettings settings,
|
||||||
mate::Arguments* start_args) {
|
mate::Arguments* args) {
|
||||||
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||||
|
|
||||||
if (settings.open_at_login) {
|
if (settings.open_at_login) {
|
||||||
base::FilePath appDir, execPath;
|
base::string16 exe;
|
||||||
if (PathService::Get(base::DIR_EXE, &appDir) &&
|
if (!ReadAppCommandLine(args, &exe)) return;
|
||||||
PathService::Get(base::FILE_EXE, &execPath)) {
|
|
||||||
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) {
|
key.WriteValue(GetAppUserModelID(), exe.c_str());
|
||||||
base::string16 appStartArg(base::StringPrintf(L"--processStart \"%s\"",
|
|
||||||
appName.c_str()));
|
|
||||||
|
|
||||||
base::string16 formattedStartArgs(L"");
|
|
||||||
std::vector<base::string16> startArgs;
|
|
||||||
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 %s",
|
|
||||||
updateDotExe.c_str(),
|
|
||||||
appStartArg.c_str(),
|
|
||||||
formattedStartArgs.c_str()));
|
|
||||||
|
|
||||||
key.WriteValue(GetAppUserModelID(), regEntry.c_str());
|
|
||||||
} else {
|
|
||||||
// TODO(charliehess): No Update.exe found, Windows Store build?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
key.DeleteValue(GetAppUserModelID());
|
key.DeleteValue(GetAppUserModelID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
Browser::LoginItemSettings Browser::GetLoginItemSettings(mate::Arguments* args) {
|
||||||
LoginItemSettings settings;
|
LoginItemSettings settings;
|
||||||
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||||
base::string16 keyVal;
|
base::string16 keyVal;
|
||||||
|
|
||||||
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
|
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
|
||||||
base::FilePath path;
|
base::string16 exe;
|
||||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
if (ReadAppCommandLine(args, &exe)) {
|
||||||
base::string16 exePath(path.value());
|
settings.open_at_login = keyVal == exe;
|
||||||
settings.open_at_login = keyVal == exePath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue