Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 params_ = api::notifications::Update::Params::Create(*args_); 666 params_ = api::notifications::Update::Params::Create(*args_);
667 EXTENSION_FUNCTION_VALIDATE(params_.get()); 667 EXTENSION_FUNCTION_VALIDATE(params_.get());
668 668
669 // We are in update. If the ID doesn't exist, succeed but call the callback 669 // We are in update. If the ID doesn't exist, succeed but call the callback
670 // with "false". 670 // with "false".
671 const Notification* matched_notification = 671 const Notification* matched_notification =
672 g_browser_process->notification_ui_manager()->FindById( 672 g_browser_process->notification_ui_manager()->FindById(
673 CreateScopedIdentifier(extension_->id(), params_->notification_id), 673 CreateScopedIdentifier(extension_->id(), params_->notification_id),
674 NotificationUIManager::GetProfileID(GetProfile())); 674 NotificationUIManager::GetProfileID(GetProfile()));
675 if (!matched_notification) { 675 if (!matched_notification) {
676 SetResult(base::MakeUnique<base::FundamentalValue>(false)); 676 SetResult(base::MakeUnique<base::Value>(false));
677 SendResponse(true); 677 SendResponse(true);
678 return true; 678 return true;
679 } 679 }
680 680
681 // Copy the existing notification to get a writable version of it. 681 // Copy the existing notification to get a writable version of it.
682 Notification notification = *matched_notification; 682 Notification notification = *matched_notification;
683 683
684 // If we have trouble updating the notification (could be improper use of API 684 // If we have trouble updating the notification (could be improper use of API
685 // or some other reason), mark the function as failed, calling the callback 685 // or some other reason), mark the function as failed, calling the callback
686 // with false. 686 // with false.
687 // TODO(dewittj): Add more human-readable error strings if this fails. 687 // TODO(dewittj): Add more human-readable error strings if this fails.
688 bool could_update_notification = UpdateNotification( 688 bool could_update_notification = UpdateNotification(
689 params_->notification_id, &params_->options, &notification); 689 params_->notification_id, &params_->options, &notification);
690 SetResult( 690 SetResult(
691 base::MakeUnique<base::FundamentalValue>(could_update_notification)); 691 base::MakeUnique<base::Value>(could_update_notification));
692 if (!could_update_notification) 692 if (!could_update_notification)
693 return false; 693 return false;
694 694
695 // No trouble, created the notification, send true to the callback and 695 // No trouble, created the notification, send true to the callback and
696 // succeed. 696 // succeed.
697 SendResponse(true); 697 SendResponse(true);
698 return true; 698 return true;
699 } 699 }
700 700
701 NotificationsClearFunction::NotificationsClearFunction() { 701 NotificationsClearFunction::NotificationsClearFunction() {
702 } 702 }
703 703
704 NotificationsClearFunction::~NotificationsClearFunction() { 704 NotificationsClearFunction::~NotificationsClearFunction() {
705 } 705 }
706 706
707 bool NotificationsClearFunction::RunNotificationsApi() { 707 bool NotificationsClearFunction::RunNotificationsApi() {
708 params_ = api::notifications::Clear::Params::Create(*args_); 708 params_ = api::notifications::Clear::Params::Create(*args_);
709 EXTENSION_FUNCTION_VALIDATE(params_.get()); 709 EXTENSION_FUNCTION_VALIDATE(params_.get());
710 710
711 bool cancel_result = g_browser_process->notification_ui_manager()->CancelById( 711 bool cancel_result = g_browser_process->notification_ui_manager()->CancelById(
712 CreateScopedIdentifier(extension_->id(), params_->notification_id), 712 CreateScopedIdentifier(extension_->id(), params_->notification_id),
713 NotificationUIManager::GetProfileID(GetProfile())); 713 NotificationUIManager::GetProfileID(GetProfile()));
714 714
715 SetResult(base::MakeUnique<base::FundamentalValue>(cancel_result)); 715 SetResult(base::MakeUnique<base::Value>(cancel_result));
716 SendResponse(true); 716 SendResponse(true);
717 717
718 return true; 718 return true;
719 } 719 }
720 720
721 NotificationsGetAllFunction::NotificationsGetAllFunction() {} 721 NotificationsGetAllFunction::NotificationsGetAllFunction() {}
722 722
723 NotificationsGetAllFunction::~NotificationsGetAllFunction() {} 723 NotificationsGetAllFunction::~NotificationsGetAllFunction() {}
724 724
725 bool NotificationsGetAllFunction::RunNotificationsApi() { 725 bool NotificationsGetAllFunction::RunNotificationsApi() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 : api::notifications::PERMISSION_LEVEL_DENIED; 760 : api::notifications::PERMISSION_LEVEL_DENIED;
761 761
762 SetResult(base::MakeUnique<base::StringValue>( 762 SetResult(base::MakeUnique<base::StringValue>(
763 api::notifications::ToString(result))); 763 api::notifications::ToString(result)));
764 SendResponse(true); 764 SendResponse(true);
765 765
766 return true; 766 return true;
767 } 767 }
768 768
769 } // namespace extensions 769 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698