16e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
26e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
36e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// found in the LICENSE file.
46e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
56e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CONVERSION_HELPER_H_
66e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CONVERSION_HELPER_H_
76e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
86e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "chrome/browser/notifications/notification.h"
96e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "ui/message_center/notification_types.h"
106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace extensions {
126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace api {
136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace notifications {
146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct NotificationOptions;
156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)struct NotificationBitmap;
166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}  // namespace notifications
176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}  // namespace api
186e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}  // namespace extensions
196e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
206e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)namespace gfx {
216e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class Image;
226e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}
236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// This class provides some static helper functions that could be used to
256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// convert between different types of notification data.
266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class NotificationConversionHelper {
276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) public:
286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Converts Notification::Notification data to
296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // extensions::api::notifications::NotificationOptions.
306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  static void NotificationToNotificationOptions(
316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      const Notification& notification,
326e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      extensions::api::notifications::NotificationOptions* options);
336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
346e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Converts gfx::Image (in ARGB format) type to
356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // extensions::api::notifications::NotificationBitmap type (RGBA).
366e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  static void GfxImageToNotificationBitmap(
376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      const gfx::Image* gfx_image,
386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      extensions::api::notifications::NotificationBitmap* return_image_args);
396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Converts an extensions::api::notifications::NotificationBitmap type object
416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // with width, height, and data in RGBA format into an gfx::Image (ARGB).
426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  static bool NotificationBitmapToGfxImage(
436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      float max_scale,
446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      const gfx::Size& target_size_dips,
456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      extensions::api::notifications::NotificationBitmap* notification_bitmap,
466e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      gfx::Image* return_image);
476e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) private:
496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Conversts message_center::NotificationType to string type used to convert
506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // to extensions::api::notifications::TemplateType
516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  static std::string MapTypeToString(message_center::NotificationType type);
526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)};
536e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif  // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_CONVERSION_HELPER_H_
55