| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 std::string path; | 42 std::string path; |
| 43 extension->manifest()->GetString(kStorageManagedSchema, &path); | 43 extension->manifest()->GetString(kStorageManagedSchema, &path); |
| 44 base::FilePath file = base::FilePath::FromUTF8Unsafe(path); | 44 base::FilePath file = base::FilePath::FromUTF8Unsafe(path); |
| 45 if (file.IsAbsolute() || file.ReferencesParent()) { | 45 if (file.IsAbsolute() || file.ReferencesParent()) { |
| 46 *error = base::StringPrintf("%s must be a relative path without ..", | 46 *error = base::StringPrintf("%s must be a relative path without ..", |
| 47 kStorageManagedSchema); | 47 kStorageManagedSchema); |
| 48 return policy::Schema(); | 48 return policy::Schema(); |
| 49 } | 49 } |
| 50 file = extension->path().AppendASCII(path); | 50 file = extension->path().AppendASCII(path); |
| 51 if (!base::PathExists(file)) { | 51 if (!base::PathExists(file)) { |
| 52 *error = | 52 *error = base::StringPrintf("File does not exist: %" PRIsFP, |
| 53 base::StringPrintf("File does not exist: %s", file.value().c_str()); | 53 file.value().c_str()); |
| 54 return policy::Schema(); | 54 return policy::Schema(); |
| 55 } | 55 } |
| 56 std::string content; | 56 std::string content; |
| 57 if (!base::ReadFileToString(file, &content)) { | 57 if (!base::ReadFileToString(file, &content)) { |
| 58 *error = base::StringPrintf("Can't read %s", file.value().c_str()); | 58 *error = base::StringPrintf("Can't read %" PRIsFP, file.value().c_str()); |
| 59 return policy::Schema(); | 59 return policy::Schema(); |
| 60 } | 60 } |
| 61 return policy::Schema::Parse(content, error); | 61 return policy::Schema::Parse(content, error); |
| 62 } | 62 } |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 bool StorageSchemaManifestHandler::Parse(Extension* extension, | 65 bool StorageSchemaManifestHandler::Parse(Extension* extension, |
| 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)) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 87 #else | 87 #else |
| 88 return true; | 88 return true; |
| 89 #endif | 89 #endif |
| 90 } | 90 } |
| 91 | 91 |
| 92 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { | 92 const std::vector<std::string> StorageSchemaManifestHandler::Keys() const { |
| 93 return SingleKey(kStorageManagedSchema); | 93 return SingleKey(kStorageManagedSchema); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace extensions | 96 } // namespace extensions |
| OLD | NEW |