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