1 // Copyright 2018 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 ASH_PUBLIC_CPP_NOTIFICATION_UTILS_H_
6 #define ASH_PUBLIC_CPP_NOTIFICATION_UTILS_H_
7 
8 #include <string>
9 
10 #include "ash/public/cpp/ash_public_export.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_refptr.h"
13 #include "base/strings/string16.h"
14 #include "ui/gfx/color_palette.h"
15 #include "ui/message_center/public/cpp/notification.h"
16 #include "ui/message_center/public/cpp/notification_types.h"
17 #include "ui/message_center/public/cpp/notifier_id.h"
18 
19 class GURL;
20 
21 namespace gfx {
22 struct VectorIcon;
23 }
24 
25 namespace ui {
26 namespace message_center {
27 class NotificationDelegate;
28 }
29 }  // namespace ui
30 
31 namespace ash {
32 
33 // Accent colors of system notifications.
34 constexpr SkColor kSystemNotificationColorNormal = gfx::kGoogleBlue700;
35 constexpr SkColor kSystemNotificationColorWarning = gfx::kGoogleYellow900;
36 constexpr SkColor kSystemNotificationColorCriticalWarning = gfx::kGoogleRed700;
37 
38 // Helper method to create a simple system notification. |click_callback|
39 // will be invoked when the notification is clicked.
40 //
41 // It should only be used for critical notification, as SetSystemPriority and
42 // CRITICAL_WARNING color are set inside, which means the notification would
43 // not go away without user interaction.
44 //
45 // TODO(tetsui): Add a function parameter |small_image| of gfx::VectorIcon, so
46 // display source of critical system notification is illustrated by icon.
47 ASH_PUBLIC_EXPORT std::unique_ptr<message_center::Notification>
48 CreateSystemNotification(const std::string& notification_id,
49                          const base::string16& title,
50                          const base::string16& message,
51                          const std::string& system_component_id,
52                          const base::RepeatingClosure& click_callback);
53 
54 // Factory method to create all kinds of notifications generated by system,
55 // from normal priority ones to critical priority ones.
56 // |small_image| is a small icon show on the upper left header to illustrate
57 // |display_source| of the notification.
58 // One specified in the |optional_fields| is overridden.
59 ASH_PUBLIC_EXPORT std::unique_ptr<message_center::Notification>
60 CreateSystemNotification(
61     message_center::NotificationType type,
62     const std::string& id,
63     const base::string16& title,
64     const base::string16& message,
65     const base::string16& display_source,
66     const GURL& origin_url,
67     const message_center::NotifierId& notifier_id,
68     const message_center::RichNotificationData& optional_fields,
69     scoped_refptr<message_center::NotificationDelegate> delegate,
70     const gfx::VectorIcon& small_image,
71     message_center::SystemNotificationWarningLevel warning_level);
72 
73 }  // namespace ash
74 
75 #endif  // ASH_PUBLIC_CPP_NOTIFICATION_UTILS_H_
76