2010-06-14 12:04:16 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; 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 "nsOSHelperAppService.h"
|
|
|
|
#include "nsMIMEInfoAndroid.h"
|
2010-07-16 11:24:42 -07:00
|
|
|
#include "AndroidBridge.h"
|
2010-06-14 12:04:16 -07:00
|
|
|
|
|
|
|
nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsOSHelperAppService::~nsOSHelperAppService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIMIMEInfo>
|
|
|
|
nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
|
|
|
|
const nsACString& aFileExt,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aFound)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
2010-08-19 18:33:06 -07:00
|
|
|
nsRefPtr<nsMIMEInfoAndroid> mimeInfo;
|
2011-10-17 07:59:28 -07:00
|
|
|
*aFound = false;
|
2010-08-19 18:33:06 -07:00
|
|
|
if (!aMIMEType.IsEmpty())
|
|
|
|
*aFound =
|
|
|
|
nsMIMEInfoAndroid::GetMimeInfoForMimeType(aMIMEType,
|
|
|
|
getter_AddRefs(mimeInfo));
|
|
|
|
if (!*aFound)
|
|
|
|
*aFound =
|
|
|
|
nsMIMEInfoAndroid::GetMimeInfoForFileExt(aFileExt,
|
|
|
|
getter_AddRefs(mimeInfo));
|
|
|
|
|
|
|
|
// Code that calls this requires an object regardless if the OS has
|
|
|
|
// something for us, so we return the empty object.
|
|
|
|
if (!*aFound)
|
|
|
|
mimeInfo = new nsMIMEInfoAndroid(aMIMEType);
|
2010-06-14 12:04:16 -07:00
|
|
|
|
2010-08-19 18:33:06 -07:00
|
|
|
return mimeInfo.forget();
|
2010-06-14 12:04:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsOSHelperAppService::OSProtocolHandlerExists(const char* aScheme,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aExists)
|
2010-06-14 12:04:16 -07:00
|
|
|
{
|
2013-09-09 05:57:36 -07:00
|
|
|
*aExists = mozilla::AndroidBridge::Bridge()->GetHandlersForURL(NS_ConvertUTF8toUTF16(aScheme));
|
2010-06-14 12:04:16 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-06-29 19:22:08 -07:00
|
|
|
|
|
|
|
nsresult nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool *found,
|
2010-06-29 19:22:08 -07:00
|
|
|
nsIHandlerInfo **info)
|
|
|
|
{
|
2010-11-23 15:40:46 -08:00
|
|
|
return nsMIMEInfoAndroid::GetMimeInfoForURL(aScheme, found, info);
|
2010-06-29 19:22:08 -07:00
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:36 -07:00
|
|
|
nsIHandlerApp*
|
|
|
|
nsOSHelperAppService::CreateAndroidHandlerApp(const nsAString& aName,
|
|
|
|
const nsAString& aDescription,
|
|
|
|
const nsAString& aPackageName,
|
|
|
|
const nsAString& aClassName,
|
|
|
|
const nsACString& aMimeType,
|
|
|
|
const nsAString& aAction)
|
|
|
|
{
|
|
|
|
return new nsAndroidHandlerApp(aName, aDescription, aPackageName,
|
|
|
|
aClassName, aMimeType, aAction);
|
|
|
|
}
|