Commit 3579436b authored by Amos Lim's avatar Amos Lim Committed by Commit Bot

[OnionSoup] Move notification_data_conversions to blink

Move notification_data_conversions* from content/renderer/notifications
to third_party/blink/public/common and third_party/blink/common.

Since notification_data_conversions converts data in blink side only,
it no longer needs to be placed in content.

Bug: 919396
Change-Id: I184d17abb4ea65390603870760c43b5bcc5063e1
Reviewed-on: https://chromium-review.googlesource.com/c/1447398Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Amos Lim <eui-sang.lim@samsung.com>
Cr-Commit-Position: refs/heads/master@{#628551}
parent 28948ce5
...@@ -431,8 +431,6 @@ target(link_target_type, "renderer") { ...@@ -431,8 +431,6 @@ target(link_target_type, "renderer") {
"navigation_state.h", "navigation_state.h",
"net_info_helper.cc", "net_info_helper.cc",
"net_info_helper.h", "net_info_helper.h",
"notifications/notification_data_conversions.cc",
"notifications/notification_data_conversions.h",
"p2p/empty_network_manager.cc", "p2p/empty_network_manager.cc",
"p2p/empty_network_manager.h", "p2p/empty_network_manager.h",
"p2p/filtering_network_manager.cc", "p2p/filtering_network_manager.cc",
......
file://content/browser/notifications/OWNERS
# TEAM: platform-capabilities@chromium.org
# COMPONENT: UI>Notifications
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "content/renderer/loader/web_data_consumer_handle_impl.h" #include "content/renderer/loader/web_data_consumer_handle_impl.h"
#include "content/renderer/loader/web_url_loader_impl.h" #include "content/renderer/loader/web_url_loader_impl.h"
#include "content/renderer/loader/web_url_request_util.h" #include "content/renderer/loader/web_url_request_util.h"
#include "content/renderer/notifications/notification_data_conversions.h"
#include "content/renderer/render_thread_impl.h" #include "content/renderer/render_thread_impl.h"
#include "content/renderer/renderer_blink_platform_impl.h" #include "content/renderer/renderer_blink_platform_impl.h"
#include "content/renderer/service_worker/controller_service_worker_impl.h" #include "content/renderer/service_worker/controller_service_worker_impl.h"
...@@ -71,6 +70,7 @@ ...@@ -71,6 +70,7 @@
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_request.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_request.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_response.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_response.h"
#include "third_party/blink/public/platform/notification_data_conversions.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/url_conversion.h" #include "third_party/blink/public/platform/url_conversion.h"
#include "third_party/blink/public/platform/web_blob_registry.h" #include "third_party/blink/public/platform/web_blob_registry.h"
......
...@@ -1816,7 +1816,6 @@ test("content_unittests") { ...@@ -1816,7 +1816,6 @@ test("content_unittests") {
"../renderer/media_recorder/audio_track_recorder_unittest.cc", "../renderer/media_recorder/audio_track_recorder_unittest.cc",
"../renderer/media_recorder/media_recorder_handler_unittest.cc", "../renderer/media_recorder/media_recorder_handler_unittest.cc",
"../renderer/media_recorder/video_track_recorder_unittest.cc", "../renderer/media_recorder/video_track_recorder_unittest.cc",
"../renderer/notifications/notification_data_conversions_unittest.cc",
"../renderer/p2p/filtering_network_manager_unittest.cc", "../renderer/p2p/filtering_network_manager_unittest.cc",
"../renderer/p2p/ipc_network_manager_unittest.cc", "../renderer/p2p/ipc_network_manager_unittest.cc",
"../renderer/peripheral_content_heuristic_unittest.cc", "../renderer/peripheral_content_heuristic_unittest.cc",
......
...@@ -176,6 +176,7 @@ source_set("blink_headers") { ...@@ -176,6 +176,7 @@ source_set("blink_headers") {
"platform/modules/service_worker/web_service_worker_request.h", "platform/modules/service_worker/web_service_worker_request.h",
"platform/modules/service_worker/web_service_worker_response.h", "platform/modules/service_worker/web_service_worker_response.h",
"platform/modules/service_worker/web_service_worker_stream_handle.h", "platform/modules/service_worker/web_service_worker_stream_handle.h",
"platform/notification_data_conversions.h",
"platform/platform.h", "platform/platform.h",
"platform/pointer_properties.h", "platform/pointer_properties.h",
"platform/scheduler/web_rail_mode_observer.h", "platform/scheduler/web_rail_mode_observer.h",
......
...@@ -2,19 +2,18 @@ ...@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ #ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_NOTIFICATION_DATA_CONVERSIONS_H_
#define CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ #define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_NOTIFICATION_DATA_CONVERSIONS_H_
#include "content/common/content_export.h"
#include "third_party/blink/public/common/notifications/platform_notification_data.h" #include "third_party/blink/public/common/notifications/platform_notification_data.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_data.h" #include "third_party/blink/public/platform/modules/notifications/web_notification_data.h"
namespace content { namespace blink {
// Converts blink::PlatformNotificationData to Blink WebNotificationData. // Converts blink::PlatformNotificationData to Blink WebNotificationData.
CONTENT_EXPORT blink::WebNotificationData ToWebNotificationData( BLINK_PLATFORM_EXPORT WebNotificationData
const blink::PlatformNotificationData& platform_data); ToWebNotificationData(const PlatformNotificationData& platform_data);
} // namespace content } // namespace blink
#endif // CONTENT_RENDERER_NOTIFICATIONS_NOTIFICATION_DATA_CONVERSIONS_H_ #endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_NOTIFICATION_DATA_CONVERSIONS_H_
...@@ -509,6 +509,7 @@ jumbo_component("platform") { ...@@ -509,6 +509,7 @@ jumbo_component("platform") {
"exported/mediastream/media_stream_audio_track.cc", "exported/mediastream/media_stream_audio_track.cc",
"exported/mediastream/web_platform_media_stream_source.cc", "exported/mediastream/web_platform_media_stream_source.cc",
"exported/mediastream/web_platform_media_stream_track.cc", "exported/mediastream/web_platform_media_stream_track.cc",
"exported/notification_data_conversions.cc",
"exported/platform.cc", "exported/platform.cc",
"exported/service_registry.cc", "exported/service_registry.cc",
"exported/url_conversion.cc", "exported/url_conversion.cc",
...@@ -1678,6 +1679,7 @@ jumbo_source_set("blink_platform_unittests_sources") { ...@@ -1678,6 +1679,7 @@ jumbo_source_set("blink_platform_unittests_sources") {
"bindings/runtime_call_stats_test.cc", "bindings/runtime_call_stats_test.cc",
"drag_image_test.cc", "drag_image_test.cc",
"exported/file_path_conversion_test.cc", "exported/file_path_conversion_test.cc",
"exported/notification_data_conversions_test.cc",
"exported/web_canonical_cookie_test.cc", "exported/web_canonical_cookie_test.cc",
"exported/web_string_test.cc", "exported/web_string_test.cc",
"fonts/android/font_cache_android_test.cc", "fonts/android/font_cache_android_test.cc",
......
include_rules = [ include_rules = [
"+net/cookies/canonical_cookie.h", "+net/cookies/canonical_cookie.h",
"+net/cookies/cookie_constants.h", "+net/cookies/cookie_constants.h",
] ]
specific_include_rules = {
"notification_data_conversions_test.cc": [
"+base/strings/nullable_string16.h",
"+base/strings/utf_string_conversions.h",
],
}
per-file notification_data_conversions*=peter@chromium.org
per-file web_rtc_*=hbos@chromium.org per-file web_rtc_*=hbos@chromium.org
...@@ -2,62 +2,55 @@ ...@@ -2,62 +2,55 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/renderer/notifications/notification_data_conversions.h" #include "third_party/blink/public/platform/notification_data_conversions.h"
#include <stddef.h>
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "third_party/blink/public/mojom/notifications/notification.mojom-shared.h" #include "third_party/blink/public/mojom/notifications/notification.mojom-shared.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_action.h" #include "third_party/blink/public/platform/modules/notifications/web_notification_action.h"
#include "third_party/blink/public/platform/url_conversion.h" #include "third_party/blink/public/platform/url_conversion.h"
#include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
using blink::WebNotificationData; namespace blink {
using blink::WebString;
namespace content {
WebNotificationData ToWebNotificationData( WebNotificationData ToWebNotificationData(
const blink::PlatformNotificationData& platform_data) { const PlatformNotificationData& platform_data) {
WebNotificationData web_data; WebNotificationData web_data;
web_data.title = WebString::FromUTF16(platform_data.title); web_data.title = WebString::FromUTF16(platform_data.title);
switch (platform_data.direction) { switch (platform_data.direction) {
case blink::PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT: case PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT:
web_data.direction = blink::mojom::NotificationDirection::LEFT_TO_RIGHT; web_data.direction = mojom::NotificationDirection::LEFT_TO_RIGHT;
break; break;
case blink::PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT: case PlatformNotificationData::DIRECTION_RIGHT_TO_LEFT:
web_data.direction = blink::mojom::NotificationDirection::RIGHT_TO_LEFT; web_data.direction = mojom::NotificationDirection::RIGHT_TO_LEFT;
break; break;
case blink::PlatformNotificationData::DIRECTION_AUTO: case PlatformNotificationData::DIRECTION_AUTO:
web_data.direction = blink::mojom::NotificationDirection::AUTO; web_data.direction = mojom::NotificationDirection::AUTO;
break; break;
} }
web_data.lang = WebString::FromUTF8(platform_data.lang); web_data.lang = WebString::FromUTF8(platform_data.lang);
web_data.body = WebString::FromUTF16(platform_data.body); web_data.body = WebString::FromUTF16(platform_data.body);
web_data.tag = WebString::FromUTF8(platform_data.tag); web_data.tag = WebString::FromUTF8(platform_data.tag);
web_data.image = blink::WebURL(platform_data.image); web_data.image = WebURL(KURL(platform_data.image));
web_data.icon = blink::WebURL(platform_data.icon); web_data.icon = WebURL(KURL(platform_data.icon));
web_data.badge = blink::WebURL(platform_data.badge); web_data.badge = WebURL(KURL(platform_data.badge));
web_data.vibrate = platform_data.vibration_pattern; web_data.vibrate = platform_data.vibration_pattern;
web_data.timestamp = platform_data.timestamp.ToJsTime(); web_data.timestamp = platform_data.timestamp.ToJsTime();
web_data.renotify = platform_data.renotify; web_data.renotify = platform_data.renotify;
web_data.silent = platform_data.silent; web_data.silent = platform_data.silent;
web_data.require_interaction = platform_data.require_interaction; web_data.require_interaction = platform_data.require_interaction;
web_data.data = platform_data.data; web_data.data = platform_data.data;
blink::WebVector<blink::WebNotificationAction> resized( WebVector<WebNotificationAction> resized(platform_data.actions.size());
platform_data.actions.size());
web_data.actions.Swap(resized); web_data.actions.Swap(resized);
for (size_t i = 0; i < platform_data.actions.size(); ++i) { for (size_t i = 0; i < platform_data.actions.size(); ++i) {
switch (platform_data.actions[i].type) { switch (platform_data.actions[i].type) {
case blink::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON: case PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON:
web_data.actions[i].type = blink::WebNotificationAction::kButton; web_data.actions[i].type = WebNotificationAction::kButton;
break; break;
case blink::PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT: case PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT:
web_data.actions[i].type = blink::WebNotificationAction::kText; web_data.actions[i].type = WebNotificationAction::kText;
break; break;
default: default:
NOTREACHED() << "Unknown platform data type: " NOTREACHED() << "Unknown platform data type: "
...@@ -67,7 +60,7 @@ WebNotificationData ToWebNotificationData( ...@@ -67,7 +60,7 @@ WebNotificationData ToWebNotificationData(
WebString::FromUTF8(platform_data.actions[i].action); WebString::FromUTF8(platform_data.actions[i].action);
web_data.actions[i].title = web_data.actions[i].title =
WebString::FromUTF16(platform_data.actions[i].title); WebString::FromUTF16(platform_data.actions[i].title);
web_data.actions[i].icon = blink::WebURL(platform_data.actions[i].icon); web_data.actions[i].icon = WebURL(KURL(platform_data.actions[i].icon));
web_data.actions[i].placeholder = web_data.actions[i].placeholder =
WebString::FromUTF16(platform_data.actions[i].placeholder); WebString::FromUTF16(platform_data.actions[i].placeholder);
} }
...@@ -75,4 +68,4 @@ WebNotificationData ToWebNotificationData( ...@@ -75,4 +68,4 @@ WebNotificationData ToWebNotificationData(
return web_data; return web_data;
} }
} // namespace content } // namespace blink
...@@ -2,21 +2,22 @@ ...@@ -2,21 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/renderer/notifications/notification_data_conversions.h" #include "third_party/blink/public/platform/notification_data_conversions.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "testing/gmock/include/gmock/gmock.h" #include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/notifications/platform_notification_data.h" #include "third_party/blink/public/common/notifications/platform_notification_data.h"
#include "third_party/blink/public/platform/modules/notifications/web_notification_data.h" #include "third_party/blink/public/platform/modules/notifications/web_notification_data.h"
#include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url.h"
namespace content { namespace blink {
const char kNotificationTitle[] = "My Notification"; const char kNotificationTitle[] = "My Notification";
const char kNotificationLang[] = "nl"; const char kNotificationLang[] = "nl";
...@@ -45,10 +46,9 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) { ...@@ -45,10 +46,9 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
std::vector<char> developer_data( std::vector<char> developer_data(
kNotificationData, kNotificationData + base::size(kNotificationData)); kNotificationData, kNotificationData + base::size(kNotificationData));
blink::PlatformNotificationData platform_data; PlatformNotificationData platform_data;
platform_data.title = base::ASCIIToUTF16(kNotificationTitle); platform_data.title = base::ASCIIToUTF16(kNotificationTitle);
platform_data.direction = platform_data.direction = PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT;
blink::PlatformNotificationData::DIRECTION_LEFT_TO_RIGHT;
platform_data.lang = kNotificationLang; platform_data.lang = kNotificationLang;
platform_data.body = base::ASCIIToUTF16(kNotificationBody); platform_data.body = base::ASCIIToUTF16(kNotificationBody);
platform_data.tag = kNotificationTag; platform_data.tag = kNotificationTag;
...@@ -62,20 +62,19 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) { ...@@ -62,20 +62,19 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
platform_data.require_interaction = true; platform_data.require_interaction = true;
platform_data.data = developer_data; platform_data.data = developer_data;
platform_data.actions.resize(2); platform_data.actions.resize(2);
platform_data.actions[0].type = platform_data.actions[0].type = PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON;
blink::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON;
platform_data.actions[0].action = kAction1Name; platform_data.actions[0].action = kAction1Name;
platform_data.actions[0].title = base::ASCIIToUTF16(kAction1Title); platform_data.actions[0].title = base::ASCIIToUTF16(kAction1Title);
platform_data.actions[0].icon = GURL(kAction1IconUrl); platform_data.actions[0].icon = GURL(kAction1IconUrl);
platform_data.actions[0].placeholder = platform_data.actions[0].placeholder =
base::NullableString16(base::ASCIIToUTF16(kAction1Placeholder), false); base::NullableString16(base::ASCIIToUTF16(kAction1Placeholder), false);
platform_data.actions[1].type = blink::PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT; platform_data.actions[1].type = PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT;
platform_data.actions[1].action = kAction2Name; platform_data.actions[1].action = kAction2Name;
platform_data.actions[1].title = base::ASCIIToUTF16(kAction2Title); platform_data.actions[1].title = base::ASCIIToUTF16(kAction2Title);
platform_data.actions[1].icon = GURL(kAction2IconUrl); platform_data.actions[1].icon = GURL(kAction2IconUrl);
platform_data.actions[1].placeholder = base::NullableString16(); platform_data.actions[1].placeholder = base::NullableString16();
blink::WebNotificationData web_data = ToWebNotificationData(platform_data); WebNotificationData web_data = ToWebNotificationData(platform_data);
EXPECT_EQ(kNotificationTitle, web_data.title); EXPECT_EQ(kNotificationTitle, web_data.title);
EXPECT_EQ(blink::mojom::NotificationDirection::LEFT_TO_RIGHT, EXPECT_EQ(blink::mojom::NotificationDirection::LEFT_TO_RIGHT,
web_data.direction); web_data.direction);
...@@ -100,16 +99,16 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) { ...@@ -100,16 +99,16 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
EXPECT_EQ(developer_data[i], web_data.data[i]); EXPECT_EQ(developer_data[i], web_data.data[i]);
ASSERT_EQ(platform_data.actions.size(), web_data.actions.size()); ASSERT_EQ(platform_data.actions.size(), web_data.actions.size());
EXPECT_EQ(blink::WebNotificationAction::kButton, web_data.actions[0].type); EXPECT_EQ(WebNotificationAction::kButton, web_data.actions[0].type);
EXPECT_EQ(kAction1Name, web_data.actions[0].action); EXPECT_EQ(kAction1Name, web_data.actions[0].action);
EXPECT_EQ(kAction1Title, web_data.actions[0].title); EXPECT_EQ(kAction1Title, web_data.actions[0].title);
EXPECT_EQ(kAction1IconUrl, web_data.actions[0].icon.GetString()); EXPECT_EQ(kAction1IconUrl, web_data.actions[0].icon.GetString());
EXPECT_EQ(kAction1Placeholder, web_data.actions[0].placeholder); EXPECT_EQ(kAction1Placeholder, web_data.actions[0].placeholder);
EXPECT_EQ(blink::WebNotificationAction::kText, web_data.actions[1].type); EXPECT_EQ(WebNotificationAction::kText, web_data.actions[1].type);
EXPECT_EQ(kAction2Name, web_data.actions[1].action); EXPECT_EQ(kAction2Name, web_data.actions[1].action);
EXPECT_EQ(kAction2Title, web_data.actions[1].title); EXPECT_EQ(kAction2Title, web_data.actions[1].title);
EXPECT_EQ(kAction2IconUrl, web_data.actions[1].icon.GetString()); EXPECT_EQ(kAction2IconUrl, web_data.actions[1].icon.GetString());
EXPECT_TRUE(web_data.actions[1].placeholder.IsNull()); EXPECT_TRUE(web_data.actions[1].placeholder.IsNull());
} }
} // namespace content } // namespace blink
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