| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 kStorageManagedSchema); | 45 kStorageManagedSchema); |
| 46 return scoped_ptr<policy::PolicySchema>(); | 46 return scoped_ptr<policy::PolicySchema>(); |
| 47 } | 47 } |
| 48 file = extension->path().AppendASCII(path); | 48 file = extension->path().AppendASCII(path); |
| 49 if (!base::PathExists(file)) { | 49 if (!base::PathExists(file)) { |
| 50 *error = | 50 *error = |
| 51 base::StringPrintf("File does not exist: %s", file.value().c_str()); | 51 base::StringPrintf("File does not exist: %s", file.value().c_str()); |
| 52 return scoped_ptr<policy::PolicySchema>(); | 52 return scoped_ptr<policy::PolicySchema>(); |
| 53 } | 53 } |
| 54 std::string content; | 54 std::string content; |
| 55 if (!file_util::ReadFileToString(file, &content)) { | 55 if (!base::ReadFileToString(file, &content)) { |
| 56 *error = base::StringPrintf("Can't read %s", file.value().c_str()); | 56 *error = base::StringPrintf("Can't read %s", file.value().c_str()); |
| 57 return scoped_ptr<policy::PolicySchema>(); | 57 return scoped_ptr<policy::PolicySchema>(); |
| 58 } | 58 } |
| 59 return policy::PolicySchema::Parse(content, error); | 59 return policy::PolicySchema::Parse(content, error); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool StorageSchemaManifestHandler::Parse(Extension* extension, | 62 bool StorageSchemaManifestHandler::Parse(Extension* extension, |
| 63 string16* error) { | 63 string16* error) { |
| 64 std::string path; | 64 std::string path; |
| 65 if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) { | 65 if (!extension->manifest()->GetString(kStorageManagedSchema, &path)) { |
| 66 *error = ASCIIToUTF16( | 66 *error = ASCIIToUTF16( |
| 67 base::StringPrintf("%s must be a string", kStorageManagedSchema)); | 67 base::StringPrintf("%s must be a string", kStorageManagedSchema)); |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool StorageSchemaManifestHandler::Validate( | 73 bool StorageSchemaManifestHandler::Validate( |
| 74 const Extension* extension, | 74 const Extension* extension, |
| 75 std::string* error, | 75 std::string* error, |
| 76 std::vector<InstallWarning>* warnings) const { | 76 std::vector<InstallWarning>* warnings) const { |
| 77 return !!GetSchema(extension, error); | 77 return !!GetSchema(extension, error); |
| 78 } | 78 } |
| 79 | 79 |
| 80 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { | 80 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { |
| 81 return SingleKey(kStorageManagedSchema); | 81 return SingleKey(kStorageManagedSchema); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace extensions | 84 } // namespace extensions |
| OLD | NEW |