Commit d063a6f8 authored by James Cook's avatar James Cook Committed by Commit Bot

Extract NotificationDisplayServiceDelegate into its own file

I anticipate needing it for notifications for lacros. See
go/lacros and go/lacros-notifications.

Also, clean up BUILD.gn slightly -- enable_native_notifications is
always true on Chrome OS.

Bug: 1113889
Change-Id: I6c3bc7f81f81157568f8c1b2969f98a82a037b6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339450
Commit-Queue: Jun Mukai <mukai@chromium.org>
Auto-Submit: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795968}
parent 6caccedd
...@@ -3817,6 +3817,7 @@ static_library("browser") { ...@@ -3817,6 +3817,7 @@ static_library("browser") {
} }
if (is_chromeos) { if (is_chromeos) {
assert(enable_native_notifications)
sources += [ sources += [
"apps/app_service/arc_activity_adaptive_icon_impl.cc", "apps/app_service/arc_activity_adaptive_icon_impl.cc",
"apps/app_service/arc_activity_adaptive_icon_impl.h", "apps/app_service/arc_activity_adaptive_icon_impl.h",
...@@ -3929,6 +3930,9 @@ static_library("browser") { ...@@ -3929,6 +3930,9 @@ static_library("browser") {
"notifications/chrome_ash_message_center_client.h", "notifications/chrome_ash_message_center_client.h",
"notifications/extension_notifier_controller.cc", "notifications/extension_notifier_controller.cc",
"notifications/extension_notifier_controller.h", "notifications/extension_notifier_controller.h",
"notifications/notification_platform_bridge_chromeos.cc",
"notifications/notification_platform_bridge_chromeos.h",
"notifications/notification_platform_bridge_delegate.h",
"notifications/notifier_controller.h", "notifications/notifier_controller.h",
"notifications/web_page_notifier_controller.cc", "notifications/web_page_notifier_controller.cc",
"notifications/web_page_notifier_controller.h", "notifications/web_page_notifier_controller.h",
...@@ -4005,13 +4009,6 @@ static_library("browser") { ...@@ -4005,13 +4009,6 @@ static_library("browser") {
"//ui/ozone", "//ui/ozone",
] ]
allow_circular_includes_from += [ "//chrome/browser/chromeos" ] allow_circular_includes_from += [ "//chrome/browser/chromeos" ]
if (enable_native_notifications) {
sources += [
"notifications/notification_platform_bridge_chromeos.cc",
"notifications/notification_platform_bridge_chromeos.h",
]
}
} else { # Non - ChromeOS. } else { # Non - ChromeOS.
sources += [ sources += [
"fullscreen.h", "fullscreen.h",
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "chrome/browser/notifications/notification_platform_bridge.h" #include "chrome/browser/notifications/notification_platform_bridge.h"
#include "chrome/browser/notifications/notification_platform_bridge_chromeos.h" #include "chrome/browser/notifications/notification_platform_bridge_delegate.h"
#include "chrome/browser/notifications/notifier_controller.h" #include "chrome/browser/notifications/notifier_controller.h"
// This class serves as Chrome's AshMessageCenterClient, as well as the // This class serves as Chrome's AshMessageCenterClient, as well as the
......
...@@ -11,39 +11,11 @@ ...@@ -11,39 +11,11 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/notifications/notification_platform_bridge.h" #include "chrome/browser/notifications/notification_platform_bridge.h"
#include "chrome/browser/notifications/notification_platform_bridge_delegate.h"
#include "chrome/browser/notifications/profile_notification.h" #include "chrome/browser/notifications/profile_notification.h"
class ChromeAshMessageCenterClient; class ChromeAshMessageCenterClient;
// The interface that a NotificationPlatformBridge uses to pass back information
// and interactions from the native notification system. TODO(estade): this
// should be hoisted into its own file, implemented by
// NativeNotificationDisplayService, and used by other platforms'
// NotificationPlatformBridge implementations. See http://crbug.com/776443
class NotificationPlatformBridgeDelegate {
public:
// To be called when a notification is closed. Each notification can be closed
// at most once.
virtual void HandleNotificationClosed(const std::string& id,
bool by_user) = 0;
// To be called when the body of a notification is clicked.
virtual void HandleNotificationClicked(const std::string& id) = 0;
// To be called when a button in a notification is clicked.
virtual void HandleNotificationButtonClicked(
const std::string& id,
int button_index,
const base::Optional<base::string16>& reply) = 0;
// To be called when the settings button in a notification is clicked.
virtual void HandleNotificationSettingsButtonClicked(
const std::string& id) = 0;
// To be called when a notification (source) should be disabled.
virtual void DisableNotification(const std::string& id) = 0;
};
// A platform bridge that uses Ash's message center to display notifications. // A platform bridge that uses Ash's message center to display notifications.
class NotificationPlatformBridgeChromeOs class NotificationPlatformBridgeChromeOs
: public NotificationPlatformBridge, : public NotificationPlatformBridge,
......
// Copyright 2020 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_DELEGATE_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_DELEGATE_H_
#include <string>
#include "base/optional.h"
#include "base/strings/string16.h"
// The interface that a NotificationPlatformBridge uses to pass back information
// and interactions from the native notification system.
// TODO(estade): This should be implemented by NativeNotificationDisplayService,
// and used by other platforms' NotificationPlatformBridge implementations. See
// http://crbug.com/776443
class NotificationPlatformBridgeDelegate {
public:
// To be called when a notification is closed. Each notification can be closed
// at most once.
virtual void HandleNotificationClosed(const std::string& id,
bool by_user) = 0;
// To be called when the body of a notification is clicked.
virtual void HandleNotificationClicked(const std::string& id) = 0;
// To be called when a button in a notification is clicked.
virtual void HandleNotificationButtonClicked(
const std::string& id,
int button_index,
const base::Optional<base::string16>& reply) = 0;
// To be called when the settings button in a notification is clicked.
virtual void HandleNotificationSettingsButtonClicked(
const std::string& id) = 0;
// To be called when a notification (source) should be disabled.
virtual void DisableNotification(const std::string& id) = 0;
protected:
virtual ~NotificationPlatformBridgeDelegate() = default;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment