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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 3302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3313 if (manifest_->HasKey(key)) { | 3313 if (manifest_->HasKey(key)) { |
3314 ListValue* permissions = NULL; | 3314 ListValue* permissions = NULL; |
3315 if (!manifest_->GetList(key, &permissions)) { | 3315 if (!manifest_->GetList(key, &permissions)) { |
3316 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 3316 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
3317 errors::kInvalidPermissions, ""); | 3317 errors::kInvalidPermissions, ""); |
3318 return false; | 3318 return false; |
3319 } | 3319 } |
3320 | 3320 |
3321 for (size_t i = 0; i < permissions->GetSize(); ++i) { | 3321 for (size_t i = 0; i < permissions->GetSize(); ++i) { |
3322 std::string permission_str; | 3322 std::string permission_str; |
3323 if (!permissions->GetString(i, &permission_str)) { | 3323 base::ListValue *permission_list = NULL; |
3324 if (!permissions->GetString(i, &permission_str) && | |
3325 !(permissions->GetList(i, &permission_list) && | |
3326 permission_list->GetString(0, &permission_str))) { | |
3324 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | 3327 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( |
3325 errors::kInvalidPermission, base::IntToString(i)); | 3328 errors::kInvalidPermission, base::IntToString(i)); |
3326 return false; | 3329 return false; |
3327 } | 3330 } |
3328 | 3331 |
3329 // NOTE: We need to get the APIPermission before the Feature | 3332 // NOTE: We need to get the APIPermission before the Feature |
3330 // object because the feature system does not know about aliases. | 3333 // object because the feature system does not know about aliases. |
3331 APIPermission* permission = | 3334 APIPermission* permission = |
3332 PermissionsInfo::GetInstance()->GetByName(permission_str); | 3335 PermissionsInfo::GetInstance()->GetByName(permission_str); |
3333 if (permission) { | 3336 if (permission) { |
(...skipping 23 matching lines...) Expand all Loading... | |
3357 continue; | 3360 continue; |
3358 } | 3361 } |
3359 | 3362 |
3360 if (permission->id() == APIPermission::kExperimental) { | 3363 if (permission->id() == APIPermission::kExperimental) { |
3361 if (!CanSpecifyExperimentalPermission()) { | 3364 if (!CanSpecifyExperimentalPermission()) { |
3362 *error = ASCIIToUTF16(errors::kExperimentalFlagRequired); | 3365 *error = ASCIIToUTF16(errors::kExperimentalFlagRequired); |
3363 return false; | 3366 return false; |
3364 } | 3367 } |
3365 } | 3368 } |
3366 | 3369 |
3367 api_permissions->insert(permission->id()); | 3370 scoped_refptr<APIPermissionDetail> detail = permission->CreateDetail(); |
3371 base::Value *value = NULL; | |
3372 if (!permission_list || !permission_list->Get(1, &value)) | |
3373 value = NULL; | |
miket_OOO
2012/07/31 18:18:37
Same comment as earlier. It's weird that a failing
Peng
2012/07/31 19:32:28
Done.
| |
3374 if (!detail->FromValue(value)) { | |
3375 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( | |
3376 errors::kInvalidPermission, base::IntToString(i)); | |
3377 return false; | |
3378 } | |
3379 | |
3380 api_permissions->insert(detail); | |
3368 continue; | 3381 continue; |
3369 } | 3382 } |
3370 | 3383 |
3371 // Check if it's a host pattern permission. | 3384 // Check if it's a host pattern permission. |
3372 const int kAllowedSchemes = CanExecuteScriptEverywhere() ? | 3385 const int kAllowedSchemes = CanExecuteScriptEverywhere() ? |
3373 URLPattern::SCHEME_ALL : kValidHostPermissionSchemes; | 3386 URLPattern::SCHEME_ALL : kValidHostPermissionSchemes; |
3374 | 3387 |
3375 URLPattern pattern = URLPattern(kAllowedSchemes); | 3388 URLPattern pattern = URLPattern(kAllowedSchemes); |
3376 URLPattern::ParseResult parse_result = pattern.Parse(permission_str); | 3389 URLPattern::ParseResult parse_result = pattern.Parse(permission_str); |
3377 if (parse_result == URLPattern::PARSE_SUCCESS) { | 3390 if (parse_result == URLPattern::PARSE_SUCCESS) { |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3870 | 3883 |
3871 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3884 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3872 const Extension* extension, | 3885 const Extension* extension, |
3873 const PermissionSet* permissions, | 3886 const PermissionSet* permissions, |
3874 Reason reason) | 3887 Reason reason) |
3875 : reason(reason), | 3888 : reason(reason), |
3876 extension(extension), | 3889 extension(extension), |
3877 permissions(permissions) {} | 3890 permissions(permissions) {} |
3878 | 3891 |
3879 } // namespace extensions | 3892 } // namespace extensions |
OLD | NEW |