michael@0: /* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsAndroidHandlerApp.h" michael@0: #include "AndroidBridge.h" michael@0: michael@0: using namespace mozilla::widget::android; michael@0: michael@0: michael@0: NS_IMPL_ISUPPORTS(nsAndroidHandlerApp, nsIHandlerApp, nsISharingHandlerApp) michael@0: michael@0: nsAndroidHandlerApp::nsAndroidHandlerApp(const nsAString& aName, michael@0: const nsAString& aDescription, michael@0: const nsAString& aPackageName, michael@0: const nsAString& aClassName, michael@0: const nsACString& aMimeType, michael@0: const nsAString& aAction) : michael@0: mName(aName), mDescription(aDescription), mPackageName(aPackageName), michael@0: mClassName(aClassName), mMimeType(aMimeType), mAction(aAction) michael@0: { michael@0: } michael@0: michael@0: nsAndroidHandlerApp::~nsAndroidHandlerApp() michael@0: { michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::GetName(nsAString & aName) michael@0: { michael@0: aName.Assign(mName); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::SetName(const nsAString & aName) michael@0: { michael@0: mName.Assign(aName); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::GetDetailedDescription(nsAString & aDescription) michael@0: { michael@0: aDescription.Assign(mDescription); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::SetDetailedDescription(const nsAString & aDescription) michael@0: { michael@0: mDescription.Assign(aDescription); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *aRetval) michael@0: { michael@0: nsCOMPtr aApp = do_QueryInterface(aHandlerApp); michael@0: *aRetval = aApp && aApp->mName.Equals(mName) && michael@0: aApp->mDescription.Equals(mDescription); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowContext) michael@0: { michael@0: nsCString uriSpec; michael@0: aURI->GetSpec(uriSpec); michael@0: return mozilla::widget::android::GeckoAppShell::OpenUriExternal michael@0: (NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ? michael@0: NS_OK : NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidHandlerApp::Share(const nsAString & data, const nsAString & title) michael@0: { michael@0: return mozilla::widget::android::GeckoAppShell::OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType), michael@0: mPackageName, mClassName, mAction) ? NS_OK : NS_ERROR_FAILURE; michael@0: } michael@0: