uriloader/exthandler/android/nsExternalSharingAppService.cpp

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsExternalSharingAppService.h"
     7 #include "mozilla/ModuleUtils.h"
     8 #include "nsIClassInfoImpl.h"
    10 #include "AndroidBridge.h"
    11 #include "nsArrayUtils.h"
    12 #include "nsISupportsUtils.h"
    13 #include "nsComponentManagerUtils.h"
    15 using namespace mozilla;
    17 NS_IMPL_ISUPPORTS(nsExternalSharingAppService, nsIExternalSharingAppService)
    19 nsExternalSharingAppService::nsExternalSharingAppService()
    20 {
    21 }
    23 nsExternalSharingAppService::~nsExternalSharingAppService()
    24 {
    25 }
    27 NS_IMETHODIMP
    28 nsExternalSharingAppService::ShareWithDefault(const nsAString & data,
    29                                               const nsAString & mime,
    30                                               const nsAString & title)
    31 {
    32   NS_NAMED_LITERAL_STRING(sendAction, "android.intent.action.SEND");
    33   const nsString emptyString = EmptyString();
    34   return mozilla::widget::android::GeckoAppShell::OpenUriExternal(data,
    35            mime, emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
    36 }
    38 NS_IMETHODIMP
    39 nsExternalSharingAppService::GetSharingApps(const nsAString & aMIMEType,
    40                                             uint32_t *aLen,
    41                                             nsISharingHandlerApp ***aHandlers)
    42 {
    43   nsresult rv;
    44   NS_NAMED_LITERAL_STRING(sendAction, "android.intent.action.SEND");
    45   nsCOMPtr<nsIMutableArray> array = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
    46   NS_ENSURE_SUCCESS(rv, rv);
    47   if (!AndroidBridge::Bridge())
    48     return NS_OK;
    49   AndroidBridge::Bridge()->GetHandlersForMimeType(aMIMEType, array,
    50                                                   nullptr, sendAction);
    51   array->GetLength(aLen);
    52   *aHandlers =
    53     static_cast<nsISharingHandlerApp**>(NS_Alloc(sizeof(nsISharingHandlerApp*)
    54                                                  * *aLen));
    55   for (uint32_t i = 0; i < *aLen; i++) {
    56     rv = array->QueryElementAt(i, NS_GET_IID(nsISharingHandlerApp),
    57                                (void**)(*aHandlers + i));
    58     NS_ENSURE_SUCCESS(rv, rv);
    59   }
    60   return NS_OK;
    61 }

mercurial