| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 617 |
| 618 NotificationsGetAllFunction::NotificationsGetAllFunction() {} | 618 NotificationsGetAllFunction::NotificationsGetAllFunction() {} |
| 619 | 619 |
| 620 NotificationsGetAllFunction::~NotificationsGetAllFunction() {} | 620 NotificationsGetAllFunction::~NotificationsGetAllFunction() {} |
| 621 | 621 |
| 622 bool NotificationsGetAllFunction::RunNotificationsApi() { | 622 bool NotificationsGetAllFunction::RunNotificationsApi() { |
| 623 NotificationUIManager* notification_ui_manager = | 623 NotificationUIManager* notification_ui_manager = |
| 624 g_browser_process->notification_ui_manager(); | 624 g_browser_process->notification_ui_manager(); |
| 625 std::set<std::string> notification_ids = | 625 std::set<std::string> notification_ids = |
| 626 notification_ui_manager->GetAllIdsByProfileAndSourceOrigin( | 626 notification_ui_manager->GetAllIdsByProfileAndSourceOrigin( |
| 627 GetProfile(), extension_->url()); | 627 NotificationUIManager::GetProfileID(GetProfile()), extension_->url()); |
| 628 | 628 |
| 629 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 629 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 630 | 630 |
| 631 for (std::set<std::string>::iterator iter = notification_ids.begin(); | 631 for (std::set<std::string>::iterator iter = notification_ids.begin(); |
| 632 iter != notification_ids.end(); iter++) { | 632 iter != notification_ids.end(); iter++) { |
| 633 result->SetBooleanWithoutPathExpansion( | 633 result->SetBooleanWithoutPathExpansion( |
| 634 StripScopeFromIdentifier(extension_->id(), *iter), true); | 634 StripScopeFromIdentifier(extension_->id(), *iter), true); |
| 635 } | 635 } |
| 636 | 636 |
| 637 SetResult(result.release()); | 637 SetResult(result.release()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 656 ? api::notifications::PERMISSION_LEVEL_GRANTED | 656 ? api::notifications::PERMISSION_LEVEL_GRANTED |
| 657 : api::notifications::PERMISSION_LEVEL_DENIED; | 657 : api::notifications::PERMISSION_LEVEL_DENIED; |
| 658 | 658 |
| 659 SetResult(new base::StringValue(api::notifications::ToString(result))); | 659 SetResult(new base::StringValue(api::notifications::ToString(result))); |
| 660 SendResponse(true); | 660 SendResponse(true); |
| 661 | 661 |
| 662 return true; | 662 return true; |
| 663 } | 663 } |
| 664 | 664 |
| 665 } // namespace extensions | 665 } // namespace extensions |
| OLD | NEW |