diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /uriloader/exthandler/nsContentHandlerApp.cpp | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'uriloader/exthandler/nsContentHandlerApp.cpp')
-rw-r--r-- | uriloader/exthandler/nsContentHandlerApp.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/uriloader/exthandler/nsContentHandlerApp.cpp b/uriloader/exthandler/nsContentHandlerApp.cpp new file mode 100644 index 000000000..ce3f7b90f --- /dev/null +++ b/uriloader/exthandler/nsContentHandlerApp.cpp @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim:expandtab:shiftwidth=2:tabstop=2:cin: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsContentHandlerApp.h" +#include "nsIURI.h" +#include "nsIClassInfoImpl.h" +#include "nsCOMPtr.h" +#include "nsString.h" + +#define NS_CONTENTHANDLER_CID \ +{ 0x43ec2c82, 0xb9db, 0x4835, {0x80, 0x3f, 0x64, 0xc9, 0x72, 0x5a, 0x70, 0x28 } } + +NS_IMPL_CLASSINFO(nsContentHandlerApp, nullptr, 0, NS_CONTENTHANDLER_CID) +NS_IMPL_ISUPPORTS_CI(nsContentHandlerApp, nsIHandlerApp) + +nsContentHandlerApp::nsContentHandlerApp(nsString aName, nsCString aType, + ContentAction::Action& aAction) : + mName(aName), + mType(aType), + mAction(aAction) +{ +} + +//////////////////////////////////////////////////////////////////////////////// +//// nsIHandlerInfo + +NS_IMETHODIMP nsContentHandlerApp::GetName(nsAString& aName) +{ + aName.Assign(mName); + return NS_OK; +} + +NS_IMETHODIMP nsContentHandlerApp::SetName(const nsAString& aName) +{ + mName.Assign(aName); + return NS_OK; +} + +NS_IMETHODIMP nsContentHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsContentHandlerApp::GetDetailedDescription(nsAString& aDetailedDescription) +{ + aDetailedDescription.Assign(mDetailedDescription); + return NS_OK; +} + +NS_IMETHODIMP nsContentHandlerApp::SetDetailedDescription(const nsAString& aDetailedDescription) +{ + mDetailedDescription.Assign(aDetailedDescription); + return NS_OK; +} + +NS_IMETHODIMP +nsContentHandlerApp::LaunchWithURI(nsIURI *aURI, + nsIInterfaceRequestor *aWindowContext) +{ + nsAutoCString spec; + nsresult rv = aURI->GetAsciiSpec(spec); + NS_ENSURE_SUCCESS(rv,rv); + const char* url = spec.get(); + + QList<ContentAction::Action> actions = + ContentAction::Action::actionsForFile(QUrl(url), QString(mType.get())); + for (int i = 0; i < actions.size(); ++i) { + if (actions[i].name() == QString((QChar*)mName.get(), mName.Length())) { + actions[i].trigger(); + break; + } + } + + return NS_OK; +} + |