OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 image_scale, bitmap_sizes.button_icon_size, *icon_bitmap_ptr, | 436 image_scale, bitmap_sizes.button_icon_size, *icon_bitmap_ptr, |
437 &info.icon); | 437 &info.icon); |
438 } | 438 } |
439 optional_fields.buttons.push_back(info); | 439 optional_fields.buttons.push_back(info); |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 if (options->context_message) { | 443 if (options->context_message) { |
444 optional_fields.context_message = | 444 optional_fields.context_message = |
445 base::UTF8ToUTF16(*options->context_message); | 445 base::UTF8ToUTF16(*options->context_message); |
446 } else { | |
447 optional_fields.context_message = base::UTF8ToUTF16(""); | |
Peter Beverloo
2017/04/07 02:26:53
Why is this necessary? I think this is a no-op? It
Miguel Garcia
2017/04/07 13:32:06
You are right, it was not needed.
| |
446 } | 448 } |
447 | 449 |
448 bool has_image = options->image_bitmap.get() && | 450 bool has_image = options->image_bitmap.get() && |
449 NotificationBitmapToGfxImage( | 451 NotificationBitmapToGfxImage( |
450 image_scale, bitmap_sizes.image_size, | 452 image_scale, bitmap_sizes.image_size, |
451 *options->image_bitmap, &optional_fields.image); | 453 *options->image_bitmap, &optional_fields.image); |
452 | 454 |
453 // We should have an image if and only if the type is an image type. | 455 // We should have an image if and only if the type is an image type. |
454 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) { | 456 if (has_image != (type == message_center::NOTIFICATION_TYPE_IMAGE)) { |
455 SetError(kExtraImageProvided); | 457 SetError(kExtraImageProvided); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 &button.icon); | 579 &button.icon); |
578 } | 580 } |
579 buttons.push_back(button); | 581 buttons.push_back(button); |
580 } | 582 } |
581 notification->set_buttons(buttons); | 583 notification->set_buttons(buttons); |
582 } | 584 } |
583 | 585 |
584 if (options->context_message) { | 586 if (options->context_message) { |
585 notification->set_context_message( | 587 notification->set_context_message( |
586 base::UTF8ToUTF16(*options->context_message)); | 588 base::UTF8ToUTF16(*options->context_message)); |
589 } else { | |
590 notification->set_context_message(base::UTF8ToUTF16("")); | |
Peter Beverloo
2017/04/07 02:26:53
(dito)
Miguel Garcia
2017/04/07 13:32:06
Acknowledged.
| |
587 } | 591 } |
588 | 592 |
589 gfx::Image image; | 593 gfx::Image image; |
590 bool has_image = | 594 bool has_image = |
591 options->image_bitmap.get() && | 595 options->image_bitmap.get() && |
592 NotificationBitmapToGfxImage( | 596 NotificationBitmapToGfxImage( |
593 image_scale, bitmap_sizes.image_size, *options->image_bitmap, &image); | 597 image_scale, bitmap_sizes.image_size, *options->image_bitmap, &image); |
594 | 598 |
595 if (has_image) { | 599 if (has_image) { |
596 // We should have an image if and only if the type is an image type. | 600 // We should have an image if and only if the type is an image type. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
828 : api::notifications::PERMISSION_LEVEL_DENIED; | 832 : api::notifications::PERMISSION_LEVEL_DENIED; |
829 | 833 |
830 SetResult( | 834 SetResult( |
831 base::MakeUnique<base::Value>(api::notifications::ToString(result))); | 835 base::MakeUnique<base::Value>(api::notifications::ToString(result))); |
832 SendResponse(true); | 836 SendResponse(true); |
833 | 837 |
834 return true; | 838 return true; |
835 } | 839 } |
836 | 840 |
837 } // namespace extensions | 841 } // namespace extensions |
OLD | NEW |