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

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

Issue 2630753003: Separate validation failures from other failures in ExecuteCodeFunction. (Closed)
Patch Set: address comments Created 3 years, 11 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
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 : ScriptExecutor::NO_RESULT, 156 : ScriptExecutor::NO_RESULT,
157 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); 157 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this));
158 return true; 158 return true;
159 } 159 }
160 160
161 bool ExecuteCodeFunction::HasPermission() { 161 bool ExecuteCodeFunction::HasPermission() {
162 return true; 162 return true;
163 } 163 }
164 164
165 bool ExecuteCodeFunction::RunAsync() { 165 bool ExecuteCodeFunction::RunAsync() {
166 EXTENSION_FUNCTION_VALIDATE(Init()); 166 InitResult init_result = Init();
167 EXTENSION_FUNCTION_VALIDATE(init_result != VALIDATION_FAILURE);
168 if (init_result == FAILURE) {
169 if (init_error_)
170 SetError(init_error_.value());
171 return false;
172 }
167 173
168 if (!details_->code.get() && !details_->file.get()) { 174 if (!details_->code.get() && !details_->file.get()) {
169 error_ = kNoCodeOrFileToExecuteError; 175 error_ = kNoCodeOrFileToExecuteError;
170 return false; 176 return false;
171 } 177 }
172 if (details_->code.get() && details_->file.get()) { 178 if (details_->code.get() && details_->file.get()) {
173 error_ = kMoreThanOneValuesError; 179 error_ = kMoreThanOneValuesError;
174 return false; 180 return false;
175 } 181 }
176 182
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 const base::ListValue& result) { 251 const base::ListValue& result) {
246 if (!error.empty()) 252 if (!error.empty())
247 SetError(error); 253 SetError(error);
248 254
249 SendResponse(error.empty()); 255 SendResponse(error.empty());
250 } 256 }
251 257
252 } // namespace extensions 258 } // namespace extensions
253 259
254 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ 260 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/execute_code_function.h ('k') | extensions/browser/api/guest_view/web_view/web_view_internal_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698