| 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 "extensions/common/file_util.h" | 5 #include "extensions/common/file_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 return extension; | 42 return extension; |
| 43 } | 43 } |
| 44 | 44 |
| 45 scoped_refptr<Extension> LoadExtensionManifest( | 45 scoped_refptr<Extension> LoadExtensionManifest( |
| 46 const std::string& manifest_value, | 46 const std::string& manifest_value, |
| 47 const base::FilePath& manifest_dir, | 47 const base::FilePath& manifest_dir, |
| 48 Manifest::Location location, | 48 Manifest::Location location, |
| 49 int extra_flags, | 49 int extra_flags, |
| 50 std::string* error) { | 50 std::string* error) { |
| 51 JSONStringValueDeserializer deserializer(manifest_value); | 51 JSONStringValueDeserializer deserializer(manifest_value); |
| 52 scoped_ptr<base::Value> result = deserializer.Deserialize(NULL, error); | 52 std::unique_ptr<base::Value> result = deserializer.Deserialize(NULL, error); |
| 53 if (!result.get()) | 53 if (!result.get()) |
| 54 return NULL; | 54 return NULL; |
| 55 CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); | 55 CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); |
| 56 return LoadExtensionManifest( | 56 return LoadExtensionManifest( |
| 57 *base::DictionaryValue::From(std::move(result)).get(), manifest_dir, | 57 *base::DictionaryValue::From(std::move(result)).get(), manifest_dir, |
| 58 location, extra_flags, error); | 58 location, extra_flags, error); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 std::vector<extensions::InstallWarning> warnings; | 277 std::vector<extensions::InstallWarning> warnings; |
| 278 EXPECT_TRUE(file_util::ValidateExtension(extension.get(), &error, &warnings)) | 278 EXPECT_TRUE(file_util::ValidateExtension(extension.get(), &error, &warnings)) |
| 279 << error; | 279 << error; |
| 280 EXPECT_EQ(0U, warnings.size()); | 280 EXPECT_EQ(0U, warnings.size()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { | 283 TEST_F(FileUtilTest, BackgroundScriptsMustExist) { |
| 284 base::ScopedTempDir temp; | 284 base::ScopedTempDir temp; |
| 285 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 285 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| 286 | 286 |
| 287 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 287 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 288 value->SetString("name", "test"); | 288 value->SetString("name", "test"); |
| 289 value->SetString("version", "1"); | 289 value->SetString("version", "1"); |
| 290 value->SetInteger("manifest_version", 1); | 290 value->SetInteger("manifest_version", 1); |
| 291 | 291 |
| 292 base::ListValue* scripts = new base::ListValue(); | 292 base::ListValue* scripts = new base::ListValue(); |
| 293 scripts->Append(new base::StringValue("foo.js")); | 293 scripts->Append(new base::StringValue("foo.js")); |
| 294 value->Set("background.scripts", scripts); | 294 value->Set("background.scripts", scripts); |
| 295 | 295 |
| 296 std::string error; | 296 std::string error; |
| 297 std::vector<extensions::InstallWarning> warnings; | 297 std::vector<extensions::InstallWarning> warnings; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 base::FilePath actual_path = | 543 base::FilePath actual_path = |
| 544 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); | 544 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); |
| 545 EXPECT_EQ(expected_path.value(), actual_path.value()) << | 545 EXPECT_EQ(expected_path.value(), actual_path.value()) << |
| 546 " For the path " << url; | 546 " For the path " << url; |
| 547 } | 547 } |
| 548 // Remove temp files. | 548 // Remove temp files. |
| 549 ASSERT_TRUE(base::DeleteFile(root_path, true)); | 549 ASSERT_TRUE(base::DeleteFile(root_path, true)); |
| 550 } | 550 } |
| 551 | 551 |
| 552 } // namespace extensions | 552 } // namespace extensions |
| OLD | NEW |