Commit 3858b669 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

bindings: Fix accesses on an IDL dictionary

This CL fixes two potential issues related to code generator's migration

- Do not access Notification.vibration if it is missing
- Check Notifivation.data is null or not


Bug: 839389, 107964
Change-Id: If2ecbb1339bf539d52f4dad196d8aff36a7e0b80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228015
Auto-Submit: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774922}
parent 8c201b94
...@@ -78,11 +78,15 @@ mojom::blink::NotificationDataPtr CreateNotificationData( ...@@ -78,11 +78,15 @@ mojom::blink::NotificationDataPtr CreateNotificationData(
if (options->hasBadge() && !options->badge().IsEmpty()) if (options->hasBadge() && !options->badge().IsEmpty())
notification_data->badge = CompleteURL(context, options->badge()); notification_data->badge = CompleteURL(context, options->badge());
VibrationController::VibrationPattern vibration_pattern = VibrationController::VibrationPattern vibration_pattern;
VibrationController::SanitizeVibrationPattern(options->vibrate()); if (options->hasVibrate()) {
vibration_pattern =
VibrationController::SanitizeVibrationPattern(options->vibrate());
}
notification_data->vibration_pattern = Vector<int32_t>(); notification_data->vibration_pattern = Vector<int32_t>();
notification_data->vibration_pattern->Append(vibration_pattern.data(), notification_data->vibration_pattern->Append(vibration_pattern.data(),
vibration_pattern.size()); vibration_pattern.size());
notification_data->timestamp = options->hasTimestamp() notification_data->timestamp = options->hasTimestamp()
? static_cast<double>(options->timestamp()) ? static_cast<double>(options->timestamp())
: base::Time::Now().ToDoubleT() * 1000.0; : base::Time::Now().ToDoubleT() * 1000.0;
...@@ -90,7 +94,9 @@ mojom::blink::NotificationDataPtr CreateNotificationData( ...@@ -90,7 +94,9 @@ mojom::blink::NotificationDataPtr CreateNotificationData(
notification_data->silent = options->silent(); notification_data->silent = options->silent();
notification_data->require_interaction = options->requireInteraction(); notification_data->require_interaction = options->requireInteraction();
if (options->hasData()) { // TODO(crbug.com/1070871, crbug.com/1070964): |data| member has a null value
// as a default value, and we don't need |hasData()| check actually.
if (options->hasData() && !options->data().IsNull()) {
const ScriptValue& data = options->data(); const ScriptValue& data = options->data();
v8::Isolate* isolate = data.GetIsolate(); v8::Isolate* isolate = data.GetIsolate();
DCHECK(isolate->InContext()); DCHECK(isolate->InContext());
......
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