зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1251819 - Use the classic Control Panel if the Settings app believes the current Windows logon is a Microsoft account while actually it is not. r=jimm
This commit is contained in:
Родитель
e5f0bc1053
Коммит
24dc7a411b
|
@ -50,6 +50,9 @@
|
|||
#include <mbstring.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include <lm.h>
|
||||
#undef ACCESS_READ
|
||||
|
||||
#ifndef MAX_BUF
|
||||
#define MAX_BUF 4096
|
||||
#endif
|
||||
|
@ -642,9 +645,96 @@ nsWindowsShellService::LaunchControlPanelDefaultsSelectionUI()
|
|||
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWindowsShellService::LaunchControlPanelDefaultPrograms()
|
||||
{
|
||||
// Default Programs is a Vista+ feature
|
||||
if (!IsVistaOrLater()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Build the path control.exe path safely
|
||||
WCHAR controlEXEPath[MAX_PATH + 1] = { '\0' };
|
||||
if (!GetSystemDirectoryW(controlEXEPath, MAX_PATH)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
LPCWSTR controlEXE = L"control.exe";
|
||||
if (wcslen(controlEXEPath) + wcslen(controlEXE) >= MAX_PATH) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!PathAppendW(controlEXEPath, controlEXE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
WCHAR params[] = L"control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram";
|
||||
STARTUPINFOW si = {sizeof(si), 0};
|
||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||
si.wShowWindow = SW_SHOWDEFAULT;
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
if (!CreateProcessW(controlEXEPath, params, nullptr, nullptr, FALSE,
|
||||
0, nullptr, nullptr, &si, &pi)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
IsWindowsLogonConnected()
|
||||
{
|
||||
WCHAR userName[UNLEN + 1];
|
||||
DWORD size = ArrayLength(userName);
|
||||
if (!GetUserNameW(userName, &size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LPUSER_INFO_24 info;
|
||||
if (NetUserGetInfo(nullptr, userName, 24, (LPBYTE *)&info)
|
||||
!= NERR_Success) {
|
||||
return false;
|
||||
}
|
||||
bool connected = info->usri24_internet_identity;
|
||||
NetApiBufferFree(info);
|
||||
|
||||
return connected;
|
||||
}
|
||||
|
||||
static bool
|
||||
SettingsAppBelievesConnected()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWindowsRegKey> regKey =
|
||||
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
|
||||
NS_LITERAL_STRING("SOFTWARE\\Microsoft\\Windows\\Shell\\Associations"),
|
||||
nsIWindowsRegKey::ACCESS_READ);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t value;
|
||||
rv = regKey->ReadIntValue(NS_LITERAL_STRING("IsConnectedAtLogon"), &value);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!value;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsWindowsShellService::LaunchModernSettingsDialogDefaultApps()
|
||||
{
|
||||
if (!IsWindowsLogonConnected() && SettingsAppBelievesConnected()) {
|
||||
// Use the classic Control Panel to work around a bug of Windows 10.
|
||||
return LaunchControlPanelDefaultPrograms();
|
||||
}
|
||||
|
||||
IApplicationActivationManager* pActivator;
|
||||
HRESULT hr = CoCreateInstance(CLSID_ApplicationActivationManager,
|
||||
nullptr,
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
protected:
|
||||
bool IsDefaultBrowserVista(bool aCheckAllTypes, bool* aIsDefaultBrowser);
|
||||
nsresult LaunchControlPanelDefaultsSelectionUI();
|
||||
nsresult LaunchControlPanelDefaultPrograms();
|
||||
nsresult LaunchModernSettingsDialogDefaultApps();
|
||||
nsresult InvokeHTTPOpenAsVerb();
|
||||
nsresult LaunchHTTPHandlerPane();
|
||||
|
|
Загрузка…
Ссылка в новой задаче