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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 // If the caller provided a notificationId, use that. | 697 // If the caller provided a notificationId, use that. |
698 notification_id = *params_->notification_id; | 698 notification_id = *params_->notification_id; |
699 } else { | 699 } else { |
700 // Otherwise, use a randomly created GUID. In case that GenerateGUID returns | 700 // Otherwise, use a randomly created GUID. In case that GenerateGUID returns |
701 // the empty string, simply generate a random string. | 701 // the empty string, simply generate a random string. |
702 notification_id = base::GenerateGUID(); | 702 notification_id = base::GenerateGUID(); |
703 if (notification_id.empty()) | 703 if (notification_id.empty()) |
704 notification_id = base::RandBytesAsString(16); | 704 notification_id = base::RandBytesAsString(16); |
705 } | 705 } |
706 | 706 |
707 SetResult(base::MakeUnique<base::StringValue>(notification_id)); | 707 SetResult(base::MakeUnique<base::Value>(notification_id)); |
708 | 708 |
709 // TODO(dewittj): Add more human-readable error strings if this fails. | 709 // TODO(dewittj): Add more human-readable error strings if this fails. |
710 if (!CreateNotification(notification_id, ¶ms_->options)) | 710 if (!CreateNotification(notification_id, ¶ms_->options)) |
711 return false; | 711 return false; |
712 | 712 |
713 SendResponse(true); | 713 SendResponse(true); |
714 | 714 |
715 return true; | 715 return true; |
716 } | 716 } |
717 | 717 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 bool NotificationsGetPermissionLevelFunction::CanRunWhileDisabled() const { | 810 bool NotificationsGetPermissionLevelFunction::CanRunWhileDisabled() const { |
811 return true; | 811 return true; |
812 } | 812 } |
813 | 813 |
814 bool NotificationsGetPermissionLevelFunction::RunNotificationsApi() { | 814 bool NotificationsGetPermissionLevelFunction::RunNotificationsApi() { |
815 api::notifications::PermissionLevel result = | 815 api::notifications::PermissionLevel result = |
816 AreExtensionNotificationsAllowed() | 816 AreExtensionNotificationsAllowed() |
817 ? api::notifications::PERMISSION_LEVEL_GRANTED | 817 ? api::notifications::PERMISSION_LEVEL_GRANTED |
818 : api::notifications::PERMISSION_LEVEL_DENIED; | 818 : api::notifications::PERMISSION_LEVEL_DENIED; |
819 | 819 |
820 SetResult(base::MakeUnique<base::StringValue>( | 820 SetResult( |
821 api::notifications::ToString(result))); | 821 base::MakeUnique<base::Value>(api::notifications::ToString(result))); |
822 SendResponse(true); | 822 SendResponse(true); |
823 | 823 |
824 return true; | 824 return true; |
825 } | 825 } |
826 | 826 |
827 } // namespace extensions | 827 } // namespace extensions |
OLD | NEW |