Commit b5e4d990 authored by Megumi Hattori's avatar Megumi Hattori Committed by Commit Bot

Add inline settings and enable block of Chrome extension notification.

Previously, only web notifications have the inline settings and can be
blocked depending the settings. This CL also applies this feature to
Chrome extension notifications.

This CL adds the inline settings on the Chrome extension notification
and enables users to choose whether to block the notification or not.

Due to this implementation, a gear icon for the inline settings is
also added on the notification.

BUG=810622

Change-Id: I6197167d2c587cd40a1e92b81a5bba5d3057820f
Reviewed-on: https://chromium-review.googlesource.com/923877
Commit-Queue: Megumi Hattori <megumihattori@google.com>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539067}
parent a4114c83
......@@ -12,6 +12,8 @@
#include "chrome/browser/extensions/api/notifications/extension_notification_display_helper.h"
#include "chrome/browser/extensions/api/notifications/extension_notification_display_helper_factory.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notifier_state_tracker.h"
#include "chrome/browser/notifications/notifier_state_tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/notifications.h"
#include "extensions/browser/app_window/app_window.h"
......@@ -107,6 +109,14 @@ void ExtensionNotificationHandler::OnClick(
std::move(completed_closure).Run();
}
void ExtensionNotificationHandler::DisableNotifications(Profile* profile,
const GURL& origin) {
message_center::NotifierId notifier_id(
message_center::NotifierId::APPLICATION, origin.host());
NotifierStateTrackerFactory::GetForProfile(profile)->SetNotifierEnabled(
notifier_id, false /* enabled */);
}
void ExtensionNotificationHandler::SendEvent(
Profile* profile,
const std::string& extension_id,
......
......@@ -36,6 +36,7 @@ class ExtensionNotificationHandler : public NotificationHandler {
const base::Optional<int>& action_index,
const base::Optional<base::string16>& reply,
base::OnceClosure completed_closure) override;
void DisableNotifications(Profile* profile, const GURL& origin) override;
protected:
// Overriden in unit tests.
......
......@@ -48,6 +48,7 @@
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/skia_util.h"
#include "ui/message_center/public/cpp/features.h"
#include "ui/message_center/public/cpp/message_center_constants.h"
#include "ui/message_center/public/cpp/notification.h"
#include "ui/message_center/public/cpp/notification_delegate.h"
......@@ -360,6 +361,11 @@ bool NotificationsApiFunction::CreateNotification(
if (options->is_clickable.get())
optional_fields.clickable = *options->is_clickable;
optional_fields.settings_button_handler =
base::FeatureList::IsEnabled(message_center::kNewStyleNotifications)
? message_center::SettingsButtonHandler::INLINE
: message_center::SettingsButtonHandler::DELEGATE;
// TODO(crbug.com/772004): Remove the manual limitation in favor of an IDL
// annotation once supported.
if (id.size() > kNotificationIdLengthLimit) {
......
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