Commit 736c9b51 authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

Remove p/p/m/n/web_notification_constants.h dependency from chrome/browser

In order to remove the dependency, the contents of the header file were
merged in the already existing
third_party/blink/public/common/notifications/notification_constants.h

Bug: 1008303
Change-Id: Ic22f381d031475d00b2614640bad5022717ab74b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1848694
Commit-Queue: Sergio Villar <svillar@igalia.com>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704540}
parent 8e45c86c
......@@ -419,7 +419,6 @@ include_rules = [
"+third_party/blink/public/platform/web_touch_event.h",
"+third_party/blink/public/platform/web_security_style.h",
"+third_party/blink/public/platform/web_sudden_termination_disabler_type.h",
"+third_party/blink/public/platform/modules/notifications/web_notification_constants.h",
"+third_party/blink/public/public_buildflags.h",
"+third_party/blink/public/web/web_context_menu_data.h",
"+third_party/blink/public/web/web_fullscreen_options.h",
......
......@@ -41,7 +41,7 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_constants.h"
#include "third_party/blink/public/common/notifications/notification_constants.h"
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/message_center/public/cpp/notification.h"
......@@ -252,7 +252,7 @@ void NotificationPlatformBridgeMac::Display(
[builder setShowSettingsButton:(notification.should_show_settings_button())];
std::vector<message_center::ButtonInfo> buttons = notification.buttons();
if (!buttons.empty()) {
DCHECK_LE(buttons.size(), blink::kWebNotificationMaxActions);
DCHECK_LE(buttons.size(), blink::kNotificationMaxActions);
NSString* buttonOne = base::SysUTF16ToNSString(buttons[0].title);
NSString* buttonTwo = nullptr;
if (buttons.size() > 1)
......@@ -414,7 +414,7 @@ bool NotificationPlatformBridgeMac::VerifyNotificationData(
if (button_index.intValue <
notification_constants::kNotificationInvalidButtonIndex ||
button_index.intValue >=
static_cast<int>(blink::kWebNotificationMaxActions)) {
static_cast<int>(blink::kNotificationMaxActions)) {
LOG(ERROR) << "Invalid number of buttons supplied "
<< button_index.intValue;
return false;
......
......@@ -118,7 +118,6 @@ include_rules = [
"+third_party/blink/public/platform/web_text_input_type.h",
"+third_party/blink/public/platform/mac/web_scrollbar_theme.h",
"+third_party/blink/public/platform/modules/indexeddb/web_idb_database_exception.h",
"+third_party/blink/public/platform/modules/notifications/web_notification_constants.h",
"+third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h",
"+third_party/blink/public/platform/modules/sms/sms_receiver.mojom.h",
"+third_party/blink/public/public_buildflags.h",
......
......@@ -17,9 +17,9 @@
#include "content/public/browser/notification_database_data.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/notifications/notification_constants.h"
#include "third_party/blink/public/common/notifications/notification_resources.h"
#include "third_party/blink/public/mojom/notifications/notification.mojom.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_constants.h"
#include "third_party/skia/include/core/SkBitmap.h"
namespace content {
......@@ -89,7 +89,7 @@ TEST(NotificationDatabaseConversionsTest, SerializeAndDeserializeData) {
notification_data.show_trigger_timestamp =
base::Time::FromJsTime(kShowTriggerTimestamp);
notification_data.data = developer_data;
for (size_t i = 0; i < blink::kWebNotificationMaxActions; i++) {
for (size_t i = 0; i < blink::kNotificationMaxActions; i++) {
blink::PlatformNotificationAction notification_action;
notification_action.type = kNotificationActionType;
notification_action.action = base::NumberToString(i);
......@@ -196,7 +196,7 @@ TEST(NotificationDatabaseConversionsTest, SerializeAndDeserializeData) {
TEST(NotificationDatabaseConversionsTest, ActionDeserializationIsNotAdditive) {
NotificationDatabaseData database_data;
for (size_t i = 0; i < blink::kWebNotificationMaxActions; ++i)
for (size_t i = 0; i < blink::kNotificationMaxActions; ++i)
database_data.notification_data.actions.emplace_back();
std::string serialized_data;
......@@ -210,7 +210,7 @@ TEST(NotificationDatabaseConversionsTest, ActionDeserializationIsNotAdditive) {
&copied_database_data));
EXPECT_EQ(copied_database_data.notification_data.actions.size(),
blink::kWebNotificationMaxActions);
blink::kNotificationMaxActions);
// Deserialize it again in the same |copied_database_data|. The number of
// actions in the structure should not be affected.
......@@ -218,7 +218,7 @@ TEST(NotificationDatabaseConversionsTest, ActionDeserializationIsNotAdditive) {
&copied_database_data));
EXPECT_EQ(copied_database_data.notification_data.actions.size(),
blink::kWebNotificationMaxActions);
blink::kNotificationMaxActions);
}
TEST(NotificationDatabaseConversionsTest, SerializeAndDeserializeActionTypes) {
......
......@@ -14,6 +14,32 @@ namespace blink {
constexpr base::TimeDelta kMaxNotificationShowTriggerDelay =
base::TimeDelta::FromDays(367);
// TODO(johnme): The maximum number of actions is platform-specific and should
// be indicated by the embedder.
// Maximum number of actions on a Platform Notification.
constexpr size_t kNotificationMaxActions = 2;
// TODO(mvanouwerkerk): Update the notification resource loader to get the
// appropriate image sizes from the embedder.
// The maximum reasonable image size, scaled from dip units to pixels using the
// largest supported scaling factor. TODO(johnme): Check sizes are correct.
constexpr int kNotificationMaxImageWidthPx = 1800; // 450 dip * 4
constexpr int kNotificationMaxImageHeightPx = 900; // 225 dip * 4
// The maximum reasonable notification icon size, scaled from dip units to
// pixels using the largest supported scaling factor.
constexpr int kNotificationMaxIconSizePx = 320; // 80 dip * 4
// The maximum reasonable badge size, scaled from dip units to pixels using the
// largest supported scaling factor.
constexpr int kNotificationMaxBadgeSizePx = 96; // 24 dip * 4
// The maximum reasonable action icon size, scaled from dip units to
// pixels using the largest supported scaling factor.
constexpr int kNotificationMaxActionIconSizePx = 128; // 32 dip * 4
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_NOTIFICATIONS_NOTIFICATION_CONSTANTS_H_
peter@chromium.org
# TEAM: platform-capabilities@chromium.org
# COMPONENT: UI>Notifications
// Copyright 2016 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 THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_NOTIFICATIONS_WEB_NOTIFICATION_CONSTANTS_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_NOTIFICATIONS_WEB_NOTIFICATION_CONSTANTS_H_
namespace blink {
// TODO(johnme): The maximum number of actions is platform-specific and should
// be indicated by the embedder.
// Maximum number of actions on a Platform Notification.
static constexpr size_t kWebNotificationMaxActions = 2;
// TODO(mvanouwerkerk): Update the notification resource loader to get the
// appropriate image sizes from the embedder.
// The maximum reasonable image size, scaled from dip units to pixels using the
// largest supported scaling factor. TODO(johnme): Check sizes are correct.
static constexpr int kWebNotificationMaxImageWidthPx = 1800; // 450 dip * 4
static constexpr int kWebNotificationMaxImageHeightPx = 900; // 225 dip * 4
// The maximum reasonable notification icon size, scaled from dip units to
// pixels using the largest supported scaling factor.
static constexpr int kWebNotificationMaxIconSizePx = 320; // 80 dip * 4
// The maximum reasonable badge size, scaled from dip units to pixels using the
// largest supported scaling factor.
static constexpr int kWebNotificationMaxBadgeSizePx = 96; // 24 dip * 4
// The maximum reasonable action icon size, scaled from dip units to
// pixels using the largest supported scaling factor.
static constexpr int kWebNotificationMaxActionIconSizePx = 128; // 32 dip * 4
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_MODULES_NOTIFICATIONS_WEB_NOTIFICATION_CONSTANTS_H_
......@@ -35,7 +35,7 @@
#include "base/unguessable_token.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_constants.h"
#include "third_party/blink/public/common/notifications/notification_constants.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value_factory.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
......@@ -469,7 +469,7 @@ ScriptPromise Notification::requestPermission(
}
uint32_t Notification::maxActions() {
return kWebNotificationMaxActions;
return kNotificationMaxActions;
}
DispatchEventResult Notification::DispatchEventInternal(Event& event) {
......
......@@ -38,7 +38,7 @@ const bool kNotificationRenotify = true;
const bool kNotificationSilent = false;
const bool kNotificationRequireInteraction = true;
const mojom::blink::NotificationActionType kWebNotificationActionType =
const mojom::blink::NotificationActionType kBlinkNotificationActionType =
mojom::blink::NotificationActionType::TEXT;
const char kNotificationActionType[] = "text";
const char kNotificationActionAction[] = "my_action";
......@@ -157,7 +157,7 @@ TEST_F(NotificationDataTest, ReflectProperties) {
notification_data->require_interaction);
EXPECT_EQ(actions.size(), notification_data->actions->size());
for (const auto& action : notification_data->actions.value()) {
EXPECT_EQ(kWebNotificationActionType, action->type);
EXPECT_EQ(kBlinkNotificationActionType, action->type);
EXPECT_EQ(kNotificationActionAction, action->action);
EXPECT_EQ(kNotificationActionTitle, action->title);
EXPECT_EQ(kNotificationActionPlaceholder, action->placeholder);
......
......@@ -8,9 +8,9 @@
#include "base/optional.h"
#include "base/time/time.h"
#include "third_party/blink/public/common/notifications/notification_constants.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/notifications/notification.mojom-blink.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_constants.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
......@@ -28,15 +28,14 @@ enum class NotificationIconType { kImage, kIcon, kBadge, kActionIcon };
WebSize GetIconDimensions(NotificationIconType type) {
switch (type) {
case NotificationIconType::kImage:
return {kWebNotificationMaxImageWidthPx,
kWebNotificationMaxImageHeightPx};
return {kNotificationMaxImageWidthPx, kNotificationMaxImageHeightPx};
case NotificationIconType::kIcon:
return {kWebNotificationMaxIconSizePx, kWebNotificationMaxIconSizePx};
return {kNotificationMaxIconSizePx, kNotificationMaxIconSizePx};
case NotificationIconType::kBadge:
return {kWebNotificationMaxBadgeSizePx, kWebNotificationMaxBadgeSizePx};
return {kNotificationMaxBadgeSizePx, kNotificationMaxBadgeSizePx};
case NotificationIconType::kActionIcon:
return {kWebNotificationMaxActionIconSizePx,
kWebNotificationMaxActionIconSizePx};
return {kNotificationMaxActionIconSizePx,
kNotificationMaxActionIconSizePx};
}
}
......
......@@ -6,8 +6,8 @@
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/notifications/notification_constants.h"
#include "third_party/blink/public/mojom/notifications/notification.mojom-blink.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_constants.h"
#include "third_party/blink/public/platform/web_url_loader_mock_factory.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
......@@ -149,19 +149,19 @@ TEST_F(NotificationResourcesLoaderTest, LargeIconsAreScaledDown) {
ASSERT_TRUE(Resources());
ASSERT_FALSE(Resources()->icon.drawsNothing());
ASSERT_EQ(kWebNotificationMaxIconSizePx, Resources()->icon.width());
ASSERT_EQ(kWebNotificationMaxIconSizePx, Resources()->icon.height());
ASSERT_EQ(kNotificationMaxIconSizePx, Resources()->icon.width());
ASSERT_EQ(kNotificationMaxIconSizePx, Resources()->icon.height());
ASSERT_FALSE(Resources()->badge.drawsNothing());
ASSERT_EQ(kWebNotificationMaxBadgeSizePx, Resources()->badge.width());
ASSERT_EQ(kWebNotificationMaxBadgeSizePx, Resources()->badge.height());
ASSERT_EQ(kNotificationMaxBadgeSizePx, Resources()->badge.width());
ASSERT_EQ(kNotificationMaxBadgeSizePx, Resources()->badge.height());
ASSERT_TRUE(Resources()->action_icons.has_value());
auto& action_icons = Resources()->action_icons.value();
ASSERT_EQ(1u, action_icons.size());
ASSERT_FALSE(action_icons[0].drawsNothing());
ASSERT_EQ(kWebNotificationMaxActionIconSizePx, action_icons[0].width());
ASSERT_EQ(kWebNotificationMaxActionIconSizePx, action_icons[0].height());
ASSERT_EQ(kNotificationMaxActionIconSizePx, action_icons[0].width());
ASSERT_EQ(kNotificationMaxActionIconSizePx, action_icons[0].height());
}
TEST_F(NotificationResourcesLoaderTest, DownscalingPreserves3_1AspectRatio) {
......@@ -174,8 +174,8 @@ TEST_F(NotificationResourcesLoaderTest, DownscalingPreserves3_1AspectRatio) {
ASSERT_TRUE(Resources());
ASSERT_FALSE(Resources()->image.drawsNothing());
ASSERT_EQ(kWebNotificationMaxImageWidthPx, Resources()->image.width());
ASSERT_EQ(kWebNotificationMaxImageWidthPx / 3, Resources()->image.height());
ASSERT_EQ(kNotificationMaxImageWidthPx, Resources()->image.width());
ASSERT_EQ(kNotificationMaxImageWidthPx / 3, Resources()->image.height());
}
TEST_F(NotificationResourcesLoaderTest, DownscalingPreserves3_2AspectRatio) {
......@@ -188,9 +188,8 @@ TEST_F(NotificationResourcesLoaderTest, DownscalingPreserves3_2AspectRatio) {
ASSERT_TRUE(Resources());
ASSERT_FALSE(Resources()->image.drawsNothing());
ASSERT_EQ(kWebNotificationMaxImageHeightPx * 3 / 2,
Resources()->image.width());
ASSERT_EQ(kWebNotificationMaxImageHeightPx, Resources()->image.height());
ASSERT_EQ(kNotificationMaxImageHeightPx * 3 / 2, Resources()->image.width());
ASSERT_EQ(kNotificationMaxImageHeightPx, Resources()->image.height());
}
TEST_F(NotificationResourcesLoaderTest, EmptyDataYieldsEmptyResources) {
......
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