15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_METRO_DRIVER_TOAST_NOTIFICATION_HANDLER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_METRO_DRIVER_TOAST_NOTIFICATION_HANDLER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <windows.ui.notifications.h>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/win/metro.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Provides functionality to display a metro style toast notification.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ToastNotificationHandler {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Holds information about a desktop notification to be displayed.
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  struct DesktopNotification {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string origin_url;
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string icon_url;
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 title;
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 body;
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 display_source;
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    std::string id;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    base::win::MetroNotificationClickedHandler notification_handler;
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::string16 notification_context;
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DesktopNotification(const char* notification_origin,
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const char* notification_icon,
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const wchar_t* notification_title,
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const wchar_t* notification_body,
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const wchar_t* notification_display_source,
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const char* notification_id,
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        base::win::MetroNotificationClickedHandler handler,
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                        const wchar_t* handler_context);
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DesktopNotification();
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ToastNotificationHandler();
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ~ToastNotificationHandler();
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DisplayNotification(const DesktopNotification& notification);
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CancelNotification();
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HRESULT OnActivate(winui::Notifications::IToastNotification* notification,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                     IInspectable* inspectable);
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  mswr::ComPtr<winui::Notifications::IToastNotifier> notifier_;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  mswr::ComPtr<winui::Notifications::IToastNotification> notification_;
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  EventRegistrationToken activated_token_;
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DesktopNotification notification_info_;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_METRO_DRIVER_TOAST_NOTIFICATION_HANDLER_H_
56