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/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" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 std::string content; | 58 std::string content; |
59 if (!base::ReadFileToString(file, &content)) { | 59 if (!base::ReadFileToString(file, &content)) { |
60 *error = base::StringPrintf("Can't read %s", file.value().c_str()); | 60 *error = base::StringPrintf("Can't read %s", file.value().c_str()); |
61 return policy::Schema(); | 61 return policy::Schema(); |
62 } | 62 } |
63 return policy::Schema::Parse(content, error); | 63 return policy::Schema::Parse(content, error); |
64 } | 64 } |
65 #endif | 65 #endif |
66 | 66 |
67 bool StorageSchemaManifestHandler::Parse(Extension* extension, | 67 bool StorageSchemaManifestHandler::Parse(Extension* extension, |
68 string16* error) { | 68 base::string16* error) { |
69 std::string path; | 69 std::string path; |
70 if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) { | 70 if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) { |
71 *error = ASCIIToUTF16( | 71 *error = ASCIIToUTF16( |
72 base::StringPrintf("%s must be a string", kStorageManagedSchema)); | 72 base::StringPrintf("%s must be a string", kStorageManagedSchema)); |
73 return false; | 73 return false; |
74 } | 74 } |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 bool StorageSchemaManifestHandler::Validate( | 78 bool StorageSchemaManifestHandler::Validate( |
79 const Extension* extension, | 79 const Extension* extension, |
80 std::string* error, | 80 std::string* error, |
81 std::vector<InstallWarning>* warnings) const { | 81 std::vector<InstallWarning>* warnings) const { |
82 #if defined(ENABLE_CONFIGURATION_POLICY) | 82 #if defined(ENABLE_CONFIGURATION_POLICY) |
83 return GetSchema(extension, error).valid(); | 83 return GetSchema(extension, error).valid(); |
84 #else | 84 #else |
85 return true; | 85 return true; |
86 #endif | 86 #endif |
87 } | 87 } |
88 | 88 |
89 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { | 89 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { |
90 return SingleKey(kStorageManagedSchema); | 90 return SingleKey(kStorageManagedSchema); |
91 } | 91 } |
92 | 92 |
93 } // namespace extensions | 93 } // namespace extensions |
OLD | NEW |