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

Side by Side Diff: chrome/common/extensions/permissions/api_permission_set.cc

Issue 11413099: Bluetooth API Permission Dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix memory leak Created 8 years 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 | Annotate | Revision Log
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/common/extensions/permissions/api_permission_set.h" 5 #include "chrome/common/extensions/permissions/api_permission_set.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/extensions/extension_manifest_constants.h" 10 #include "chrome/common/extensions/extension_manifest_constants.h"
(...skipping 15 matching lines...) Expand all
26 const base::Value* permission_value, 26 const base::Value* permission_value,
27 APIPermissionSet* api_permissions, 27 APIPermissionSet* api_permissions,
28 string16* error, 28 string16* error,
29 std::vector<std::string>* unhandled_permissions) { 29 std::vector<std::string>* unhandled_permissions) {
30 PermissionsInfo* info = PermissionsInfo::GetInstance(); 30 PermissionsInfo* info = PermissionsInfo::GetInstance();
31 31
32 const APIPermissionInfo* permission_info = info->GetByName(permission_str); 32 const APIPermissionInfo* permission_info = info->GetByName(permission_str);
33 if (permission_info) { 33 if (permission_info) {
34 scoped_ptr<APIPermission> permission( 34 scoped_ptr<APIPermission> permission(
35 permission_info->CreateAPIPermission()); 35 permission_info->CreateAPIPermission());
36 if (!permission->FromValue(permission_value)) { 36 if (permission->ManifestEntryForbidden()) {
37 if (error) {
38 *error = ErrorUtils::FormatErrorMessageUTF16(
39 errors::kPermissionNotAllowedInManifest, permission_info->name());
40 return false;
41 }
42 LOG(WARNING) << "Permission not allowed in manifest.";
43 } else if (!permission->FromValue(permission_value)) {
37 if (error) { 44 if (error) {
38 *error = ErrorUtils::FormatErrorMessageUTF16( 45 *error = ErrorUtils::FormatErrorMessageUTF16(
39 errors::kInvalidPermission, permission_info->name()); 46 errors::kInvalidPermission, permission_info->name());
40 return false; 47 return false;
41 } 48 }
42 LOG(WARNING) << "Parse permission failed."; 49 LOG(WARNING) << "Parse permission failed.";
43 } else { 50 } else {
44 api_permissions->insert(permission.release()); 51 api_permissions->insert(permission.release());
45 } 52 }
46 return true; 53 return true;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 323 }
317 324
318 if (!CreateAPIPermission(permission_str, permission_value, 325 if (!CreateAPIPermission(permission_str, permission_value,
319 api_permissions, error, unhandled_permissions)) 326 api_permissions, error, unhandled_permissions))
320 return false; 327 return false;
321 } 328 }
322 return true; 329 return true;
323 } 330 }
324 331
325 } // namespace extensions 332 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698