mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
b91a6a24cc
- Bug 1001637 - Make math tables implement the nsIAccessibleTable interface. r=surkov (ebbb4325d6) - Bug 1149118 - Expose radio group with the correct role on OS X, r=surkov (4d4a95735c) - Bug 1113153 - use 'paragraph' role for paragraphs only, introduce 'text' role for small text containers, r=marcoz (14c4fa5881) - Bug 1175164 - Do not expose MathML semantics element in the accessibility tree. r=surkov (3945ae0367) - Bug 930843 part.1 Add test for checking isTrust attribute value of DOMActivate event r=smaug (14a49dd447) - Bug 930843 part.2 NS_UI_ACTIVATE event should be trusted event even if it's caused by an untrusted event r=smaug (e0af6165b5) - Bug 1156315 - Call DispatchInputEvent in more places on OS X. r=dvander (e24f42c09f) - Bug 1186015 part.1 Rename nsIMEContext to mozilla::widget::IMEContext r=jimm (077bf6e772) - Bug 1186015 part.2 Rename nsIMM32Handler to mozilla::widget::IMMHandler r=jimm+m_kato (a2098e33b5) - Bug 1184533 Rewrite range check in aOffset of nsIMM32Handler::GetCharacterRectOfSelectedTextAt() r=emk (fb68bc3c56) - Bug 555642 part.1 nsCaret should have a way to override the caret visible state for hiding caret temporarily and nsEditor should hide caret if composition string doesn't have caret information r=roc (9de4aa366c) - Bug 1171847 Remove unnecessary ',' in logging code in nsTextStore::Initialize() r=m_kato (78d0d43625) - Bug 1181714 nsTextStore should store previous focused document manager until new document manager actually gets focus r=m_kato (fd7e820af2) - Bug 1176950 nsTextStore should keep storing locked content until NOTIFY_IME_OF_COMPOSITION_UPDATE is notified r=emk (0a12349575) - Bug 1137539 part.1 Implement TSFStaticSink::IsGoogleJapaneseInputActive() r=emk (68d1f9a0ec) - Bug 1137539 part.2 Implement TSFStaticSink::IsATOKActive() r=emk (51a4208bfa) - Bug 1137539 part.3 Implement TSFStaticSink::IsFreeChangJieActive() r=emk (affbb81b96) - Bug 1137539 part.4 Implement TSFStaticSink::IsEasyChangjeiActive() r=emk (abd3e674b6) - Bug 1186014 Rename nsTextStore to mozilla::widget::TSFTextStore r=jimm+m_kato (ca63351f94) - Bug 1187351 TSFTextStore should forget modified range at notifying TSF of layout change since GetTextExt() shouldn't return TS_E_NOLAYOUT after that r=emk (48878793e0) - Bg 1187367 TSFTextStore shouldn't destroy native caret for ATOK until notifying TSF of layout change r=emk (a2a4022d15) - Bug 1187566 TSFTextStore::Content should compute mMinTextModified Offset only with the latest composition string and original composition string, and also the hack should be enabled on Win10 r=emk (1368885efe) - Bug 1050644 part.1 Add methods to check whether the active TIP is Chinese TIP which deosn't show candidate window in e10s mode r=emk (1b783e682e) - Bug 1050644 part.2 Hack ITextStoreACP::GetTextExt()'s offset for some Chinese TIPs of MS r=emk (c05cec10ce) - Bug 1187579 Enable TSF in e10s mode r=m_kato (1ae106231a) - Bug 555642 part.2 IME handlers on Windows shouldn't append caret range if the caret is in the target clause which doesn't have specific style r=m_kato (88bae2c8da) - Bug 1196124 Fix mismatch of printf style string and following arguments of MOZ_LOG() in IMMHandler::GetCharacterRectOfSelectedTextAt() r=m_kato (0f6debd0d3) - Bug 90712 Cancel composition when Enter key message isn't consumed by IME r=m_kato (0febdb1fd9) - pointer style (6c984274cd) - Bug 1177268 - implement aria-rowcount/index and aria-colcount/index, r=marcoz (92ac300374) - Bug 1153135 - Return possibility PEN working while APZC is enabled. r=jimm (8bc77ff84f) - Bug 1171073 - Suppress content scrolling issue on 64-bit platforms. r=kats (62db0dead3) - Bug 1121946, Implement e10 cursor drag feedback on Windows, r=jmathies (6e8218d202) - Bug 1144650 - Don't dispatch touch-based mouse events when APZ is handling touch. r=jimm (53ebea0d90) - Bug 1163056 - InkCollector activation at first PEN event. r=jimm (b28e0ee58b) - Bug 895274 part.3 Make the enum of event messages a named enum IGNORE IDL r=smaug (32e04a4e90) - spacing (b9249221dc) - Bug 1182966 - Part 3: Add some final annotations to DomainSet. r=mrbkap (3455822e89) - Bug 1050122 - Part 1: Enable Nuwa on debug builds, and kill it if the preference is false. r=khuey (46685a7bf3) - Bug 1146229: Remove calling convention modifier from local variable. r=surkov (e5f4b6e5d5) - bug 1168932 - Implement ProxyCreated and ProxyDestroyed to update mozAccessibles r=tbsaunde (77a007fa21) - Bug 1169701 - Fire native OS X accessibility events for proxied accessibles r=tbsaunde (c4847135a8) - bug 1172523 - fire useful text change events for proxies r=lsock (85b7f995b8) - remove spurious file (229c787360) - bug 1171117 - Fix cairo to build on iOS. r=jrmuizel (45709c8fe3) - Bug 963738 - Annotate XPCNativeMember, r=terrence (d1afdde52b) - Bug 1148383 - Add testcase for previously fixed object metadata issue r=terrence (2c1b762cba) - Bug 1149797 - Update browser jstests to treat ecma_6/extensions tests as 1.8, so that let is interpreted as a statement and not as an expression. r=bustage in a CLOSED TREE (ac6127d6bc) - Bug 1150858 - Unwrap the correct object in ArrayBuffer.transfer (r=sfink) (cf67906802) - Bug 1150380 - IonMonkey: MIPS: Fix JitRuntime::generateProfilerExitFrameTailStub. r=rankov (eeac49ddce) - use RootedValue for POW as in 1135708 (34c1c3d191) - Bug 1196648: IonMonkey - Don't run the lazy link stub for asmjs to jit fastpath, r=nbp (686d495371) - Bug 1121947, Implement e10 cursor drag feedback on Mac, r=smaug (f48df2d1) - and sync widget/TextEvents.h and TextRange.h with AF.
471 lines
15 KiB
C++
471 lines
15 KiB
C++
/* -*- 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/. */
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
|
#include "nsIDOMElement.h"
|
|
#include "nsIDOMHTMLImageElement.h"
|
|
#include "nsIImageLoadingContent.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsIContent.h"
|
|
#include "nsILocalFileMac.h"
|
|
#include "nsIObserverService.h"
|
|
#include "nsIPrefService.h"
|
|
#include "nsIServiceManager.h"
|
|
#include "nsIStringBundle.h"
|
|
#include "nsIURL.h"
|
|
#include "nsIWebBrowserPersist.h"
|
|
#include "nsMacShellService.h"
|
|
#include "nsIProperties.h"
|
|
#include "nsServiceManagerUtils.h"
|
|
#include "nsShellService.h"
|
|
#include "nsStringAPI.h"
|
|
#include "nsIDocShell.h"
|
|
#include "nsILoadContext.h"
|
|
|
|
#include <CoreFoundation/CoreFoundation.h>
|
|
#include <ApplicationServices/ApplicationServices.h>
|
|
|
|
#define NETWORK_PREFPANE NS_LITERAL_CSTRING("/System/Library/PreferencePanes/Network.prefPane")
|
|
#define DESKTOP_PREFPANE NS_LITERAL_CSTRING("/System/Library/PreferencePanes/DesktopScreenEffectsPref.prefPane")
|
|
|
|
#define SAFARI_BUNDLE_IDENTIFIER "com.apple.Safari"
|
|
|
|
NS_IMPL_ISUPPORTS(nsMacShellService, nsIMacShellService, nsIShellService, nsIWebProgressListener)
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::IsDefaultBrowser(bool aStartupCheck,
|
|
bool aForAllTypes,
|
|
bool* aIsDefaultBrowser)
|
|
{
|
|
*aIsDefaultBrowser = false;
|
|
|
|
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);
|
|
}
|
|
|
|
// If this is the first browser window, maintain internal state that we've
|
|
// checked this session (so that subsequent window opens don't show the
|
|
// default browser dialog).
|
|
if (aStartupCheck)
|
|
mCheckedThisSession = true;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::SetDefaultBrowser(bool aClaimAllTypes, 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 (aClaimAllTypes) {
|
|
if (::LSSetDefaultHandlerForURLScheme(CFSTR("ftp"), firefoxID) != noErr) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
if (::LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesAll, firefoxID) != noErr) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
|
{
|
|
// If we've already checked, the browser has been started and this is a
|
|
// new window open, and we don't want to check again.
|
|
if (mCheckedThisSession) {
|
|
*aResult = false;
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefs;
|
|
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
if (pserve)
|
|
pserve->GetBranch("", getter_AddRefs(prefs));
|
|
|
|
prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
|
{
|
|
nsCOMPtr<nsIPrefBranch> prefs;
|
|
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
if (pserve)
|
|
pserve->GetBranch("", getter_AddRefs(prefs));
|
|
|
|
prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::GetCanSetDesktopBackground(bool* aResult)
|
|
{
|
|
*aResult = true;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
|
int32_t aPosition)
|
|
{
|
|
// Note: We don't support aPosition on OS X.
|
|
|
|
// Get the image URI:
|
|
nsresult rv;
|
|
nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement,
|
|
&rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
nsCOMPtr<nsIURI> imageURI;
|
|
rv = imageContent->GetCurrentURI(getter_AddRefs(imageURI));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// We need the referer URI for nsIWebBrowserPersist::saveURI
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement, &rv);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsIURI *docURI = content->OwnerDoc()->GetDocumentURI();
|
|
if (!docURI)
|
|
return NS_ERROR_FAILURE;
|
|
|
|
// Get the desired image file name
|
|
nsCOMPtr<nsIURL> imageURL(do_QueryInterface(imageURI));
|
|
if (!imageURL) {
|
|
// XXXmano (bug 300293): Non-URL images (e.g. the data: protocol) are not
|
|
// yet supported. What filename should we take here?
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
nsAutoCString fileName;
|
|
imageURL->GetFileName(fileName);
|
|
nsCOMPtr<nsIProperties> fileLocator
|
|
(do_GetService("@mozilla.org/file/directory_service;1", &rv));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// 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;
|
|
|
|
nsAutoString fileNameUnicode;
|
|
CopyUTF8toUTF16(fileName, fileNameUnicode);
|
|
|
|
// 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);
|
|
|
|
uint32_t flags = nsIWebBrowserPersist::PERSIST_FLAGS_NO_CONVERSION |
|
|
nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES |
|
|
nsIWebBrowserPersist::PERSIST_FLAGS_FROM_CACHE;
|
|
|
|
wbp->SetPersistFlags(flags);
|
|
wbp->SetProgressListener(this);
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext;
|
|
nsCOMPtr<nsISupports> container = content->OwnerDoc()->GetContainer();
|
|
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
|
|
if (docShell) {
|
|
loadContext = do_QueryInterface(docShell);
|
|
}
|
|
|
|
return wbp->SaveURI(imageURI, nullptr, docURI, content->OwnerDoc()->GetReferrerPolicy(),
|
|
nullptr, nullptr, mBackgroundFile, loadContext);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OnProgressChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
int32_t aCurSelfProgress,
|
|
int32_t aMaxSelfProgress,
|
|
int32_t aCurTotalProgress,
|
|
int32_t aMaxTotalProgress)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
nsIURI* aLocation,
|
|
uint32_t aFlags)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
nsresult aStatus,
|
|
const char16_t* aMessage)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
uint32_t aState)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OnStateChange(nsIWebProgress* aWebProgress,
|
|
nsIRequest* aRequest,
|
|
uint32_t aStateFlags,
|
|
nsresult aStatus)
|
|
{
|
|
if (aStateFlags & STATE_STOP) {
|
|
nsCOMPtr<nsIObserverService> os(do_GetService("@mozilla.org/observer-service;1"));
|
|
if (os)
|
|
os->NotifyObservers(nullptr, "shell:desktop-background-changed", nullptr);
|
|
|
|
bool exists = false;
|
|
mBackgroundFile->Exists(&exists);
|
|
if (!exists)
|
|
return NS_OK;
|
|
|
|
nsAutoCString nativePath;
|
|
mBackgroundFile->GetNativePath(nativePath);
|
|
|
|
AEDesc tAEDesc = { typeNull, nil };
|
|
OSErr err = noErr;
|
|
AliasHandle aliasHandle = nil;
|
|
FSRef pictureRef;
|
|
OSStatus status;
|
|
|
|
// Convert the path into a FSRef
|
|
status = ::FSPathMakeRef((const UInt8*)nativePath.get(), &pictureRef, nullptr);
|
|
if (status == noErr) {
|
|
err = ::FSNewAlias(nil, &pictureRef, &aliasHandle);
|
|
if (err == noErr && aliasHandle == nil)
|
|
err = paramErr;
|
|
|
|
if (err == noErr) {
|
|
// We need the descriptor (based on the picture file reference)
|
|
// for the 'Set Desktop Picture' apple event.
|
|
char handleState = ::HGetState((Handle)aliasHandle);
|
|
::HLock((Handle)aliasHandle);
|
|
err = ::AECreateDesc(typeAlias, *aliasHandle,
|
|
GetHandleSize((Handle)aliasHandle), &tAEDesc);
|
|
// unlock the alias handler
|
|
::HSetState((Handle)aliasHandle, handleState);
|
|
::DisposeHandle((Handle)aliasHandle);
|
|
}
|
|
if (err == noErr) {
|
|
AppleEvent tAppleEvent;
|
|
OSType sig = 'MACS';
|
|
AEBuildError tAEBuildError;
|
|
// Create a 'Set Desktop Pictue' Apple Event
|
|
err = ::AEBuildAppleEvent(kAECoreSuite, kAESetData, typeApplSignature,
|
|
&sig, sizeof(OSType), kAutoGenerateReturnID,
|
|
kAnyTransactionID, &tAppleEvent, &tAEBuildError,
|
|
"'----':'obj '{want:type (prop),form:prop" \
|
|
",seld:type('dpic'),from:'null'()},data:(@)",
|
|
&tAEDesc);
|
|
if (err == noErr) {
|
|
AppleEvent reply = { typeNull, nil };
|
|
// Sent the event we built, the reply event isn't necessary
|
|
err = ::AESend(&tAppleEvent, &reply, kAENoReply, kAENormalPriority,
|
|
kNoTimeOut, nil, nil);
|
|
::AEDisposeDesc(&tAppleEvent);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OpenApplication(int32_t aApplication)
|
|
{
|
|
nsresult rv = NS_OK;
|
|
CFURLRef appURL = nil;
|
|
OSStatus err = noErr;
|
|
|
|
switch (aApplication) {
|
|
case nsIShellService::APPLICATION_MAIL:
|
|
{
|
|
CFURLRef tempURL = ::CFURLCreateWithString(kCFAllocatorDefault,
|
|
CFSTR("mailto:"), nullptr);
|
|
err = ::LSGetApplicationForURL(tempURL, kLSRolesAll, nullptr, &appURL);
|
|
::CFRelease(tempURL);
|
|
}
|
|
break;
|
|
case nsIShellService::APPLICATION_NEWS:
|
|
{
|
|
CFURLRef tempURL = ::CFURLCreateWithString(kCFAllocatorDefault,
|
|
CFSTR("news:"), nullptr);
|
|
err = ::LSGetApplicationForURL(tempURL, kLSRolesAll, nullptr, &appURL);
|
|
::CFRelease(tempURL);
|
|
}
|
|
break;
|
|
case nsIMacShellService::APPLICATION_KEYCHAIN_ACCESS:
|
|
err = ::LSGetApplicationForInfo('APPL', 'kcmr', nullptr, kLSRolesAll, nullptr,
|
|
&appURL);
|
|
break;
|
|
case nsIMacShellService::APPLICATION_NETWORK:
|
|
{
|
|
nsCOMPtr<nsIFile> lf;
|
|
rv = NS_NewNativeLocalFile(NETWORK_PREFPANE, true, getter_AddRefs(lf));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
bool exists;
|
|
lf->Exists(&exists);
|
|
if (!exists)
|
|
return NS_ERROR_FILE_NOT_FOUND;
|
|
return lf->Launch();
|
|
}
|
|
break;
|
|
case nsIMacShellService::APPLICATION_DESKTOP:
|
|
{
|
|
nsCOMPtr<nsIFile> lf;
|
|
rv = NS_NewNativeLocalFile(DESKTOP_PREFPANE, true, getter_AddRefs(lf));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
bool exists;
|
|
lf->Exists(&exists);
|
|
if (!exists)
|
|
return NS_ERROR_FILE_NOT_FOUND;
|
|
return lf->Launch();
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (appURL && err == noErr) {
|
|
err = ::LSOpenCFURLRef(appURL, nullptr);
|
|
rv = err != noErr ? NS_ERROR_FAILURE : NS_OK;
|
|
|
|
::CFRelease(appURL);
|
|
}
|
|
|
|
return 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;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::OpenApplicationWithURI(nsIFile* aApplication, const nsACString& aURI)
|
|
{
|
|
nsCOMPtr<nsILocalFileMac> lfm(do_QueryInterface(aApplication));
|
|
CFURLRef appURL;
|
|
nsresult rv = lfm->GetCFURL(&appURL);
|
|
if (NS_FAILED(rv))
|
|
return rv;
|
|
|
|
const nsCString spec(aURI);
|
|
const UInt8* uriString = (const UInt8*)spec.get();
|
|
CFURLRef uri = ::CFURLCreateWithBytes(nullptr, uriString, aURI.Length(),
|
|
kCFStringEncodingUTF8, nullptr);
|
|
if (!uri)
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
CFArrayRef uris = ::CFArrayCreate(nullptr, (const void**)&uri, 1, nullptr);
|
|
if (!uris) {
|
|
::CFRelease(uri);
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
|
|
LSLaunchURLSpec launchSpec;
|
|
launchSpec.appURL = appURL;
|
|
launchSpec.itemURLs = uris;
|
|
launchSpec.passThruParams = nullptr;
|
|
launchSpec.launchFlags = kLSLaunchDefaults;
|
|
launchSpec.asyncRefCon = nullptr;
|
|
|
|
OSErr err = ::LSOpenFromURLSpec(&launchSpec, nullptr);
|
|
|
|
::CFRelease(uris);
|
|
::CFRelease(uri);
|
|
|
|
return err != noErr ? NS_ERROR_FAILURE : NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsMacShellService::GetDefaultFeedReader(nsIFile** _retval)
|
|
{
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
*_retval = nullptr;
|
|
|
|
CFStringRef defaultHandlerID = ::LSCopyDefaultHandlerForURLScheme(CFSTR("feed"));
|
|
if (!defaultHandlerID) {
|
|
defaultHandlerID = ::CFStringCreateWithCString(kCFAllocatorDefault,
|
|
SAFARI_BUNDLE_IDENTIFIER,
|
|
kCFStringEncodingASCII);
|
|
}
|
|
|
|
CFURLRef defaultHandlerURL = nullptr;
|
|
OSStatus status = ::LSFindApplicationForInfo(kLSUnknownCreator,
|
|
defaultHandlerID,
|
|
nullptr, // inName
|
|
nullptr, // outAppRef
|
|
&defaultHandlerURL);
|
|
|
|
if (status == noErr && defaultHandlerURL) {
|
|
nsCOMPtr<nsILocalFileMac> defaultReader =
|
|
do_CreateInstance("@mozilla.org/file/local;1", &rv);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
rv = defaultReader->InitWithCFURL(defaultHandlerURL);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
NS_ADDREF(*_retval = defaultReader);
|
|
rv = NS_OK;
|
|
}
|
|
}
|
|
|
|
::CFRelease(defaultHandlerURL);
|
|
}
|
|
|
|
::CFRelease(defaultHandlerID);
|
|
|
|
return rv;
|
|
}
|