1 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "mozilla/Logging.h"
10 #include "mozilla/net/NeckoCommon.h"
11 #include "nsOSHelperAppServiceChild.h"
12 #include "nsISupports.h"
16 #include "nsIHandlerService.h"
17 #include "nsMimeTypes.h"
18 #include "nsMIMEInfoImpl.h"
19 #include "nsCExternalHandlerService.h"
21 #include "nsEmbedCID.h"
25 MOZ_LOG(nsExternalHelperAppService::sLog, mozilla::LogLevel::Info, \
28 #define LOG_ERR(...) \
29 MOZ_LOG(nsExternalHelperAppService::sLog, mozilla::LogLevel::Error, \
32 #define LOG_ENABLED() \
33 MOZ_LOG_TEST(nsExternalHelperAppService::sLog, mozilla::LogLevel::Info)
35 nsresult
nsOSHelperAppServiceChild::ExternalProtocolHandlerExists(
36 const char* aProtocolScheme
, bool* aHandlerExists
) {
38 nsCOMPtr
<nsIHandlerService
> handlerSvc
=
39 do_GetService(NS_HANDLERSERVICE_CONTRACTID
, &rv
);
40 if (NS_WARN_IF(NS_FAILED(rv
))) {
41 LOG_ERR("nsOSHelperAppServiceChild error: no handler service");
45 nsAutoCString
scheme(aProtocolScheme
);
46 *aHandlerExists
= false;
47 rv
= handlerSvc
->ExistsForProtocol(scheme
, aHandlerExists
);
48 LOG("nsOSHelperAppServiceChild::ExternalProtocolHandlerExists(): "
49 "protocol: %s, result: %" PRId32
,
50 aProtocolScheme
, static_cast<uint32_t>(rv
));
51 mozilla::Unused
<< NS_WARN_IF(NS_FAILED(rv
));
55 nsresult
nsOSHelperAppServiceChild::OSProtocolHandlerExists(const char* aScheme
,
57 // Use ExternalProtocolHandlerExists() which includes the
58 // OS-level check and remotes the call to the parent process.
59 return NS_ERROR_NOT_IMPLEMENTED
;
63 nsOSHelperAppServiceChild::GetApplicationDescription(const nsACString
& aScheme
,
66 nsCOMPtr
<nsIHandlerService
> handlerSvc
=
67 do_GetService(NS_HANDLERSERVICE_CONTRACTID
, &rv
);
68 if (NS_WARN_IF(NS_FAILED(rv
))) {
69 LOG_ERR("nsOSHelperAppServiceChild error: no handler service");
73 rv
= handlerSvc
->GetApplicationDescription(aScheme
, aRetVal
);
74 LOG("nsOSHelperAppServiceChild::GetApplicationDescription(): "
75 "scheme: %s, result: %" PRId32
", description: %s",
76 PromiseFlatCString(aScheme
).get(), static_cast<uint32_t>(rv
),
77 NS_ConvertUTF16toUTF8(aRetVal
).get());
78 mozilla::Unused
<< NS_WARN_IF(NS_FAILED(rv
));
83 nsOSHelperAppServiceChild::GetMIMEInfoFromOS(const nsACString
& aMIMEType
,
84 const nsACString
& aFileExt
,
86 nsIMIMEInfo
** aMIMEInfo
) {
88 nsCOMPtr
<nsIHandlerService
> handlerSvc
=
89 do_GetService(NS_HANDLERSERVICE_CONTRACTID
, &rv
);
90 if (NS_WARN_IF(NS_FAILED(rv
))) {
91 LOG_ERR("nsOSHelperAppServiceChild error: no handler service");
95 rv
= handlerSvc
->GetMIMEInfoFromOS(aMIMEType
, aFileExt
, aFound
, aMIMEInfo
);
96 LOG("nsOSHelperAppServiceChild::GetMIMEInfoFromOS(): "
97 "MIME type: %s, extension: %s, result: %" PRId32
,
98 PromiseFlatCString(aMIMEType
).get(), PromiseFlatCString(aFileExt
).get(),
99 static_cast<uint32_t>(rv
));
100 mozilla::Unused
<< NS_WARN_IF(NS_FAILED(rv
));
105 nsOSHelperAppServiceChild::GetProtocolHandlerInfoFromOS(
106 const nsACString
& aScheme
, bool* aFound
, nsIHandlerInfo
** aRetVal
) {
107 return NS_ERROR_NOT_IMPLEMENTED
;
111 nsOSHelperAppServiceChild::IsCurrentAppOSDefaultForProtocol(
112 const nsACString
& aScheme
, bool* aRetVal
) {
113 return NS_ERROR_NOT_IMPLEMENTED
;
116 nsresult
nsOSHelperAppServiceChild::GetFileTokenForPath(
117 const char16_t
* platformAppPath
, nsIFile
** aFile
) {
118 return NS_ERROR_NOT_IMPLEMENTED
;