Commit e4fab30e authored by Sharon Yang's avatar Sharon Yang Committed by Commit Bot

Prefix Operation enum operations with OPERATION_

Replace an enum with an enum class, as preferred.

Change-Id: I657373e7a4f0d245a930341db7feff27a2f8fda5
Reviewed-on: https://chromium-review.googlesource.com/1118552Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Sharon Yang <yangsharon@google.com>
Cr-Commit-Position: refs/heads/master@{#572573}
parent c035b5fc
......@@ -17,13 +17,12 @@ class NotificationCommon {
public:
// Things as user can do to a notification. Keep in sync with the
// NotificationOperation enumeration in notification_response_builder_mac.h.
// TODO(peter): Prefix these options with OPERATION_.
enum Operation {
CLICK = 0,
CLOSE = 1,
DISABLE_PERMISSION = 2,
SETTINGS = 3,
OPERATION_MAX = SETTINGS
OPERATION_CLICK = 0,
OPERATION_CLOSE = 1,
OPERATION_DISABLE_PERMISSION = 2,
OPERATION_SETTINGS = 3,
OPERATION_MAX = OPERATION_SETTINGS
};
// A struct that contains extra data about a notification specific to one of
......
......@@ -158,19 +158,19 @@ void NotificationDisplayServiceImpl::ProcessNotificationOperation(
base::OnceClosure completed_closure = base::BindOnce(&OperationCompleted);
switch (operation) {
case NotificationCommon::CLICK:
case NotificationCommon::OPERATION_CLICK:
handler->OnClick(profile_, origin, notification_id, action_index, reply,
std::move(completed_closure));
break;
case NotificationCommon::CLOSE:
case NotificationCommon::OPERATION_CLOSE:
DCHECK(by_user.has_value());
handler->OnClose(profile_, origin, notification_id, by_user.value(),
std::move(completed_closure));
break;
case NotificationCommon::DISABLE_PERMISSION:
case NotificationCommon::OPERATION_DISABLE_PERMISSION:
handler->DisableNotifications(profile_, origin);
break;
case NotificationCommon::SETTINGS:
case NotificationCommon::OPERATION_SETTINGS:
handler->OpenSettings(profile_, origin);
break;
}
......
......@@ -167,7 +167,7 @@ void NotificationPlatformBridgeAndroid::OnNotificationClicked(
profile_manager->LoadProfile(
profile_id, incognito,
base::Bind(&NotificationDisplayServiceImpl::ProfileLoadedCallback,
NotificationCommon::CLICK,
NotificationCommon::OPERATION_CLICK,
NotificationHandler::Type::WEB_PERSISTENT, origin,
notification_id, std::move(action_index), std::move(reply),
base::nullopt /* by_user */));
......@@ -213,7 +213,7 @@ void NotificationPlatformBridgeAndroid::OnNotificationClosed(
profile_manager->LoadProfile(
profile_id, incognito,
base::Bind(&NotificationDisplayServiceImpl::ProfileLoadedCallback,
NotificationCommon::CLOSE,
NotificationCommon::OPERATION_CLOSE,
NotificationHandler::Type::WEB_PERSISTENT,
GURL(ConvertJavaStringToUTF8(env, java_origin)),
notification_id, base::nullopt /* action index */,
......
......@@ -126,7 +126,7 @@ void NotificationPlatformBridgeChromeOs::HandleNotificationClosed(
} else {
NotificationDisplayServiceImpl::GetForProfile(notification->profile())
->ProcessNotificationOperation(
NotificationCommon::CLOSE, notification->type(),
NotificationCommon::OPERATION_CLOSE, notification->type(),
notification->notification().origin_url(),
notification->original_id(), base::nullopt, base::nullopt, by_user);
}
......@@ -145,7 +145,7 @@ void NotificationPlatformBridgeChromeOs::HandleNotificationClicked(
} else {
NotificationDisplayServiceImpl::GetForProfile(notification->profile())
->ProcessNotificationOperation(
NotificationCommon::CLICK, notification->type(),
NotificationCommon::OPERATION_CLICK, notification->type(),
notification->notification().origin_url(),
notification->original_id(), base::nullopt, base::nullopt,
base::nullopt);
......@@ -165,7 +165,7 @@ void NotificationPlatformBridgeChromeOs::HandleNotificationButtonClicked(
} else {
NotificationDisplayServiceImpl::GetForProfile(notification->profile())
->ProcessNotificationOperation(
NotificationCommon::CLICK, notification->type(),
NotificationCommon::OPERATION_CLICK, notification->type(),
notification->notification().origin_url(),
notification->original_id(), button_index, reply, base::nullopt);
}
......@@ -182,7 +182,7 @@ void NotificationPlatformBridgeChromeOs::
} else {
NotificationDisplayServiceImpl::GetForProfile(notification->profile())
->ProcessNotificationOperation(
NotificationCommon::SETTINGS, notification->type(),
NotificationCommon::OPERATION_SETTINGS, notification->type(),
notification->notification().origin_url(),
notification->original_id(), base::nullopt, base::nullopt,
base::nullopt);
......@@ -197,11 +197,11 @@ void NotificationPlatformBridgeChromeOs::DisableNotification(
DCHECK_NE(NotificationHandler::Type::TRANSIENT, notification->type());
NotificationDisplayServiceImpl::GetForProfile(notification->profile())
->ProcessNotificationOperation(NotificationCommon::DISABLE_PERMISSION,
notification->type(),
notification->notification().origin_url(),
notification->original_id(), base::nullopt,
base::nullopt, base::nullopt);
->ProcessNotificationOperation(
NotificationCommon::OPERATION_DISABLE_PERMISSION,
notification->type(), notification->notification().origin_url(),
notification->original_id(), base::nullopt, base::nullopt,
base::nullopt);
}
ProfileNotification* NotificationPlatformBridgeChromeOs::GetProfileNotification(
......
......@@ -787,12 +787,12 @@ class NotificationPlatformBridgeLinuxImpl
return;
if (action == kDefaultButtonId) {
ForwardNotificationOperation(FROM_HERE, data, NotificationCommon::CLICK,
base::nullopt /* action_index */,
base::nullopt /* by_user */);
ForwardNotificationOperation(
FROM_HERE, data, NotificationCommon::OPERATION_CLICK,
base::nullopt /* action_index */, base::nullopt /* by_user */);
} else if (action == kSettingsButtonId) {
ForwardNotificationOperation(
FROM_HERE, data, NotificationCommon::SETTINGS,
FROM_HERE, data, NotificationCommon::OPERATION_SETTINGS,
base::nullopt /* action_index */, base::nullopt /* by_user */);
} else if (action == kCloseButtonId) {
CloseOnTaskRunner(data->profile_id, data->notification_id);
......@@ -804,7 +804,8 @@ class NotificationPlatformBridgeLinuxImpl
size_t id_zero_based = id - data->action_start;
if (id_zero_based >= n_buttons)
return;
ForwardNotificationOperation(FROM_HERE, data, NotificationCommon::CLICK,
ForwardNotificationOperation(FROM_HERE, data,
NotificationCommon::OPERATION_CLICK,
id_zero_based, base::nullopt /* by_user */);
}
}
......@@ -821,9 +822,9 @@ class NotificationPlatformBridgeLinuxImpl
return;
// TODO(peter): Can we support |by_user| appropriately here?
ForwardNotificationOperation(FROM_HERE, data, NotificationCommon::CLOSE,
base::nullopt /* action_index */,
true /* by_user */);
ForwardNotificationOperation(
FROM_HERE, data, NotificationCommon::OPERATION_CLOSE,
base::nullopt /* action_index */, true /* by_user */);
notifications_.erase(data);
}
......
......@@ -34,7 +34,7 @@ class PassThroughDelegate : public message_center::NotificationDelegate {
void SettingsClick() override {
NotificationDisplayServiceImpl::GetForProfile(profile_)
->ProcessNotificationOperation(
NotificationCommon::SETTINGS, notification_type_,
NotificationCommon::OPERATION_SETTINGS, notification_type_,
notification_.origin_url(), notification_.id(), base::nullopt,
base::nullopt, base::nullopt /* by_user */);
}
......@@ -42,8 +42,8 @@ class PassThroughDelegate : public message_center::NotificationDelegate {
void DisableNotification() override {
NotificationDisplayServiceImpl::GetForProfile(profile_)
->ProcessNotificationOperation(
NotificationCommon::DISABLE_PERMISSION, notification_type_,
notification_.origin_url(), notification_.id(),
NotificationCommon::OPERATION_DISABLE_PERMISSION,
notification_type_, notification_.origin_url(), notification_.id(),
base::nullopt /* action_index */, base::nullopt /* reply */,
base::nullopt /* by_user */);
}
......@@ -51,7 +51,7 @@ class PassThroughDelegate : public message_center::NotificationDelegate {
void Close(bool by_user) override {
NotificationDisplayServiceImpl::GetForProfile(profile_)
->ProcessNotificationOperation(
NotificationCommon::CLOSE, notification_type_,
NotificationCommon::OPERATION_CLOSE, notification_type_,
notification_.origin_url(), notification_.id(),
base::nullopt /* action_index */, base::nullopt /* reply */,
by_user);
......@@ -61,7 +61,7 @@ class PassThroughDelegate : public message_center::NotificationDelegate {
const base::Optional<base::string16>& reply) override {
NotificationDisplayServiceImpl::GetForProfile(profile_)
->ProcessNotificationOperation(
NotificationCommon::CLICK, notification_type_,
NotificationCommon::OPERATION_CLICK, notification_type_,
notification_.origin_url(), notification_.id(), button_index, reply,
base::nullopt /* by_user */);
}
......
......@@ -691,7 +691,7 @@ class NotificationPlatformBridgeWinImpl
DLOG(ERROR) << "Failed to get toast dismissal reason: " << std::hex << hr;
}
HandleEvent(notification, NotificationCommon::CLOSE,
HandleEvent(notification, NotificationCommon::OPERATION_CLOSE,
/*action_index=*/base::nullopt, by_user);
return S_OK;
}
......@@ -839,9 +839,9 @@ bool NotificationPlatformBridgeWin::HandleActivation(
if (!inline_reply.empty())
reply = inline_reply;
NotificationCommon::Operation operation = launch_id.is_for_context_menu()
? NotificationCommon::SETTINGS
: NotificationCommon::CLICK;
NotificationCommon::Operation operation =
launch_id.is_for_context_menu() ? NotificationCommon::OPERATION_SETTINGS
: NotificationCommon::OPERATION_CLICK;
ForwardNotificationOperationOnUiThread(
operation, launch_id.notification_type(), launch_id.origin_url(),
......
......@@ -249,12 +249,12 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, HandleEvent) {
// Simulate clicks on the toast.
NotificationPlatformBridgeWin* bridge = GetBridge();
ASSERT_TRUE(bridge);
bridge->ForwardHandleEventForTesting(NotificationCommon::CLICK, &toast, &args,
base::nullopt);
bridge->ForwardHandleEventForTesting(NotificationCommon::OPERATION_CLICK,
&toast, &args, base::nullopt);
run_loop.Run();
// Validate the click values.
EXPECT_EQ(NotificationCommon::CLICK, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_CLICK, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......@@ -281,7 +281,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, HandleActivation) {
run_loop.Run();
// Validate the values.
EXPECT_EQ(NotificationCommon::CLICK, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_CLICK, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......@@ -320,12 +320,12 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, HandleSettings) {
// Simulate clicks on the toast.
NotificationPlatformBridgeWin* bridge = GetBridge();
ASSERT_TRUE(bridge);
bridge->ForwardHandleEventForTesting(NotificationCommon::SETTINGS, &toast,
&args, base::nullopt);
bridge->ForwardHandleEventForTesting(NotificationCommon::OPERATION_SETTINGS,
&toast, &args, base::nullopt);
run_loop.Run();
// Validate the click values.
EXPECT_EQ(NotificationCommon::SETTINGS, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_SETTINGS, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......@@ -476,7 +476,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, CmdLineClick) {
ASSERT_NO_FATAL_FAILURE(ProcessLaunchIdViaCmdLine(kLaunchId, /*reply=*/""));
// Validate the click values.
EXPECT_EQ(NotificationCommon::CLICK, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_CLICK, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......@@ -494,7 +494,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest,
ProcessLaunchIdViaCmdLine(kLaunchIdButtonClick, "Inline reply"));
// Validate the click values.
EXPECT_EQ(NotificationCommon::CLICK, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_CLICK, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......@@ -511,7 +511,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, CmdLineButton) {
ProcessLaunchIdViaCmdLine(kLaunchIdButtonClick, /*reply=*/""));
// Validate the click values.
EXPECT_EQ(NotificationCommon::CLICK, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_CLICK, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......@@ -528,7 +528,7 @@ IN_PROC_BROWSER_TEST_F(NotificationPlatformBridgeWinUITest, CmdLineSettings) {
ProcessLaunchIdViaCmdLine(kLaunchIdSettings, /*reply=*/""));
// Validate the click values.
EXPECT_EQ(NotificationCommon::SETTINGS, last_operation_);
EXPECT_EQ(NotificationCommon::OPERATION_SETTINGS, last_operation_);
EXPECT_EQ(NotificationHandler::Type::WEB_PERSISTENT, last_notification_type_);
EXPECT_EQ(GURL("https://example.com/"), last_origin_);
EXPECT_EQ("notification_id", last_notification_id_);
......
......@@ -16,11 +16,12 @@
static_assert(static_cast<int>(a) == static_cast<int>(b), \
"mismatching enums: " #a)
STATIC_ASSERT_ENUM(NOTIFICATION_CLICK, NotificationCommon::CLICK);
STATIC_ASSERT_ENUM(NOTIFICATION_CLOSE, NotificationCommon::CLOSE);
STATIC_ASSERT_ENUM(NOTIFICATION_CLICK, NotificationCommon::OPERATION_CLICK);
STATIC_ASSERT_ENUM(NOTIFICATION_CLOSE, NotificationCommon::OPERATION_CLOSE);
STATIC_ASSERT_ENUM(NOTIFICATION_DISABLE_PERMISSION,
NotificationCommon::DISABLE_PERMISSION);
STATIC_ASSERT_ENUM(NOTIFICATION_SETTINGS, NotificationCommon::SETTINGS);
NotificationCommon::OPERATION_DISABLE_PERMISSION);
STATIC_ASSERT_ENUM(NOTIFICATION_SETTINGS,
NotificationCommon::OPERATION_SETTINGS);
STATIC_ASSERT_ENUM(NOTIFICATION_OPERATION_MAX,
NotificationCommon::OPERATION_MAX);
......
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