diff -r 000000000000 -r 6474c204b198 widget/windows/winrt/ToastNotificationHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widget/windows/winrt/ToastNotificationHandler.h Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; 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/. */ + +#pragma once + +#include +#include +#include "mozwrlbase.h" +#include "nsString.h" + + +class ToastNotificationHandler { + typedef ABI::Windows::UI::Notifications::IToastNotification IToastNotification; + typedef ABI::Windows::UI::Notifications::IToastDismissedEventArgs IToastDismissedEventArgs; + typedef ABI::Windows::UI::Notifications::IToastNotificationManagerStatics IToastNotificationManagerStatics; + typedef ABI::Windows::UI::Notifications::ToastTemplateType ToastTemplateType; + typedef ABI::Windows::Data::Xml::Dom::IXmlNode IXmlNode; + typedef ABI::Windows::Data::Xml::Dom::IXmlDocument IXmlDocument; + + void SetNodeValueString(HSTRING inputString,Microsoft::WRL::ComPtr node, + Microsoft::WRL::ComPtr xml); + public: + ToastNotificationHandler() {}; + ~ToastNotificationHandler() {}; + + bool DisplayNotification(HSTRING title, HSTRING msg, HSTRING imagePath, + const nsAString& aCookie, const nsAString& aAppId); + bool DisplayTextNotification(HSTRING title, HSTRING msg, + const nsAString& aCookie, + const nsAString& aAppId); + HRESULT OnActivate(IToastNotification *notification, IInspectable *inspectable); + HRESULT OnDismiss(IToastNotification *notification, + IToastDismissedEventArgs* aArgs); + + private: + nsString mCookie; + Microsoft::WRL::ComPtr mToastNotificationManagerStatics; + + bool CreateWindowsNotificationFromXml(IXmlDocument *toastXml, + const nsAString& aAppId); + Microsoft::WRL::ComPtr InitializeXmlForTemplate(ToastTemplateType templateType); +};