| 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 28 matching lines...) Expand all Loading... |
| 39 std::string error; | 39 std::string error; |
| 40 scoped_refptr<Extension> extension = Extension::Create( | 40 scoped_refptr<Extension> extension = Extension::Create( |
| 41 temp_dir_.path(), Manifest::UNPACKED, manifest_, | 41 temp_dir_.path(), Manifest::UNPACKED, manifest_, |
| 42 Extension::NO_FLAGS, "", &error); | 42 Extension::NO_FLAGS, "", &error); |
| 43 if (!extension.get()) | 43 if (!extension.get()) |
| 44 return NULL; | 44 return NULL; |
| 45 base::FilePath schema_path = temp_dir_.path().AppendASCII("schema.json"); | 45 base::FilePath schema_path = temp_dir_.path().AppendASCII("schema.json"); |
| 46 if (schema.empty()) { | 46 if (schema.empty()) { |
| 47 base::DeleteFile(schema_path, false); | 47 base::DeleteFile(schema_path, false); |
| 48 } else { | 48 } else { |
| 49 if (file_util::WriteFile(schema_path, schema.data(), schema.size()) != | 49 if (base::WriteFile(schema_path, schema.data(), schema.size()) != |
| 50 static_cast<int>(schema.size())) { | 50 static_cast<int>(schema.size())) { |
| 51 return NULL; | 51 return NULL; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 return extension; | 54 return extension; |
| 55 } | 55 } |
| 56 | 56 |
| 57 testing::AssertionResult Validates(const std::string& schema) { | 57 testing::AssertionResult Validates(const std::string& schema) { |
| 58 scoped_refptr<Extension> extension = CreateExtension(schema); | 58 scoped_refptr<Extension> extension = CreateExtension(schema); |
| 59 if (!extension.get()) | 59 if (!extension.get()) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 // All good now. | 142 // All good now. |
| 143 EXPECT_TRUE(Validates( | 143 EXPECT_TRUE(Validates( |
| 144 "{" | 144 "{" |
| 145 " \"$schema\": \"http://json-schema.org/draft-03/schema#\"," | 145 " \"$schema\": \"http://json-schema.org/draft-03/schema#\"," |
| 146 " \"type\": \"object\"" | 146 " \"type\": \"object\"" |
| 147 "}")); | 147 "}")); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace extensions | 150 } // namespace extensions |
| OLD | NEW |