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/browser/extensions/api/storage/storage_schema_manifest_handler.
h" | 5 #include "chrome/browser/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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 scoped_refptr<Extension> CreateExtension(const std::string& schema) { | 42 scoped_refptr<Extension> CreateExtension(const std::string& schema) { |
43 std::string error; | 43 std::string error; |
44 scoped_refptr<Extension> extension = Extension::Create( | 44 scoped_refptr<Extension> extension = Extension::Create( |
45 temp_dir_.path(), Manifest::UNPACKED, manifest_, | 45 temp_dir_.path(), Manifest::UNPACKED, manifest_, |
46 Extension::NO_FLAGS, "", &error); | 46 Extension::NO_FLAGS, "", &error); |
47 if (!extension.get()) | 47 if (!extension.get()) |
48 return NULL; | 48 return NULL; |
49 base::FilePath schema_path = temp_dir_.path().AppendASCII("schema.json"); | 49 base::FilePath schema_path = temp_dir_.path().AppendASCII("schema.json"); |
50 if (schema.empty()) { | 50 if (schema.empty()) { |
51 file_util::Delete(schema_path, false); | 51 base::Delete(schema_path, false); |
52 } else { | 52 } else { |
53 if (file_util::WriteFile(schema_path, schema.data(), schema.size()) != | 53 if (file_util::WriteFile(schema_path, schema.data(), schema.size()) != |
54 static_cast<int>(schema.size())) { | 54 static_cast<int>(schema.size())) { |
55 return NULL; | 55 return NULL; |
56 } | 56 } |
57 } | 57 } |
58 return extension; | 58 return extension; |
59 } | 59 } |
60 | 60 |
61 testing::AssertionResult Validates(const std::string& schema) { | 61 testing::AssertionResult Validates(const std::string& schema) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 // All good now. | 155 // All good now. |
156 EXPECT_TRUE(Validates( | 156 EXPECT_TRUE(Validates( |
157 "{" | 157 "{" |
158 " \"$schema\": \"http://json-schema.org/draft-03/schema#\"," | 158 " \"$schema\": \"http://json-schema.org/draft-03/schema#\"," |
159 " \"type\": \"object\"" | 159 " \"type\": \"object\"" |
160 "}")); | 160 "}")); |
161 } | 161 } |
162 | 162 |
163 } // namespace extensions | 163 } // namespace extensions |
OLD | NEW |