michael@0: /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsOSHelperAppService_h__ michael@0: #define nsOSHelperAppService_h__ michael@0: michael@0: // The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each michael@0: // platform. It contains platform specific code for finding helper applications for a given mime type michael@0: // in addition to launching those applications. michael@0: michael@0: #include "nsExternalHelperAppService.h" michael@0: #include "nsCExternalHandlerService.h" michael@0: #include "nsMIMEInfoImpl.h" michael@0: #include "nsCOMPtr.h" michael@0: #include michael@0: michael@0: #ifdef _WIN32_WINNT michael@0: #undef _WIN32_WINNT michael@0: #endif michael@0: #define _WIN32_WINNT 0x0600 michael@0: #include michael@0: michael@0: class nsMIMEInfoWin; michael@0: michael@0: class nsOSHelperAppService : public nsExternalHelperAppService michael@0: { michael@0: public: michael@0: nsOSHelperAppService(); michael@0: virtual ~nsOSHelperAppService(); michael@0: michael@0: // override nsIExternalProtocolService methods michael@0: nsresult OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists); michael@0: nsresult LoadUriInternal(nsIURI * aURL); michael@0: NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval); michael@0: michael@0: // method overrides for windows registry look up steps.... michael@0: already_AddRefed GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, bool *aFound); michael@0: NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString &aScheme, michael@0: bool *found, michael@0: nsIHandlerInfo **_retval); michael@0: michael@0: /** Get the string value of a registry value and store it in result. michael@0: * @return true on success, false on failure michael@0: */ michael@0: static bool GetValueString(HKEY hKey, const char16_t* pValueName, nsAString& result); michael@0: michael@0: // Removes registry command handler parameters, quotes, and expands environment strings. michael@0: static bool CleanupCmdHandlerPath(nsAString& aCommandHandler); michael@0: michael@0: protected: michael@0: nsresult GetDefaultAppInfo(const nsAString& aTypeName, nsAString& aDefaultDescription, nsIFile** aDefaultApplication); michael@0: // Lookup a mime info by extension, using an optional type hint michael@0: already_AddRefed GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint = nullptr); michael@0: nsresult FindOSMimeInfoForType(const char * aMimeContentType, nsIURI * aURI, char ** aFileExtension, nsIMIMEInfo ** aMIMEInfo); michael@0: michael@0: static nsresult GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo); michael@0: /// Looks up the type for the extension aExt and compares it to aType michael@0: static bool typeFromExtEquals(const char16_t* aExt, const char *aType); michael@0: michael@0: private: michael@0: IApplicationAssociationRegistration* mAppAssoc; michael@0: }; michael@0: michael@0: #endif // nsOSHelperAppService_h__