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/browser/extensions/component_loader.h" | 5 #include "chrome/browser/extensions/component_loader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 ComponentExtensionInfo info(manifest, root_directory); | 184 ComponentExtensionInfo info(manifest, root_directory); |
185 return info.extension_id; | 185 return info.extension_id; |
186 } | 186 } |
187 | 187 |
188 std::string ComponentLoader::Add(int manifest_resource_id, | 188 std::string ComponentLoader::Add(int manifest_resource_id, |
189 const base::FilePath& root_directory) { | 189 const base::FilePath& root_directory) { |
190 if (!ignore_whitelist_for_testing_ && | 190 if (!ignore_whitelist_for_testing_ && |
191 !IsComponentExtensionWhitelisted(manifest_resource_id)) | 191 !IsComponentExtensionWhitelisted(manifest_resource_id)) |
192 return std::string(); | 192 return std::string(); |
193 | 193 |
194 std::string manifest_contents = | 194 base::StringPiece manifest_contents = |
195 ResourceBundle::GetSharedInstance().GetRawDataResource( | 195 ResourceBundle::GetSharedInstance().GetRawDataResource( |
196 manifest_resource_id).as_string(); | 196 manifest_resource_id); |
197 return Add(manifest_contents, root_directory, true); | 197 return Add(manifest_contents, root_directory, true); |
198 } | 198 } |
199 | 199 |
200 std::string ComponentLoader::Add(const std::string& manifest_contents, | 200 std::string ComponentLoader::Add(const base::StringPiece& manifest_contents, |
201 const base::FilePath& root_directory) { | 201 const base::FilePath& root_directory) { |
202 return Add(manifest_contents, root_directory, false); | 202 return Add(manifest_contents, root_directory, false); |
203 } | 203 } |
204 | 204 |
205 std::string ComponentLoader::Add(const std::string& manifest_contents, | 205 std::string ComponentLoader::Add(const base::StringPiece& manifest_contents, |
206 const base::FilePath& root_directory, | 206 const base::FilePath& root_directory, |
207 bool skip_whitelist) { | 207 bool skip_whitelist) { |
208 // The Value is kept for the lifetime of the ComponentLoader. This is | 208 // The Value is kept for the lifetime of the ComponentLoader. This is |
209 // required in case LoadAll() is called again. | 209 // required in case LoadAll() is called again. |
210 base::DictionaryValue* manifest = ParseManifest(manifest_contents); | 210 base::DictionaryValue* manifest = ParseManifest(manifest_contents); |
211 if (manifest) | 211 if (manifest) |
212 return Add(manifest, root_directory, skip_whitelist); | 212 return Add(manifest, root_directory, skip_whitelist); |
213 return std::string(); | 213 return std::string(); |
214 } | 214 } |
215 | 215 |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 manifest.release(), | 718 manifest.release(), |
719 root_directory, | 719 root_directory, |
720 false); | 720 false); |
721 CHECK_EQ(extension_id, actual_extension_id); | 721 CHECK_EQ(extension_id, actual_extension_id); |
722 if (!done_cb.is_null()) | 722 if (!done_cb.is_null()) |
723 done_cb.Run(); | 723 done_cb.Run(); |
724 } | 724 } |
725 #endif | 725 #endif |
726 | 726 |
727 } // namespace extensions | 727 } // namespace extensions |
OLD | NEW |