blob: 7b8a892abbffba92841496f0d81d5afbe8d725e8 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_
#include <set>
#include <string>
#include "base/compiler_specific.h"
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_platform_bridge.h"
class Notification;
@class NotificationCenterDelegate;
@class NotificationRemoteDispatcher;
@class NSDictionary;
@class NSUserNotificationCenter;
@class NSXPCConnection;
class PrefService;
// This class is an implementation of NotificationPlatformBridge that will
// send platform notifications to the the MacOSX notification center.
class NotificationPlatformBridgeMac : public NotificationPlatformBridge {
public:
explicit NotificationPlatformBridgeMac(
NSUserNotificationCenter* notification_center);
~NotificationPlatformBridgeMac() override;
// NotificationPlatformBridge implementation.
void Display(NotificationCommon::Type notification_type,
const std::string& notification_id,
const std::string& profile_id,
bool incognito,
const Notification& notification) override;
void Close(const std::string& profile_id,
const std::string& notification_id) override;
bool GetDisplayed(const std::string& profile_id,
bool incognito,
std::set<std::string>* notifications) const override;
// Processes a notification response generated from a user action
// (click close, etc.).
static void ProcessNotificationResponse(NSDictionary* response);
// Validates contents of the |response| dictionary as received from the system
// when a notification gets activated.
static bool VerifyNotificationData(NSDictionary* response) WARN_UNUSED_RESULT;
private:
// Cocoa class that receives callbacks from the NSUserNotificationCenter.
base::scoped_nsobject<NotificationCenterDelegate> delegate_;
// The notification center to use for local banner notifications,
// this can be overriden in tests.
NSUserNotificationCenter* notification_center_;
// The object in charge of dispatching remote notifications.
base::scoped_nsobject<NotificationRemoteDispatcher>
notification_remote_dispatcher_;
DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeMac);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_H_