Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: chrome/browser/notifications/notification_template_builder.h

Issue 2920303002: Add a NotificationTemplateBuilder for Action Center toasts (Closed)
Patch Set: remove libxml usage from the test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/notifications/notification_template_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEMPLATE_BUILDER_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEMPLATE_BUILDER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12
13 class GURL;
14 class XmlWriter;
15
16 namespace message_center {
17 class Notification;
18 }
19
20 // Builds XML-based notification templates for displaying a given notification
21 // in the Windows Action Center.
22 //
23 // https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/schema-root
24 // https://msdn.microsoft.com/library/1a437614-4259-426b-8e3f-ca57368b2e7a
25 //
26 // The current builder is a best-effort implementation that supports the title
27 // body text and attribution of a notification.
28 class NotificationTemplateBuilder {
29 public:
30 // Builds the notification template for the given |notification|. The given
31 // |notification_id| will be available when the user interacts with the toast.
32 static std::unique_ptr<NotificationTemplateBuilder> Build(
33 const std::string& notification_id,
34 const message_center::Notification& notification);
35
36 ~NotificationTemplateBuilder();
37
38 // Gets the XML template that was created by this builder.
39 std::string GetNotificationTemplate();
40
41 private:
42 NotificationTemplateBuilder();
43
44 // Formats the |origin| for display in the notification template.
45 std::string FormatOrigin(const GURL& origin) const;
46
47 // Writes the <toast> element with the |notification_id| as the launch string.
48 // Also closes the |xml_writer_| for writing as the toast is now complete.
49 // https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-toas t
50 void StartToastElement(const std::string& notification_id);
51 void EndToastElement();
52
53 // Writes the <visual> element.
54 // https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-visu al
55 void StartVisualElement();
56 void EndVisualElement();
57
58 // Writes the <binding> element with the given |template_name|.
59 // https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-bind ing
60 void StartBindingElement(const std::string& template_name);
61 void EndBindingElement();
62
63 // Writes the <text> element with the given |id| and |content|.
64 // https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-text
65 void WriteTextElement(const std::string& id, const std::string& content);
66
67 // The XML writer to which the template will be written.
68 std::unique_ptr<XmlWriter> xml_writer_;
69
70 DISALLOW_COPY_AND_ASSIGN(NotificationTemplateBuilder);
71 };
72
73 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEMPLATE_BUILDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/notifications/notification_template_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698