uriloader/exthandler/win/nsOSHelperAppService.h

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

mercurial