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

Side by Side Diff: extensions/browser/api/execute_code_function.cc

Issue 615703002: Verify that ComponentExtensionResourceManager exists before using it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_
6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_
7 7
8 #include "extensions/browser/api/execute_code_function.h" 8 #include "extensions/browser/api/execute_code_function.h"
9 9
10 #include "extensions/browser/component_extension_resource_manager.h" 10 #include "extensions/browser/component_extension_resource_manager.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (!details_->file.get()) 199 if (!details_->file.get())
200 return false; 200 return false;
201 resource_ = extension()->GetResource(*details_->file); 201 resource_ = extension()->GetResource(*details_->file);
202 202
203 if (resource_.extension_root().empty() || resource_.relative_path().empty()) { 203 if (resource_.extension_root().empty() || resource_.relative_path().empty()) {
204 error_ = kNoCodeOrFileToExecuteError; 204 error_ = kNoCodeOrFileToExecuteError;
205 return false; 205 return false;
206 } 206 }
207 207
208 int resource_id; 208 int resource_id;
209 if (ExtensionsBrowserClient::Get() 209 if (ExtensionsBrowserClient::Get()->GetComponentExtensionResourceManager() &&
Ken Rockot(use gerrit already) 2014/09/29 21:56:32 nit: Retain the value of ExtensionsBrowserClient::
lfg 2014/09/29 22:12:44 Done.
210 ExtensionsBrowserClient::Get()
210 ->GetComponentExtensionResourceManager() 211 ->GetComponentExtensionResourceManager()
211 ->IsComponentExtensionResource(resource_.extension_root(), 212 ->IsComponentExtensionResource(resource_.extension_root(),
212 resource_.relative_path(), 213 resource_.relative_path(),
213 &resource_id)) { 214 &resource_id)) {
214 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 215 const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
215 DidLoadFile(true, rb.GetRawDataResource(resource_id).as_string()); 216 DidLoadFile(true, rb.GetRawDataResource(resource_id).as_string());
216 } else { 217 } else {
217 scoped_refptr<FileReader> file_reader(new FileReader( 218 scoped_refptr<FileReader> file_reader(new FileReader(
218 resource_, base::Bind(&ExecuteCodeFunction::DidLoadFile, this))); 219 resource_, base::Bind(&ExecuteCodeFunction::DidLoadFile, this)));
219 file_reader->Start(); 220 file_reader->Start();
220 } 221 }
221 222
222 return true; 223 return true;
223 } 224 }
224 225
225 void ExecuteCodeFunction::OnExecuteCodeFinished(const std::string& error, 226 void ExecuteCodeFunction::OnExecuteCodeFinished(const std::string& error,
226 const GURL& on_url, 227 const GURL& on_url,
227 const base::ListValue& result) { 228 const base::ListValue& result) {
228 if (!error.empty()) 229 if (!error.empty())
229 SetError(error); 230 SetError(error);
230 231
231 SendResponse(error.empty()); 232 SendResponse(error.empty());
232 } 233 }
233 234
234 } // namespace extensions 235 } // namespace extensions
235 236
236 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ 237 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698