uriloader/exthandler/win/nsOSHelperAppService.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     6 #ifndef nsOSHelperAppService_h__
     7 #define nsOSHelperAppService_h__
     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.
    13 #include "nsExternalHelperAppService.h"
    14 #include "nsCExternalHandlerService.h"
    15 #include "nsMIMEInfoImpl.h"
    16 #include "nsCOMPtr.h"
    17 #include <windows.h>
    19 #ifdef _WIN32_WINNT
    20 #undef _WIN32_WINNT
    21 #endif
    22 #define _WIN32_WINNT 0x0600
    23 #include <shlobj.h>
    25 class nsMIMEInfoWin;
    27 class nsOSHelperAppService : public nsExternalHelperAppService
    28 {
    29 public:
    30   nsOSHelperAppService();
    31   virtual ~nsOSHelperAppService();
    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);
    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);
    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);
    49   // Removes registry command handler parameters, quotes, and expands environment strings.
    50   static bool CleanupCmdHandlerPath(nsAString& aCommandHandler);
    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);
    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);
    62 private:
    63   IApplicationAssociationRegistration* mAppAssoc;
    64 };
    66 #endif // nsOSHelperAppService_h__

mercurial