2010-06-14 12:04:16 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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/. */
|
2010-06-14 12:04:16 -07:00
|
|
|
|
|
|
|
#include "nsAndroidHandlerApp.h"
|
2010-06-29 19:22:08 -07:00
|
|
|
#include "AndroidBridge.h"
|
|
|
|
|
2013-11-12 10:41:01 -08:00
|
|
|
using namespace mozilla::widget::android;
|
|
|
|
|
2010-06-14 12:04:16 -07:00
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsAndroidHandlerApp, nsIHandlerApp, nsISharingHandlerApp)
|
2010-06-14 12:04:16 -07:00
|
|
|
|
2010-06-29 19:22:08 -07:00
|
|
|
nsAndroidHandlerApp::nsAndroidHandlerApp(const nsAString& aName,
|
|
|
|
const nsAString& aDescription,
|
|
|
|
const nsAString& aPackageName,
|
|
|
|
const nsAString& aClassName,
|
2010-09-30 08:37:36 -07:00
|
|
|
const nsACString& aMimeType,
|
|
|
|
const nsAString& aAction) :
|
2010-06-29 19:22:08 -07:00
|
|
|
mName(aName), mDescription(aDescription), mPackageName(aPackageName),
|
2010-09-30 08:37:36 -07:00
|
|
|
mClassName(aClassName), mMimeType(aMimeType), mAction(aAction)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAndroidHandlerApp::~nsAndroidHandlerApp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAndroidHandlerApp::GetName(nsAString & aName)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
|
|
|
aName.Assign(mName);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAndroidHandlerApp::SetName(const nsAString & aName)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
|
|
|
mName.Assign(aName);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAndroidHandlerApp::GetDetailedDescription(nsAString & aDescription)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
|
|
|
aDescription.Assign(mDescription);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAndroidHandlerApp::SetDetailedDescription(const nsAString & aDescription)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
|
|
|
mDescription.Assign(aDescription);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-11 02:47:11 -07:00
|
|
|
// XXX Workaround for bug 986975 to maintain the existing broken semantics
|
|
|
|
template<>
|
|
|
|
struct nsISharingHandlerApp::COMTypeInfo<nsAndroidHandlerApp, void> {
|
|
|
|
static const nsIID kIID NS_HIDDEN;
|
|
|
|
};
|
|
|
|
const nsIID nsISharingHandlerApp::COMTypeInfo<nsAndroidHandlerApp, void>::kIID = NS_IHANDLERAPP_IID;
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsAndroidHandlerApp::Equals(nsIHandlerApp *aHandlerApp, bool *aRetval)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsAndroidHandlerApp> aApp = do_QueryInterface(aHandlerApp);
|
|
|
|
*aRetval = aApp && aApp->mName.Equals(mName) &&
|
|
|
|
aApp->mDescription.Equals(mDescription);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAndroidHandlerApp::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowContext)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
2010-06-29 19:22:08 -07:00
|
|
|
nsCString uriSpec;
|
|
|
|
aURI->GetSpec(uriSpec);
|
2014-04-01 05:29:25 -07:00
|
|
|
return mozilla::widget::android::GeckoAppShell::OpenUriExternal
|
|
|
|
(NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ?
|
2010-06-29 19:22:08 -07:00
|
|
|
NS_OK : NS_ERROR_FAILURE;
|
2010-09-30 08:37:36 -07:00
|
|
|
}
|
2010-06-29 19:22:08 -07:00
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAndroidHandlerApp::Share(const nsAString & data, const nsAString & title)
|
|
|
|
{
|
2014-04-01 05:29:25 -07:00
|
|
|
return mozilla::widget::android::GeckoAppShell::OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType),
|
|
|
|
mPackageName, mClassName, mAction) ? NS_OK : NS_ERROR_FAILURE;
|
2010-06-14 12:04:16 -07:00
|
|
|
}
|
2010-09-30 08:37:36 -07:00
|
|
|
|