Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsOSHelperAppService_h__ |
michael@0 | 7 | #define nsOSHelperAppService_h__ |
michael@0 | 8 | |
michael@0 | 9 | // The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each |
michael@0 | 10 | // platform. It contains platform specific code for finding helper applications for a given mime type |
michael@0 | 11 | // in addition to launching those applications. |
michael@0 | 12 | |
michael@0 | 13 | #include "nsExternalHelperAppService.h" |
michael@0 | 14 | #include "nsCExternalHandlerService.h" |
michael@0 | 15 | #include "nsMIMEInfoImpl.h" |
michael@0 | 16 | #include "nsCOMPtr.h" |
michael@0 | 17 | #include <windows.h> |
michael@0 | 18 | |
michael@0 | 19 | #ifdef _WIN32_WINNT |
michael@0 | 20 | #undef _WIN32_WINNT |
michael@0 | 21 | #endif |
michael@0 | 22 | #define _WIN32_WINNT 0x0600 |
michael@0 | 23 | #include <shlobj.h> |
michael@0 | 24 | |
michael@0 | 25 | class nsMIMEInfoWin; |
michael@0 | 26 | |
michael@0 | 27 | class nsOSHelperAppService : public nsExternalHelperAppService |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | nsOSHelperAppService(); |
michael@0 | 31 | virtual ~nsOSHelperAppService(); |
michael@0 | 32 | |
michael@0 | 33 | // override nsIExternalProtocolService methods |
michael@0 | 34 | nsresult OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists); |
michael@0 | 35 | nsresult LoadUriInternal(nsIURI * aURL); |
michael@0 | 36 | NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval); |
michael@0 | 37 | |
michael@0 | 38 | // method overrides for windows registry look up steps.... |
michael@0 | 39 | already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, bool *aFound); |
michael@0 | 40 | NS_IMETHOD GetProtocolHandlerInfoFromOS(const nsACString &aScheme, |
michael@0 | 41 | bool *found, |
michael@0 | 42 | nsIHandlerInfo **_retval); |
michael@0 | 43 | |
michael@0 | 44 | /** Get the string value of a registry value and store it in result. |
michael@0 | 45 | * @return true on success, false on failure |
michael@0 | 46 | */ |
michael@0 | 47 | static bool GetValueString(HKEY hKey, const char16_t* pValueName, nsAString& result); |
michael@0 | 48 | |
michael@0 | 49 | // Removes registry command handler parameters, quotes, and expands environment strings. |
michael@0 | 50 | static bool CleanupCmdHandlerPath(nsAString& aCommandHandler); |
michael@0 | 51 | |
michael@0 | 52 | protected: |
michael@0 | 53 | nsresult GetDefaultAppInfo(const nsAString& aTypeName, nsAString& aDefaultDescription, nsIFile** aDefaultApplication); |
michael@0 | 54 | // Lookup a mime info by extension, using an optional type hint |
michael@0 | 55 | already_AddRefed<nsMIMEInfoWin> GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint = nullptr); |
michael@0 | 56 | nsresult FindOSMimeInfoForType(const char * aMimeContentType, nsIURI * aURI, char ** aFileExtension, nsIMIMEInfo ** aMIMEInfo); |
michael@0 | 57 | |
michael@0 | 58 | static nsresult GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo); |
michael@0 | 59 | /// Looks up the type for the extension aExt and compares it to aType |
michael@0 | 60 | static bool typeFromExtEquals(const char16_t* aExt, const char *aType); |
michael@0 | 61 | |
michael@0 | 62 | private: |
michael@0 | 63 | IApplicationAssociationRegistration* mAppAssoc; |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | #endif // nsOSHelperAppService_h__ |