| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_test_util.h" | 5 #include "chrome/common/extensions/extension_test_util.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 10 #include "base/values.h" | 12 #include "base/values.h" |
| 11 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 12 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
| 13 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 17 |
| 16 using extensions::Extension; | 18 using extensions::Extension; |
| 17 using extensions::Manifest; | 19 using extensions::Manifest; |
| 18 | 20 |
| 19 namespace extension_test_util { | 21 namespace extension_test_util { |
| 20 | 22 |
| 21 scoped_refptr<Extension> LoadManifestUnchecked(const std::string& dir, | 23 scoped_refptr<Extension> LoadManifestUnchecked(const std::string& dir, |
| 22 const std::string& test_file, | 24 const std::string& test_file, |
| 23 Manifest::Location location, | 25 Manifest::Location location, |
| 24 int extra_flags, | 26 int extra_flags, |
| 25 const std::string& id, | 27 const std::string& id, |
| 26 std::string* error) { | 28 std::string* error) { |
| 27 base::FilePath path; | 29 base::FilePath path; |
| 28 PathService::Get(chrome::DIR_TEST_DATA, &path); | 30 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 29 path = path.AppendASCII("extensions") | 31 path = path.AppendASCII("extensions") |
| 30 .AppendASCII(dir) | 32 .AppendASCII(dir) |
| 31 .AppendASCII(test_file); | 33 .AppendASCII(test_file); |
| 32 | 34 |
| 33 JSONFileValueDeserializer deserializer(path); | 35 JSONFileValueDeserializer deserializer(path); |
| 34 scoped_ptr<base::Value> result = deserializer.Deserialize(NULL, error); | 36 std::unique_ptr<base::Value> result = deserializer.Deserialize(NULL, error); |
| 35 if (!result) | 37 if (!result) |
| 36 return NULL; | 38 return NULL; |
| 37 const base::DictionaryValue* dict; | 39 const base::DictionaryValue* dict; |
| 38 CHECK(result->GetAsDictionary(&dict)); | 40 CHECK(result->GetAsDictionary(&dict)); |
| 39 | 41 |
| 40 scoped_refptr<Extension> extension = Extension::Create( | 42 scoped_refptr<Extension> extension = Extension::Create( |
| 41 path.DirName(), location, *dict, extra_flags, id, error); | 43 path.DirName(), location, *dict, extra_flags, id, error); |
| 42 return extension; | 44 return extension; |
| 43 } | 45 } |
| 44 | 46 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 const std::string& test_file) { | 75 const std::string& test_file) { |
| 74 return LoadManifest(dir, test_file, Extension::NO_FLAGS); | 76 return LoadManifest(dir, test_file, Extension::NO_FLAGS); |
| 75 } | 77 } |
| 76 | 78 |
| 77 scoped_refptr<Extension> LoadManifest(const std::string& dir, | 79 scoped_refptr<Extension> LoadManifest(const std::string& dir, |
| 78 const std::string& test_file) { | 80 const std::string& test_file) { |
| 79 return LoadManifest(dir, test_file, Extension::NO_FLAGS); | 81 return LoadManifest(dir, test_file, Extension::NO_FLAGS); |
| 80 } | 82 } |
| 81 | 83 |
| 82 } // namespace extension_test_util | 84 } // namespace extension_test_util |
| OLD | NEW |