Bumping manifests a=b2g-bump
[gecko.git] / uriloader / exthandler / nsContentHandlerApp.cpp
blobce3f7b90f52aab294114b9a362650317bf2f6f5d
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)
27 ////////////////////////////////////////////////////////////////////////////////
28 //// nsIHandlerInfo
30 NS_IMETHODIMP nsContentHandlerApp::GetName(nsAString& aName)
32 aName.Assign(mName);
33 return NS_OK;
36 NS_IMETHODIMP nsContentHandlerApp::SetName(const nsAString& aName)
38 mName.Assign(aName);
39 return NS_OK;
42 NS_IMETHODIMP nsContentHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *_retval)
44 return NS_ERROR_NOT_IMPLEMENTED;
47 NS_IMETHODIMP nsContentHandlerApp::GetDetailedDescription(nsAString& aDetailedDescription)
49 aDetailedDescription.Assign(mDetailedDescription);
50 return NS_OK;
53 NS_IMETHODIMP nsContentHandlerApp::SetDetailedDescription(const nsAString& aDetailedDescription)
55 mDetailedDescription.Assign(aDetailedDescription);
56 return NS_OK;
59 NS_IMETHODIMP
60 nsContentHandlerApp::LaunchWithURI(nsIURI *aURI,
61 nsIInterfaceRequestor *aWindowContext)
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;
77 return NS_OK;