@@ -94,7 +94,8 @@ void WindowsToastNotification::Show(const NotificationOptions& options) {
9494
9595 ComPtr<IXmlDocument> toast_xml;
9696 if (FAILED (GetToastXml (toast_manager_.Get (), options.title , options.msg ,
97- icon_path, options.silent , &toast_xml))) {
97+ icon_path, options.timeout_type , options.silent ,
98+ &toast_xml))) {
9899 NotificationFailed ();
99100 return ;
100101 }
@@ -149,6 +150,7 @@ bool WindowsToastNotification::GetToastXml(
149150 const std::wstring& title,
150151 const std::wstring& msg,
151152 const std::wstring& icon_path,
153+ const std::wstring& timeout_type,
152154 bool silent,
153155 IXmlDocument** toast_xml) {
154156 ABI ::Windows::UI ::Notifications::ToastTemplateType template_type;
@@ -183,6 +185,15 @@ bool WindowsToastNotification::GetToastXml(
183185 }
184186 }
185187
188+ // Configure the toast's timeout settings
189+ if (timeout_type == base::ASCIIToUTF16 (" never" )) {
190+ if (FAILED (SetXmlScenarioReminder (*toast_xml))) {
191+ if (IsDebuggingNotifications ())
192+ LOG (INFO ) << " Setting \" scenario\" option on notification failed" ;
193+ return false ;
194+ }
195+ }
196+
186197 // Configure the toast's notification sound
187198 if (silent) {
188199 if (FAILED (SetXmlAudioSilent (*toast_xml))) {
@@ -201,6 +212,56 @@ bool WindowsToastNotification::GetToastXml(
201212 return true ;
202213}
203214
215+ bool WindowsToastNotification::SetXmlScenarioReminder (IXmlDocument* doc) {
216+ ScopedHString tag (L" toast" );
217+ if (!tag.success ())
218+ return false ;
219+
220+ ComPtr<IXmlNodeList> node_list;
221+ if (FAILED (doc->GetElementsByTagName (tag, &node_list)))
222+ return false ;
223+
224+ // Check that root "toast" node exists
225+ ComPtr<IXmlNode> root;
226+ if (FAILED (node_list->Item (0 , &root)))
227+ return false ;
228+
229+ // get attributes of root "toast" node
230+ ComPtr<IXmlNamedNodeMap> attributes;
231+ if (FAILED (root->get_Attributes (&attributes)))
232+ return false ;
233+
234+ ComPtr<IXmlAttribute> scenario_attribute;
235+ ScopedHString scenario_str (L" scenario" );
236+ if (FAILED (doc->CreateAttribute (scenario_str, &scenario_attribute)))
237+ return false ;
238+
239+ ComPtr<IXmlNode> scenario_attribute_node;
240+ if (FAILED (scenario_attribute.As (&scenario_attribute_node)))
241+ return false ;
242+
243+ ScopedHString scenario_value (L" reminder" );
244+ if (!scenario_value.success ())
245+ return false ;
246+
247+ ComPtr<IXmlText> scenario_text;
248+ if (FAILED (doc->CreateTextNode (scenario_value, &scenario_text)))
249+ return false ;
250+
251+ ComPtr<IXmlNode> scenario_node;
252+ if (FAILED (scenario_text.As (&scenario_node)))
253+ return false ;
254+
255+ ComPtr<IXmlNode> child_node;
256+ if (FAILED (scenario_attribute_node->AppendChild (scenario_node.Get (),
257+ &child_node)))
258+ return false ;
259+
260+ ComPtr<IXmlNode> scenario_attribute_pnode;
261+ return SUCCEEDED (attributes.Get ()->SetNamedItem (scenario_attribute_node.Get (),
262+ &scenario_attribute_pnode));
263+ }
264+
204265bool WindowsToastNotification::SetXmlAudioSilent (IXmlDocument* doc) {
205266 ScopedHString tag (L" toast" );
206267 if (!tag.success ())
0 commit comments