uriloader/exthandler/nsContentHandlerApp.cpp

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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  * vim:expandtab:shiftwidth=2:tabstop=2:cin:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "nsContentHandlerApp.h"
     8 #include "nsIURI.h"
     9 #include "nsIClassInfoImpl.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsString.h"
    13 #define NS_CONTENTHANDLER_CID \
    14 { 0x43ec2c82, 0xb9db, 0x4835, {0x80, 0x3f, 0x64, 0xc9, 0x72, 0x5a, 0x70, 0x28 } }
    16 NS_IMPL_CLASSINFO(nsContentHandlerApp, nullptr, 0, NS_CONTENTHANDLER_CID)
    17 NS_IMPL_ISUPPORTS_CI(nsContentHandlerApp, nsIHandlerApp)
    19 nsContentHandlerApp::nsContentHandlerApp(nsString aName, nsCString aType,
    20                                          ContentAction::Action& aAction) :
    21   mName(aName),
    22   mType(aType),
    23   mAction(aAction)
    24 {
    25 }
    27 ////////////////////////////////////////////////////////////////////////////////
    28 //// nsIHandlerInfo
    30 NS_IMETHODIMP nsContentHandlerApp::GetName(nsAString& aName)
    31 {
    32   aName.Assign(mName);
    33   return NS_OK;
    34 }
    36 NS_IMETHODIMP nsContentHandlerApp::SetName(const nsAString& aName)
    37 {
    38   mName.Assign(aName);
    39   return NS_OK;
    40 }
    42 NS_IMETHODIMP nsContentHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *_retval)
    43 {
    44   return NS_ERROR_NOT_IMPLEMENTED;
    45 }
    47 NS_IMETHODIMP nsContentHandlerApp::GetDetailedDescription(nsAString& aDetailedDescription)
    48 {
    49   aDetailedDescription.Assign(mDetailedDescription);
    50   return NS_OK;
    51 }
    53 NS_IMETHODIMP nsContentHandlerApp::SetDetailedDescription(const nsAString& aDetailedDescription)
    54 {
    55   mDetailedDescription.Assign(aDetailedDescription);
    56   return NS_OK;
    57 }
    59 NS_IMETHODIMP
    60 nsContentHandlerApp::LaunchWithURI(nsIURI *aURI,
    61                                    nsIInterfaceRequestor *aWindowContext)
    62 {
    63   nsAutoCString spec;
    64   nsresult rv = aURI->GetAsciiSpec(spec);
    65   NS_ENSURE_SUCCESS(rv,rv);
    66   const char* url = spec.get();
    68   QList<ContentAction::Action> actions = 
    69     ContentAction::Action::actionsForFile(QUrl(url), QString(mType.get()));
    70   for (int i = 0; i < actions.size(); ++i) {
    71     if (actions[i].name() == QString((QChar*)mName.get(), mName.Length())) {
    72       actions[i].trigger();
    73       break;
    74     }
    75   }
    77   return NS_OK;
    78 }

mercurial