1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/windows/winrt/ToastNotificationHandler.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#pragma once 1.10 + 1.11 +#include <windows.ui.notifications.h> 1.12 +#include <windows.data.xml.dom.h> 1.13 +#include "mozwrlbase.h" 1.14 +#include "nsString.h" 1.15 + 1.16 + 1.17 +class ToastNotificationHandler { 1.18 + typedef ABI::Windows::UI::Notifications::IToastNotification IToastNotification; 1.19 + typedef ABI::Windows::UI::Notifications::IToastDismissedEventArgs IToastDismissedEventArgs; 1.20 + typedef ABI::Windows::UI::Notifications::IToastNotificationManagerStatics IToastNotificationManagerStatics; 1.21 + typedef ABI::Windows::UI::Notifications::ToastTemplateType ToastTemplateType; 1.22 + typedef ABI::Windows::Data::Xml::Dom::IXmlNode IXmlNode; 1.23 + typedef ABI::Windows::Data::Xml::Dom::IXmlDocument IXmlDocument; 1.24 + 1.25 + void SetNodeValueString(HSTRING inputString,Microsoft::WRL::ComPtr<IXmlNode> node, 1.26 + Microsoft::WRL::ComPtr<IXmlDocument> xml); 1.27 + public: 1.28 + ToastNotificationHandler() {}; 1.29 + ~ToastNotificationHandler() {}; 1.30 + 1.31 + bool DisplayNotification(HSTRING title, HSTRING msg, HSTRING imagePath, 1.32 + const nsAString& aCookie, const nsAString& aAppId); 1.33 + bool DisplayTextNotification(HSTRING title, HSTRING msg, 1.34 + const nsAString& aCookie, 1.35 + const nsAString& aAppId); 1.36 + HRESULT OnActivate(IToastNotification *notification, IInspectable *inspectable); 1.37 + HRESULT OnDismiss(IToastNotification *notification, 1.38 + IToastDismissedEventArgs* aArgs); 1.39 + 1.40 + private: 1.41 + nsString mCookie; 1.42 + Microsoft::WRL::ComPtr<IToastNotificationManagerStatics> mToastNotificationManagerStatics; 1.43 + 1.44 + bool CreateWindowsNotificationFromXml(IXmlDocument *toastXml, 1.45 + const nsAString& aAppId); 1.46 + Microsoft::WRL::ComPtr<IXmlDocument> InitializeXmlForTemplate(ToastTemplateType templateType); 1.47 +};