nsAlertsService.cpp 2.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
/* 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/. */

#include "nsXULAppAPI.h"

#include "nsAlertsService.h"
#include "nsStringGlue.h"

#include "nsISupportsArray.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIServiceManager.h"
#include "nsIDOMWindow.h"
#include "nsIWindowWatcher.h"
#include "nsToolkitCompsCID.h"

using namespace mozilla;

21
NS_IMPL_ISUPPORTS(nsEmbedAlertsService, nsIAlertsService, nsIAlertsProgressListener)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

nsEmbedAlertsService::nsEmbedAlertsService()
{
}

nsEmbedAlertsService::~nsEmbedAlertsService()
{
}

bool nsEmbedAlertsService::ShouldShowAlert()
{
  bool result = true;
  printf(">>>>>>Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
  return result;
}

38 39 40 41
NS_IMETHODIMP nsEmbedAlertsService::ShowAlertNotification(const nsAString& aImageUrl, const nsAString& aAlertTitle,
                                                          const nsAString& aAlertText, bool aAlertTextClickable,
                                                          const nsAString& aAlertCookie, nsIObserver* aAlertListener,
                                                          const nsAString& aAlertName, const nsAString& aBidi,
42 43
                                                          const nsAString& aLang, const nsAString & data, nsIPrincipal *principal,
                                                          bool aInPrivateBrowsing)
44
{
45
  printf(">>>>>>Func:%s::%d image:%s, title:%s, text:%s, clickable:%i, cookie:%s, name:%s\n", __PRETTY_FUNCTION__, __LINE__,
46 47 48 49 50 51 52 53 54 55
         NS_ConvertUTF16toUTF8(aImageUrl).get(),
         NS_ConvertUTF16toUTF8(aAlertTitle).get(),
         NS_ConvertUTF16toUTF8(aAlertText).get(),
         aAlertTextClickable,
         NS_ConvertUTF16toUTF8(aAlertCookie).get(),
         NS_ConvertUTF16toUTF8(aAlertName).get()
        );

  // Do not display the alert. Instead call alertfinished and get out.
  if (aAlertListener)
56
    aAlertListener->Observe(NULL, "alertclickcallback", PromiseFlatString(aAlertCookie).get());
57 58 59 60

  return NS_OK;
}

61
NS_IMETHODIMP nsEmbedAlertsService::CloseAlert(const nsAString & name, nsIPrincipal*)
62 63 64 65 66 67
{
  printf("nsEmbedAlertsService::CloseAlert: name:%s", NS_ConvertUTF16toUTF8(name).get());
  return NS_OK;
}


68 69 70 71 72 73 74 75 76 77 78 79 80 81
NS_IMETHODIMP nsEmbedAlertsService::OnProgress(const nsAString & aAlertName,
                                          int64_t aProgress,
                                          int64_t aProgressMax,
                                          const nsAString & aAlertText)
{
  printf(">>>>>>Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
  return NS_OK;
}

NS_IMETHODIMP nsEmbedAlertsService::OnCancel(const nsAString & aAlertName)
{
  printf(">>>>>>Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
  return NS_OK;
}