| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/extensions/device_local_account_management_pol
icy_provider.h" | 5 #include "chrome/browser/chromeos/extensions/device_local_account_management_pol
icy_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 it.key() == emk::kOptionalPermissions) { | 756 it.key() == emk::kOptionalPermissions) { |
| 757 const base::ListValue* list_value; | 757 const base::ListValue* list_value; |
| 758 if (!it.value().GetAsList(&list_value)) { | 758 if (!it.value().GetAsList(&list_value)) { |
| 759 LOG(ERROR) << extension->id() << ": " << it.key() << " is not a list."; | 759 LOG(ERROR) << extension->id() << ": " << it.key() << " is not a list."; |
| 760 safe = false; | 760 safe = false; |
| 761 continue; | 761 continue; |
| 762 } | 762 } |
| 763 for (auto it2 = list_value->begin(); it2 != list_value->end(); ++it2) { | 763 for (auto it2 = list_value->begin(); it2 != list_value->end(); ++it2) { |
| 764 // Try to read as dictionary. | 764 // Try to read as dictionary. |
| 765 const base::DictionaryValue *dict_value; | 765 const base::DictionaryValue *dict_value; |
| 766 if (it2->GetAsDictionary(&dict_value)) { | 766 if ((*it2)->GetAsDictionary(&dict_value)) { |
| 767 if (dict_value->size() != 1) { | 767 if (dict_value->size() != 1) { |
| 768 LOG(ERROR) << extension->id() | 768 LOG(ERROR) << extension->id() |
| 769 << " has dict in permission list with size " | 769 << " has dict in permission list with size " |
| 770 << dict_value->size() << "."; | 770 << dict_value->size() << "."; |
| 771 safe = false; | 771 safe = false; |
| 772 continue; | 772 continue; |
| 773 } | 773 } |
| 774 for (base::DictionaryValue::Iterator it3(*dict_value); | 774 for (base::DictionaryValue::Iterator it3(*dict_value); |
| 775 !it3.IsAtEnd(); it3.Advance()) { | 775 !it3.IsAtEnd(); it3.Advance()) { |
| 776 if (!ArrayContains(kSafePermissionDicts, it3.key())) { | 776 if (!ArrayContains(kSafePermissionDicts, it3.key())) { |
| 777 LOG(ERROR) << extension->id() | 777 LOG(ERROR) << extension->id() |
| 778 << " has non-whitelisted dict in permission list: " | 778 << " has non-whitelisted dict in permission list: " |
| 779 << it3.key(); | 779 << it3.key(); |
| 780 safe = false; | 780 safe = false; |
| 781 continue; | 781 continue; |
| 782 } | 782 } |
| 783 } | 783 } |
| 784 continue; | 784 continue; |
| 785 } | 785 } |
| 786 // Try to read as string. | 786 // Try to read as string. |
| 787 std::string permission_string; | 787 std::string permission_string; |
| 788 if (!it2->GetAsString(&permission_string)) { | 788 if (!(*it2)->GetAsString(&permission_string)) { |
| 789 LOG(ERROR) << extension->id() << ": " << it.key() | 789 LOG(ERROR) << extension->id() << ": " << it.key() |
| 790 << " contains a token that's neither a string nor a dict."; | 790 << " contains a token that's neither a string nor a dict."; |
| 791 safe = false; | 791 safe = false; |
| 792 continue; | 792 continue; |
| 793 } | 793 } |
| 794 // Accept whitelisted permissions. | 794 // Accept whitelisted permissions. |
| 795 if (ArrayContains(kSafePermissionStrings, permission_string)) { | 795 if (ArrayContains(kSafePermissionStrings, permission_string)) { |
| 796 continue; | 796 continue; |
| 797 } | 797 } |
| 798 // Web requests (origin permissions). Don't include <all_urls> because | 798 // Web requests (origin permissions). Don't include <all_urls> because |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 if (error) { | 940 if (error) { |
| 941 *error = l10n_util::GetStringFUTF16( | 941 *error = l10n_util::GetStringFUTF16( |
| 942 IDS_EXTENSION_CANT_INSTALL_IN_DEVICE_LOCAL_ACCOUNT, | 942 IDS_EXTENSION_CANT_INSTALL_IN_DEVICE_LOCAL_ACCOUNT, |
| 943 base::UTF8ToUTF16(extension->name()), | 943 base::UTF8ToUTF16(extension->name()), |
| 944 base::UTF8ToUTF16(extension->id())); | 944 base::UTF8ToUTF16(extension->id())); |
| 945 } | 945 } |
| 946 return false; | 946 return false; |
| 947 } | 947 } |
| 948 | 948 |
| 949 } // namespace chromeos | 949 } // namespace chromeos |
| OLD | NEW |