|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #pragma once |
|
7 |
|
8 #include <windows.ui.notifications.h> |
|
9 #include <windows.data.xml.dom.h> |
|
10 #include "mozwrlbase.h" |
|
11 #include "nsString.h" |
|
12 |
|
13 |
|
14 class ToastNotificationHandler { |
|
15 typedef ABI::Windows::UI::Notifications::IToastNotification IToastNotification; |
|
16 typedef ABI::Windows::UI::Notifications::IToastDismissedEventArgs IToastDismissedEventArgs; |
|
17 typedef ABI::Windows::UI::Notifications::IToastNotificationManagerStatics IToastNotificationManagerStatics; |
|
18 typedef ABI::Windows::UI::Notifications::ToastTemplateType ToastTemplateType; |
|
19 typedef ABI::Windows::Data::Xml::Dom::IXmlNode IXmlNode; |
|
20 typedef ABI::Windows::Data::Xml::Dom::IXmlDocument IXmlDocument; |
|
21 |
|
22 void SetNodeValueString(HSTRING inputString,Microsoft::WRL::ComPtr<IXmlNode> node, |
|
23 Microsoft::WRL::ComPtr<IXmlDocument> xml); |
|
24 public: |
|
25 ToastNotificationHandler() {}; |
|
26 ~ToastNotificationHandler() {}; |
|
27 |
|
28 bool DisplayNotification(HSTRING title, HSTRING msg, HSTRING imagePath, |
|
29 const nsAString& aCookie, const nsAString& aAppId); |
|
30 bool DisplayTextNotification(HSTRING title, HSTRING msg, |
|
31 const nsAString& aCookie, |
|
32 const nsAString& aAppId); |
|
33 HRESULT OnActivate(IToastNotification *notification, IInspectable *inspectable); |
|
34 HRESULT OnDismiss(IToastNotification *notification, |
|
35 IToastDismissedEventArgs* aArgs); |
|
36 |
|
37 private: |
|
38 nsString mCookie; |
|
39 Microsoft::WRL::ComPtr<IToastNotificationManagerStatics> mToastNotificationManagerStatics; |
|
40 |
|
41 bool CreateWindowsNotificationFromXml(IXmlDocument *toastXml, |
|
42 const nsAString& aAppId); |
|
43 Microsoft::WRL::ComPtr<IXmlDocument> InitializeXmlForTemplate(ToastTemplateType templateType); |
|
44 }; |