OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void UninstallExtension(const FilePath& extensions_dir, | 81 void UninstallExtension(const FilePath& extensions_dir, |
82 const std::string& id) { | 82 const std::string& id) { |
83 // We don't care about the return value. If this fails (and it can, due to | 83 // We don't care about the return value. If this fails (and it can, due to |
84 // plugins that aren't unloaded yet, it will get cleaned up by | 84 // plugins that aren't unloaded yet, it will get cleaned up by |
85 // ExtensionService::GarbageCollectExtensions). | 85 // ExtensionService::GarbageCollectExtensions). |
86 file_util::Delete(extensions_dir.AppendASCII(id), true); // recursive. | 86 file_util::Delete(extensions_dir.AppendASCII(id), true); // recursive. |
87 } | 87 } |
88 | 88 |
89 scoped_refptr<Extension> LoadExtension(const FilePath& extension_path, | 89 scoped_refptr<Extension> LoadExtension(const FilePath& extension_path, |
90 Extension::Location location, | 90 Extension::Location location, |
91 bool require_key, | 91 int flags, |
92 bool strict_error_checks, | |
93 std::string* error) { | 92 std::string* error) { |
94 FilePath manifest_path = | 93 FilePath manifest_path = |
95 extension_path.Append(Extension::kManifestFilename); | 94 extension_path.Append(Extension::kManifestFilename); |
96 if (!file_util::PathExists(manifest_path)) { | 95 if (!file_util::PathExists(manifest_path)) { |
97 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); | 96 *error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); |
98 return NULL; | 97 return NULL; |
99 } | 98 } |
100 | 99 |
101 JSONFileValueSerializer serializer(manifest_path); | 100 JSONFileValueSerializer serializer(manifest_path); |
102 scoped_ptr<Value> root(serializer.Deserialize(NULL, error)); | 101 scoped_ptr<Value> root(serializer.Deserialize(NULL, error)); |
(...skipping 18 matching lines...) Expand all Loading... |
121 } | 120 } |
122 | 121 |
123 DictionaryValue* manifest = static_cast<DictionaryValue*>(root.get()); | 122 DictionaryValue* manifest = static_cast<DictionaryValue*>(root.get()); |
124 if (!extension_l10n_util::LocalizeExtension(extension_path, manifest, error)) | 123 if (!extension_l10n_util::LocalizeExtension(extension_path, manifest, error)) |
125 return NULL; | 124 return NULL; |
126 | 125 |
127 scoped_refptr<Extension> extension(Extension::Create( | 126 scoped_refptr<Extension> extension(Extension::Create( |
128 extension_path, | 127 extension_path, |
129 location, | 128 location, |
130 *manifest, | 129 *manifest, |
131 require_key, | 130 flags, |
132 strict_error_checks, | |
133 error)); | 131 error)); |
134 if (!extension.get()) | 132 if (!extension.get()) |
135 return NULL; | 133 return NULL; |
136 | 134 |
137 if (!ValidateExtension(extension.get(), error)) | 135 if (!ValidateExtension(extension.get(), error)) |
138 return NULL; | 136 return NULL; |
139 | 137 |
140 return extension; | 138 return extension; |
141 } | 139 } |
142 | 140 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 return temp_path; | 611 return temp_path; |
614 | 612 |
615 return FilePath(); | 613 return FilePath(); |
616 } | 614 } |
617 | 615 |
618 void DeleteFile(const FilePath& path, bool recursive) { | 616 void DeleteFile(const FilePath& path, bool recursive) { |
619 file_util::Delete(path, recursive); | 617 file_util::Delete(path, recursive); |
620 } | 618 } |
621 | 619 |
622 } // namespace extension_file_util | 620 } // namespace extension_file_util |
OLD | NEW |