| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 PermissionIDSet set; | 62 PermissionIDSet set; |
| 63 for (const APIPermission* permission : permissions) | 63 for (const APIPermission* permission : permissions) |
| 64 set.insert(permission->id()); | 64 set.insert(permission->id()); |
| 65 return set; | 65 return set; |
| 66 } | 66 } |
| 67 | 67 |
| 68 std::string LegacyPermissionIDsToString(const PermissionMessageIDs& ids) { | 68 std::string LegacyPermissionIDsToString(const PermissionMessageIDs& ids) { |
| 69 std::vector<std::string> strs; | 69 std::vector<std::string> strs; |
| 70 for (const PermissionMessage::ID& id : ids) | 70 for (const PermissionMessage::ID& id : ids) |
| 71 strs.push_back(base::IntToString(id)); | 71 strs.push_back(base::IntToString(id)); |
| 72 return base::StringPrintf("[ %s ]", base::JoinString(strs, ", ").c_str()); | 72 return base::StringPrintf("[ %s ]", JoinString(strs, ", ").c_str()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 std::string PermissionIDsToString(const PermissionIDSet& ids) { | 75 std::string PermissionIDsToString(const PermissionIDSet& ids) { |
| 76 std::vector<std::string> strs; | 76 std::vector<std::string> strs; |
| 77 for (const PermissionID& id : ids) | 77 for (const PermissionID& id : ids) |
| 78 strs.push_back(base::IntToString(id.id())); | 78 strs.push_back(base::IntToString(id.id())); |
| 79 return base::StringPrintf("[ %s ]", base::JoinString(strs, ", ").c_str()); | 79 return base::StringPrintf("[ %s ]", JoinString(strs, ", ").c_str()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 std::string CoalescedPermissionIDsToString( | 82 std::string CoalescedPermissionIDsToString( |
| 83 const CoalescedPermissionMessages& msgs) { | 83 const CoalescedPermissionMessages& msgs) { |
| 84 std::vector<std::string> strs; | 84 std::vector<std::string> strs; |
| 85 for (const CoalescedPermissionMessage& msg : msgs) | 85 for (const CoalescedPermissionMessage& msg : msgs) |
| 86 strs.push_back(PermissionIDsToString(msg.permissions())); | 86 strs.push_back(PermissionIDsToString(msg.permissions())); |
| 87 return base::JoinString(strs, " "); | 87 return JoinString(strs, " "); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Check that the given |permissions| produce a single warning message, | 90 // Check that the given |permissions| produce a single warning message, |
| 91 // identified by |expected_legacy_id| in the old system, and by the set of | 91 // identified by |expected_legacy_id| in the old system, and by the set of |
| 92 // |expected_ids| in the new system. | 92 // |expected_ids| in the new system. |
| 93 testing::AssertionResult PermissionSetProducesMessage( | 93 testing::AssertionResult PermissionSetProducesMessage( |
| 94 const PermissionSet* permissions, | 94 const PermissionSet* permissions, |
| 95 Manifest::Type extension_type, | 95 Manifest::Type extension_type, |
| 96 PermissionMessage::ID expected_legacy_id, | 96 PermissionMessage::ID expected_legacy_id, |
| 97 const PermissionIDSet& expected_ids) { | 97 const PermissionIDSet& expected_ids) { |
| (...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 scoped_refptr<const PermissionSet> permissions_dwr( | 1801 scoped_refptr<const PermissionSet> permissions_dwr( |
| 1802 extension_dwr->permissions_data()->active_permissions()); | 1802 extension_dwr->permissions_data()->active_permissions()); |
| 1803 | 1803 |
| 1804 EXPECT_FALSE(PermissionMessageProvider::Get()-> | 1804 EXPECT_FALSE(PermissionMessageProvider::Get()-> |
| 1805 IsPrivilegeIncrease(permissions.get(), | 1805 IsPrivilegeIncrease(permissions.get(), |
| 1806 permissions_dwr.get(), | 1806 permissions_dwr.get(), |
| 1807 extension->GetType())); | 1807 extension->GetType())); |
| 1808 } | 1808 } |
| 1809 | 1809 |
| 1810 } // namespace extensions | 1810 } // namespace extensions |
| OLD | NEW |