/* vim: se cin sw=2 ts=2 et : */ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
NS_IMETHODIMP
DefaultController::OnClose(void) {
MOZ_ASSERT_UNREACHABLE( "OnClose should not be called for " "TaskbarWindowPreviews"); return NS_OK;
}
NS_IMETHODIMP
DefaultController::OnActivate(bool* rAcceptActivation) {
*rAcceptActivation = true;
MOZ_ASSERT_UNREACHABLE( "OnActivate should not be called for " "TaskbarWindowPreviews"); return NS_OK;
}
hr = mTaskbar->HrInit(); if (FAILED(hr)) { // This may fail with shell extensions like blackbox installed.
NS_WARNING("Unable to initialize taskbar");
NS_RELEASE(mTaskbar); returnfalse;
} returntrue;
}
WinTaskbar::WinTaskbar() : mTaskbar(nullptr) {}
WinTaskbar::~WinTaskbar() { if (mTaskbar) { // match successful Initialize() call
NS_RELEASE(mTaskbar);
::CoUninitialize();
}
}
// static bool WinTaskbar::GenerateAppUserModelID(nsAString& aAppUserModelId, bool aPrivateBrowsing) { // If marked as such in prefs, use a hash of the profile path for the id // instead of the install path hash setup by the installer. if (Preferences::GetBool("taskbar.grouping.useprofile", false)) {
nsCOMPtr<nsIFile> profileDir;
NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(profileDir)); bool exists = false; if (profileDir && NS_SUCCEEDED(profileDir->Exists(&exists)) && exists) {
nsAutoCString path; if (NS_SUCCEEDED(profileDir->GetPersistentDescriptor(path))) {
nsAutoString id;
id.AppendInt(HashString(path)); if (!id.IsEmpty()) {
aAppUserModelId.Assign(id);
if (aPrivateBrowsing) {
aAppUserModelId.AppendLiteral(";PrivateBrowsingAUMID");
}
returntrue;
}
}
}
}
// The default value is set by the installer and is stored in the registry // under (HKLM||HKCU)/Software/Mozilla/Firefox/TaskBarIDs. If for any reason // hash generation operation fails, the installer will not store a value in // the registry or set ids on shortcuts. A lack of an id can also occur for // zipped builds.
nsCOMPtr<nsIXULAppInfo> appInfo =
do_GetService("@mozilla.org/xre/app-info;1");
nsCString appName; if (appInfo && NS_SUCCEEDED(appInfo->GetName(appName))) {
nsAutoString regKey;
regKey.AssignLiteral("Software\\Mozilla\\");
AppendASCIItoUTF16(appName, regKey);
regKey.AppendLiteral("\\TaskBarIDs");
WCHAR path[MAX_PATH]; if (GetModuleFileNameW(nullptr, path, MAX_PATH)) { wchar_t* slash = wcsrchr(path, '\\'); if (!slash) returnfalse;
*slash = '\0'; // no trailing slash
// If we haven't found an ID yet then use the install hash. In xpcshell tests // the directory provider may not have been initialized so bypass in this // case. if (aAppUserModelId.IsEmpty() && gDirServiceProvider) {
gDirServiceProvider->GetInstallHash(aAppUserModelId);
}
if (aPrivateBrowsing) {
aAppUserModelId.AppendLiteral(";PrivateBrowsingAUMID");
}
return !aAppUserModelId.IsEmpty();
}
// static bool WinTaskbar::GetAppUserModelID(nsAString& aAppUserModelId, bool aPrivateBrowsing) { // If an ID has already been set then use that.
PWSTR id; if (SUCCEEDED(GetCurrentProcessExplicitAppUserModelID(&id))) {
aAppUserModelId.Assign(id);
CoTaskMemFree(id);
}
NS_IMETHODIMP
WinTaskbar::GetAvailable(bool* aAvailable) { // ITaskbarList4::HrInit() may fail with shell extensions like blackbox // installed. Initialize early to return available=false in those cases.
*aAvailable = Initialize();
NS_IMETHODIMP
WinTaskbar::GetGroupIdForWindow(mozIDOMWindow* aParent,
nsAString& aIdentifier) {
NS_ENSURE_ARG_POINTER(aParent);
HWND toplevelHWND = ::GetAncestor(GetHWNDFromDOMWindow(aParent), GA_ROOT); if (!toplevelHWND) return NS_ERROR_INVALID_ARG;
RefPtr<IPropertyStore> pPropStore; if (FAILED(SHGetPropertyStoreForWindow(toplevelHWND, IID_IPropertyStore,
getter_AddRefs(pPropStore)))) { return NS_ERROR_INVALID_ARG;
}
PROPVARIANT pv;
PropVariantInit(&pv); auto cleanupPropVariant = MakeScopeExit([&] { PropVariantClear(&pv); }); if (FAILED(pPropStore->GetValue(PKEY_AppUserModel_ID, &pv))) { return NS_ERROR_FAILURE;
} if (pv.vt != VT_LPWSTR) { // This can happen when there is no window specific group ID set // It's not an error case so we have to check for empty strings // returned from the function. return NS_OK;
}
aIdentifier.Assign(char16ptr_t(pv.pwszVal)); return NS_OK;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.