/* -*- 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/. */
CFStringRef firefoxID = ::CFBundleGetIdentifier(::CFBundleGetMainBundle()); if (!firefoxID) { // CFBundleGetIdentifier is expected to return nullptr only if the specified // bundle doesn't have a bundle identifier in its plist. In this case, that // means a failure, since our bundle does have an identifier. return NS_ERROR_FAILURE;
}
// Get the default http handler's bundle ID (or nullptr if it has not been // explicitly set)
CFStringRef defaultBrowserID =
::LSCopyDefaultHandlerForURLScheme(CFSTR("http")); if (defaultBrowserID) {
*aIsDefaultBrowser =
::CFStringCompare(firefoxID, defaultBrowserID, 0) == kCFCompareEqualTo;
::CFRelease(defaultBrowserID);
}
return NS_OK;
}
NS_IMETHODIMP
nsMacShellService::SetDefaultBrowser(bool aForAllUsers) { // Note: We don't support aForAllUsers on Mac OS X.
CFStringRef firefoxID = ::CFBundleGetIdentifier(::CFBundleGetMainBundle()); if (!firefoxID) { return NS_ERROR_FAILURE;
}
if (::LSSetDefaultHandlerForURLScheme(CFSTR("http"), firefoxID) != noErr) { return NS_ERROR_FAILURE;
} if (::LSSetDefaultHandlerForURLScheme(CFSTR("https"), firefoxID) != noErr) { return NS_ERROR_FAILURE;
}
if (::LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesAll,
firefoxID) != noErr) { return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (prefs) {
(void)prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, true); // Reset the number of times the dialog should be shown // before it is silenced.
(void)prefs->SetIntPref(PREF_DEFAULTBROWSERCHECKCOUNT, 0);
}
return NS_OK;
}
NS_IMETHODIMP
nsMacShellService::SetDesktopBackground(Element* aElement, int32_t aPosition, const nsACString& aImageName) { // Note: We don't support aPosition on OS X.
// Get the current user's "Pictures" folder (That's ~/Pictures):
fileLocator->Get(NS_OSX_PICTURE_DOCUMENTS_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(mBackgroundFile)); if (!mBackgroundFile) return NS_ERROR_OUT_OF_MEMORY;
// and add the imgage file name itself:
mBackgroundFile->Append(fileNameUnicode);
// Download the image; the desktop background will be set in OnStateChange()
nsCOMPtr<nsIWebBrowserPersist> wbp(do_CreateInstance( "@mozilla.org/embedding/browser/nsWebBrowserPersist;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_IMETHODIMP
nsMacShellService::GetDesktopBackgroundColor(uint32_t* aColor) { // This method and |SetDesktopBackgroundColor| has no meaning on Mac OS X. // The mac desktop preferences UI uses pictures for the few solid colors it // supports. return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsMacShellService::SetDesktopBackgroundColor(uint32_t aColor) { // This method and |GetDesktopBackgroundColor| has no meaning on Mac OS X. // The mac desktop preferences UI uses pictures for the few solid colors it // supports. return NS_ERROR_NOT_IMPLEMENTED;
}
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.