Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: chrome/browser/extensions/component_loader.cc

Issue 2252253003: Remove ComponentLoader's unnecessary string copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698