LCOV - code coverage report
Current view: top level - uriloader/exthandler - HandlerServiceParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 116 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 55 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "HandlerServiceParent.h"
       2             : #include "nsIHandlerService.h"
       3             : #include "nsIMIMEInfo.h"
       4             : #include "ContentHandlerService.h"
       5             : 
       6             : using mozilla::dom::HandlerInfo;
       7             : using mozilla::dom::HandlerApp;
       8             : using mozilla::dom::ContentHandlerService;
       9             : using mozilla::dom::RemoteHandlerApp;
      10             : 
      11             : namespace {
      12             : 
      13             : class ProxyHandlerInfo final : public nsIHandlerInfo {
      14             : public:
      15             :   explicit ProxyHandlerInfo(const HandlerInfo& aHandlerInfo);
      16             :   NS_DECL_ISUPPORTS;
      17             :   NS_DECL_NSIHANDLERINFO;
      18             : protected:
      19           0 :   ~ProxyHandlerInfo() {}
      20             :   HandlerInfo mHandlerInfo;
      21             :   nsHandlerInfoAction mPrefAction;
      22             :   nsCOMPtr<nsIMutableArray> mPossibleApps;
      23             : };
      24             : 
      25           0 : NS_IMPL_ISUPPORTS(ProxyHandlerInfo, nsIHandlerInfo)
      26             : 
      27           0 : ProxyHandlerInfo::ProxyHandlerInfo(const HandlerInfo& aHandlerInfo) : mHandlerInfo(aHandlerInfo), mPossibleApps(do_CreateInstance(NS_ARRAY_CONTRACTID))
      28             : {
      29           0 :   for (auto& happ : aHandlerInfo.possibleApplicationHandlers()) {
      30           0 :     mPossibleApps->AppendElement(new RemoteHandlerApp(happ), false);
      31             :   }
      32           0 : }
      33             : 
      34             : /* readonly attribute ACString type; */
      35           0 : NS_IMETHODIMP ProxyHandlerInfo::GetType(nsACString & aType)
      36             : {
      37           0 :   aType.Assign(mHandlerInfo.type());
      38           0 :   return NS_OK;
      39             : }
      40             : 
      41             : /* attribute AString description; */
      42           0 : NS_IMETHODIMP ProxyHandlerInfo::GetDescription(nsAString & aDescription)
      43             : {
      44           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      45             : }
      46           0 : NS_IMETHODIMP ProxyHandlerInfo::SetDescription(const nsAString & aDescription)
      47             : {
      48           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      49             : }
      50             : 
      51             : /* attribute nsIHandlerApp preferredApplicationHandler; */
      52           0 : NS_IMETHODIMP ProxyHandlerInfo::GetPreferredApplicationHandler(nsIHandlerApp * *aPreferredApplicationHandler)
      53             : {
      54           0 :   *aPreferredApplicationHandler = new RemoteHandlerApp(mHandlerInfo.preferredApplicationHandler());
      55           0 :   NS_IF_ADDREF(*aPreferredApplicationHandler);
      56           0 :   return NS_OK;
      57             : }
      58             : 
      59           0 : NS_IMETHODIMP ProxyHandlerInfo::SetPreferredApplicationHandler(nsIHandlerApp *aApp)
      60             : {
      61           0 :   nsString name;
      62           0 :   nsString detailedDescription;
      63           0 :   if (aApp) {
      64           0 :     aApp->GetName(name);
      65           0 :     aApp->GetDetailedDescription(detailedDescription);
      66             :   }
      67           0 :   HandlerApp happ(name, detailedDescription);
      68           0 :   mHandlerInfo = HandlerInfo(mHandlerInfo.type(),
      69           0 :                              mHandlerInfo.isMIMEInfo(),
      70           0 :                              mHandlerInfo.description(),
      71           0 :                              mHandlerInfo.alwaysAskBeforeHandling(),
      72             :                              happ,
      73           0 :                              mHandlerInfo.possibleApplicationHandlers(),
      74           0 :                              mHandlerInfo.preferredAction());
      75           0 :   return NS_OK;
      76             : }
      77             : 
      78             : /* readonly attribute nsIMutableArray possibleApplicationHandlers; */
      79           0 : NS_IMETHODIMP ProxyHandlerInfo::GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleApplicationHandlers)
      80             : {
      81           0 :   *aPossibleApplicationHandlers = mPossibleApps;
      82           0 :   NS_IF_ADDREF(*aPossibleApplicationHandlers);
      83           0 :   return NS_OK;
      84             : }
      85             : 
      86             : /* readonly attribute boolean hasDefaultHandler; */
      87           0 : NS_IMETHODIMP ProxyHandlerInfo::GetHasDefaultHandler(bool *aHasDefaultHandler)
      88             : {
      89           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      90             : }
      91             : 
      92             : /* readonly attribute AString defaultDescription; */
      93           0 : NS_IMETHODIMP ProxyHandlerInfo::GetDefaultDescription(nsAString & aDefaultDescription)
      94             : {
      95           0 :   return NS_ERROR_NOT_IMPLEMENTED;
      96             : }
      97             : 
      98             : /* void launchWithURI (in nsIURI aURI, [optional] in nsIInterfaceRequestor aWindowContext); */
      99           0 : NS_IMETHODIMP ProxyHandlerInfo::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowContext)
     100             : {
     101           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     102             : }
     103             : 
     104             : /* attribute ProxyHandlerInfoAction preferredAction; */
     105           0 : NS_IMETHODIMP ProxyHandlerInfo::GetPreferredAction(nsHandlerInfoAction *aPreferredAction)
     106             : {
     107           0 :   *aPreferredAction = mPrefAction;
     108           0 :   return NS_OK;
     109             : }
     110           0 : NS_IMETHODIMP ProxyHandlerInfo::SetPreferredAction(nsHandlerInfoAction aPreferredAction)
     111             : {
     112           0 :   mHandlerInfo = HandlerInfo(mHandlerInfo.type(),
     113           0 :                              mHandlerInfo.isMIMEInfo(),
     114           0 :                              mHandlerInfo.description(),
     115           0 :                              mHandlerInfo.alwaysAskBeforeHandling(),
     116           0 :                              mHandlerInfo.preferredApplicationHandler(),
     117           0 :                              mHandlerInfo.possibleApplicationHandlers(),
     118           0 :                              aPreferredAction);
     119           0 :   mPrefAction = aPreferredAction;
     120           0 :   return NS_OK;
     121             : }
     122             : 
     123             : /* attribute boolean alwaysAskBeforeHandling; */
     124           0 : NS_IMETHODIMP ProxyHandlerInfo::GetAlwaysAskBeforeHandling(bool *aAlwaysAskBeforeHandling)
     125             : {
     126           0 :   *aAlwaysAskBeforeHandling = mHandlerInfo.alwaysAskBeforeHandling();
     127           0 :   return NS_OK;
     128             : }
     129           0 : NS_IMETHODIMP ProxyHandlerInfo::SetAlwaysAskBeforeHandling(bool aAlwaysAskBeforeHandling)
     130             : {
     131           0 :   mHandlerInfo = HandlerInfo(mHandlerInfo.type(),
     132           0 :                              mHandlerInfo.isMIMEInfo(),
     133           0 :                              mHandlerInfo.description(),
     134             :                              aAlwaysAskBeforeHandling,
     135           0 :                              mHandlerInfo.preferredApplicationHandler(),
     136           0 :                              mHandlerInfo.possibleApplicationHandlers(),
     137           0 :                              mHandlerInfo.preferredAction());
     138           0 :   return NS_OK;
     139             : }
     140             : 
     141             : 
     142             : class ProxyMIMEInfo : public nsIMIMEInfo
     143             : {
     144             : public:
     145             :   NS_DECL_ISUPPORTS
     146             :   NS_DECL_NSIMIMEINFO
     147           0 :   NS_FORWARD_NSIHANDLERINFO(mProxyHandlerInfo->);
     148             : 
     149           0 :   explicit ProxyMIMEInfo(HandlerInfo aHandlerInfo) : mProxyHandlerInfo(new ProxyHandlerInfo(aHandlerInfo)) {}
     150             : 
     151             : private:
     152           0 :   virtual ~ProxyMIMEInfo() {}
     153             :   nsCOMPtr<nsIHandlerInfo> mProxyHandlerInfo;
     154             : 
     155             : protected:
     156             :   /* additional members */
     157             : };
     158             : 
     159           0 : NS_IMPL_ISUPPORTS(ProxyMIMEInfo, nsIMIMEInfo, nsIHandlerInfo)
     160             : 
     161             : /* nsIUTF8StringEnumerator getFileExtensions (); */
     162           0 : NS_IMETHODIMP ProxyMIMEInfo::GetFileExtensions(nsIUTF8StringEnumerator * *_retval)
     163             : {
     164           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     165             : }
     166             : 
     167             : /* void setFileExtensions (in AUTF8String aExtensions); */
     168           0 : NS_IMETHODIMP ProxyMIMEInfo::SetFileExtensions(const nsACString & aExtensions)
     169             : {
     170           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     171             : }
     172             : 
     173             : /* boolean extensionExists (in AUTF8String aExtension); */
     174           0 : NS_IMETHODIMP ProxyMIMEInfo::ExtensionExists(const nsACString & aExtension, bool *_retval)
     175             : {
     176           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     177             : }
     178             : 
     179             : /* void appendExtension (in AUTF8String aExtension); */
     180           0 : NS_IMETHODIMP ProxyMIMEInfo::AppendExtension(const nsACString & aExtension)
     181             : {
     182           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     183             : }
     184             : 
     185             : /* attribute AUTF8String primaryExtension; */
     186           0 : NS_IMETHODIMP ProxyMIMEInfo::GetPrimaryExtension(nsACString & aPrimaryExtension)
     187             : {
     188           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     189             : }
     190             : 
     191           0 : NS_IMETHODIMP ProxyMIMEInfo::SetPrimaryExtension(const nsACString & aPrimaryExtension)
     192             : {
     193           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     194             : }
     195             : 
     196             : /* readonly attribute ACString MIMEType; */
     197           0 : NS_IMETHODIMP ProxyMIMEInfo::GetMIMEType(nsACString & aMIMEType)
     198             : {
     199           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     200             : }
     201             : 
     202             : /* boolean equals (in nsIMIMEInfo aMIMEInfo); */
     203           0 : NS_IMETHODIMP ProxyMIMEInfo::Equals(nsIMIMEInfo *aMIMEInfo, bool *_retval)
     204             : {
     205           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     206             : }
     207             : 
     208             : /* readonly attribute nsIArray possibleLocalHandlers; */
     209           0 : NS_IMETHODIMP ProxyMIMEInfo::GetPossibleLocalHandlers(nsIArray * *aPossibleLocalHandlers)
     210             : {
     211           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     212             : }
     213             : 
     214             : /* void launchWithFile (in nsIFile aFile); */
     215           0 : NS_IMETHODIMP ProxyMIMEInfo::LaunchWithFile(nsIFile *aFile)
     216             : {
     217           0 :   return NS_ERROR_NOT_IMPLEMENTED;
     218             : }
     219             : 
     220           0 : static already_AddRefed<nsIHandlerInfo> WrapHandlerInfo(const HandlerInfo& aHandlerInfo) {
     221           0 :   nsCOMPtr<nsIHandlerInfo> info;
     222           0 :   if (aHandlerInfo.isMIMEInfo()) {
     223           0 :     info = new ProxyMIMEInfo(aHandlerInfo);
     224             :   } else {
     225           0 :     info = new ProxyHandlerInfo(aHandlerInfo);
     226             :   }
     227           0 :   return info.forget();
     228             : }
     229             : 
     230             : } // anonymous namespace
     231             : 
     232           0 : HandlerServiceParent::HandlerServiceParent()
     233             : {
     234           0 : }
     235             : 
     236           0 : HandlerServiceParent::~HandlerServiceParent()
     237             : {
     238           0 : }
     239             : 
     240             : mozilla::ipc::IPCResult
     241           0 : HandlerServiceParent::RecvFillHandlerInfo(const HandlerInfo& aHandlerInfoData,
     242             :                                           const nsCString& aOverrideType,
     243             :                                           HandlerInfo* handlerInfoData)
     244             : {
     245           0 :   nsCOMPtr<nsIHandlerInfo> info(WrapHandlerInfo(aHandlerInfoData));
     246           0 :   nsCOMPtr<nsIHandlerService> handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID);
     247           0 :   handlerSvc->FillHandlerInfo(info, aOverrideType);
     248           0 :   ContentHandlerService::nsIHandlerInfoToHandlerInfo(info, handlerInfoData);
     249           0 :   return IPC_OK();
     250             : }
     251             : 
     252             : mozilla::ipc::IPCResult
     253           0 : HandlerServiceParent::RecvExists(const HandlerInfo& aHandlerInfo,
     254             :                                  bool* exists)
     255             : {
     256           0 :   nsCOMPtr<nsIHandlerInfo> info(WrapHandlerInfo(aHandlerInfo));
     257           0 :   nsCOMPtr<nsIHandlerService> handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID);
     258           0 :   handlerSvc->Exists(info, exists);
     259           0 :   return IPC_OK();
     260             : }
     261             : 
     262             : mozilla::ipc::IPCResult
     263           0 : HandlerServiceParent::RecvGetTypeFromExtension(const nsCString& aFileExtension,
     264             :                                                nsCString* type)
     265             : {
     266           0 :   nsCOMPtr<nsIHandlerService> handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID);
     267           0 :   handlerSvc->GetTypeFromExtension(aFileExtension, *type);
     268           0 :   return IPC_OK();
     269             : }
     270             : 
     271           0 : void HandlerServiceParent::ActorDestroy(ActorDestroyReason aWhy)
     272             : {
     273           0 : }

Generated by: LCOV version 1.13