#include "ui/message_center/public/cpp/notification.h"
#include <map>
#include <memory>
#include "build/chromeos_buildflags.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/public/cpp/notification_delegate.h"
#include "ui/message_center/public/cpp/notification_types.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/metrics/histogram_functions.h"
#endif
namespace message_center {
namespace {
unsigned g_next_serial_number = …;
#if BUILDFLAG(IS_CHROMEOS_ASH)
constexpr char kNotificationImageMemorySizeHistogram[] =
"Ash.Notification.ImageMemorySizeInKB";
constexpr char kNotificationSmallImageMemorySizeHistogram[] =
"Ash.Notification.SmallImageMemorySizeInKB";
int CalculateImageByteSize(const gfx::Image& image) {
constexpr int kBytesPerPixel = 4;
return image.IsEmpty() ? 0 : image.Width() * image.Height() * kBytesPerPixel;
}
#endif
const gfx::ImageSkia CreateSolidColorImage(int width,
int height,
SkColor color) { … }
gfx::Image DeepCopyImage(const gfx::Image& image) { … }
}
NotificationItem::NotificationItem(const std::u16string& title,
const std::u16string& message,
ui::ImageModel icon)
: … { … }
NotificationItem::NotificationItem(const NotificationItem& other) = default;
NotificationItem::NotificationItem() = default;
NotificationItem::~NotificationItem() = default;
NotificationItem& NotificationItem::operator=(const NotificationItem& other) =
default;
ButtonInfo::ButtonInfo(const std::u16string& title) : … { … }
ButtonInfo::ButtonInfo(const gfx::VectorIcon* vector_icon,
const std::u16string& accessible_name)
: … { … }
ButtonInfo::ButtonInfo(const ButtonInfo& other) = default;
ButtonInfo::ButtonInfo() = default;
ButtonInfo::~ButtonInfo() = default;
ButtonInfo& ButtonInfo::operator=(const ButtonInfo& other) = default;
RichNotificationData::RichNotificationData() : … { … }
RichNotificationData::RichNotificationData(const RichNotificationData& other) =
default;
RichNotificationData::~RichNotificationData() = default;
Notification::Notification(NotificationType type,
const std::string& id,
const std::u16string& title,
const std::u16string& message,
const ui::ImageModel& icon,
const std::u16string& display_source,
const GURL& origin_url,
const NotifierId& notifier_id,
const RichNotificationData& optional_fields,
scoped_refptr<NotificationDelegate> delegate)
: … { … }
Notification::Notification(scoped_refptr<NotificationDelegate> delegate,
const Notification& other)
: … { … }
Notification::Notification(const std::string& id, const Notification& other)
: … { … }
Notification::Notification(const Notification& other) = default;
Notification& Notification::operator=(const Notification& other) = default;
Notification::~Notification() = default;
std::unique_ptr<Notification> Notification::DeepCopy(
const Notification& notification,
const ui::ColorProvider* color_provider,
bool include_body_image,
bool include_small_image,
bool include_icon_images) { … }
void Notification::SetButtonIcon(size_t index, const gfx::Image& icon) { … }
void Notification::SetSystemPriority() { … }
void Notification::SetGroupChild() { … }
void Notification::SetGroupParent() { … }
void Notification::ClearGroupChild() { … }
void Notification::ClearGroupParent() { … }
bool Notification::UseOriginAsContextMessage() const { … }
void Notification::SetImage(const gfx::Image& image) { … }
void Notification::SetSmallImage(const gfx::Image& image) { … }
gfx::Image Notification::GenerateMaskedSmallIcon(
int dip_size,
SkColor mask_color,
SkColor background_color,
SkColor foreground_color) const { … }
gfx::Image Notification::GetMaskedSmallImage(const gfx::ImageSkia& small_image,
SkColor background_color,
SkColor foreground_color) const { … }
}