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

Side by Side Diff: chrome/common/extensions/api/storage/storage_schema_manifest_handler.cc

Issue 309533007: Refactor PermissionsData pt1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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 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/common/extensions/api/storage/storage_schema_manifest_handler.h " 5 #include "chrome/common/extensions/api/storage/storage_schema_manifest_handler.h "
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "extensions/common/extension.h" 16 #include "extensions/common/extension.h"
17 #include "extensions/common/install_warning.h" 17 #include "extensions/common/install_warning.h"
18 #include "extensions/common/manifest.h" 18 #include "extensions/common/manifest.h"
19 #include "extensions/common/manifest_constants.h" 19 #include "extensions/common/manifest_constants.h"
20 #include "extensions/common/manifest_handlers/permissions_parser.h"
20 #include "extensions/common/permissions/api_permission.h" 21 #include "extensions/common/permissions/api_permission.h"
21 #include "extensions/common/permissions/api_permission_set.h" 22 #include "extensions/common/permissions/api_permission_set.h"
22 #include "extensions/common/permissions/permissions_data.h"
23 #include "extensions/common/permissions/permissions_info.h" 23 #include "extensions/common/permissions/permissions_info.h"
24 24
25 #if defined(ENABLE_CONFIGURATION_POLICY) 25 #if defined(ENABLE_CONFIGURATION_POLICY)
26 #include "components/policy/core/common/schema.h" 26 #include "components/policy/core/common/schema.h"
27 #endif 27 #endif
28 28
29 using extensions::manifest_keys::kStorageManagedSchema; 29 using extensions::manifest_keys::kStorageManagedSchema;
30 30
31 namespace extensions { 31 namespace extensions {
32 32
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 base::string16* error) { 66 base::string16* error) {
67 std::string path; 67 std::string path;
68 if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) { 68 if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) {
69 *error = base::ASCIIToUTF16( 69 *error = base::ASCIIToUTF16(
70 base::StringPrintf("%s must be a string", kStorageManagedSchema)); 70 base::StringPrintf("%s must be a string", kStorageManagedSchema));
71 return false; 71 return false;
72 } 72 }
73 73
74 // If an extension declares the "storage.managed_schema" key then it gets 74 // If an extension declares the "storage.managed_schema" key then it gets
75 // the "storage" permission implicitly. 75 // the "storage" permission implicitly.
76 APIPermissionSet* permission_set = 76 PermissionsParser::AddAPIPermission(extension, APIPermission::kStorage);
77 PermissionsData::GetInitialAPIPermissions(extension);
78 permission_set->insert(APIPermission::kStorage);
79 77
80 return true; 78 return true;
81 } 79 }
82 80
83 bool StorageSchemaManifestHandler::Validate( 81 bool StorageSchemaManifestHandler::Validate(
84 const Extension* extension, 82 const Extension* extension,
85 std::string* error, 83 std::string* error,
86 std::vector<InstallWarning>* warnings) const { 84 std::vector<InstallWarning>* warnings) const {
87 #if defined(ENABLE_CONFIGURATION_POLICY) 85 #if defined(ENABLE_CONFIGURATION_POLICY)
88 return GetSchema(extension, error).valid(); 86 return GetSchema(extension, error).valid();
89 #else 87 #else
90 return true; 88 return true;
91 #endif 89 #endif
92 } 90 }
93 91
94 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { 92 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const {
95 return SingleKey(kStorageManagedSchema); 93 return SingleKey(kStorageManagedSchema);
96 } 94 }
97 95
98 } // namespace extensions 96 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698