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

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

Issue 10871034: Make all quota-exceeding messages in the storage API explain what the failure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update... the other error message Created 8 years, 3 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 | Annotate | Revision Log
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/extension_function_dispatcher.h" 5 #include "chrome/browser/extensions/extension_function_dispatcher.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if (!function_io) { 145 if (!function_io) {
146 NOTREACHED(); 146 NOTREACHED();
147 return; 147 return;
148 } 148 }
149 function_io->set_ipc_sender(ipc_sender, routing_id); 149 function_io->set_ipc_sender(ipc_sender, routing_id);
150 function_io->set_extension_info_map(extension_info_map); 150 function_io->set_extension_info_map(extension_info_map);
151 function->set_include_incognito( 151 function->set_include_incognito(
152 extension_info_map->IsIncognitoEnabled(extension->id())); 152 extension_info_map->IsIncognitoEnabled(extension->id()));
153 153
154 ExtensionsQuotaService* quota = extension_info_map->GetQuotaService(); 154 ExtensionsQuotaService* quota = extension_info_map->GetQuotaService();
155 if (quota->Assess(extension->id(), function, &params.arguments, 155 std::string violation_error = quota->Assess(extension->id(),
156 base::TimeTicks::Now())) { 156 function,
157 &params.arguments,
158 base::TimeTicks::Now());
159 if (violation_error.empty()) {
157 function->Run(); 160 function->Run();
158 LogSuccess(extension, params); 161 LogSuccess(extension, params);
159 } else { 162 } else {
160 function->OnQuotaExceeded(); 163 function->OnQuotaExceeded(violation_error);
161 LogFailure(extension, params.name, kQuotaExceeded); 164 LogFailure(extension, params.name, kQuotaExceeded);
162 } 165 }
163 } 166 }
164 167
165 ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(Profile* profile, 168 ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(Profile* profile,
166 Delegate* delegate) 169 Delegate* delegate)
167 : profile_(profile), 170 : profile_(profile),
168 delegate_(delegate) { 171 delegate_(delegate) {
169 } 172 }
170 173
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 function->AsUIThreadExtensionFunction(); 205 function->AsUIThreadExtensionFunction();
203 if (!function_ui) { 206 if (!function_ui) {
204 NOTREACHED(); 207 NOTREACHED();
205 return; 208 return;
206 } 209 }
207 function_ui->set_dispatcher(AsWeakPtr()); 210 function_ui->set_dispatcher(AsWeakPtr());
208 function_ui->set_profile(profile_); 211 function_ui->set_profile(profile_);
209 function->set_include_incognito(service->CanCrossIncognito(extension)); 212 function->set_include_incognito(service->CanCrossIncognito(extension));
210 213
211 ExtensionsQuotaService* quota = service->quota_service(); 214 ExtensionsQuotaService* quota = service->quota_service();
212 if (quota->Assess(extension->id(), function, &params.arguments, 215 std::string violation_error = quota->Assess(extension->id(),
213 base::TimeTicks::Now())) { 216 function,
217 &params.arguments,
218 base::TimeTicks::Now());
219 if (violation_error.empty()) {
214 // See crbug.com/39178. 220 // See crbug.com/39178.
215 ExternalProtocolHandler::PermitLaunchUrl(); 221 ExternalProtocolHandler::PermitLaunchUrl();
216 222
217 function->Run(); 223 function->Run();
218 LogSuccess(extension, params); 224 LogSuccess(extension, params);
219 } else { 225 } else {
220 function->OnQuotaExceeded(); 226 function->OnQuotaExceeded(violation_error);
221 LogFailure(extension, params.name, kQuotaExceeded); 227 LogFailure(extension, params.name, kQuotaExceeded);
222 } 228 }
223 229
224 // Check if extension was uninstalled by management.uninstall. 230 // Check if extension was uninstalled by management.uninstall.
225 if (!service->extensions()->GetByID(params.extension_id)) 231 if (!service->extensions()->GetByID(params.extension_id))
226 return; 232 return;
227 233
228 // We only adjust the keepalive count for UIThreadExtensionFunction for 234 // We only adjust the keepalive count for UIThreadExtensionFunction for
229 // now, largely for simplicity's sake. This is OK because currently, only 235 // now, largely for simplicity's sake. This is OK because currently, only
230 // the webRequest API uses IOThreadExtensionFunction, and that API is not 236 // the webRequest API uses IOThreadExtensionFunction, and that API is not
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 298 }
293 299
294 // static 300 // static
295 void ExtensionFunctionDispatcher::SendAccessDenied( 301 void ExtensionFunctionDispatcher::SendAccessDenied(
296 IPC::Sender* ipc_sender, int routing_id, int request_id) { 302 IPC::Sender* ipc_sender, int routing_id, int request_id) {
297 ListValue empty_list; 303 ListValue empty_list;
298 ipc_sender->Send(new ExtensionMsg_Response( 304 ipc_sender->Send(new ExtensionMsg_Response(
299 routing_id, request_id, false, empty_list, 305 routing_id, request_id, false, empty_list,
300 "Access to extension API denied.")); 306 "Access to extension API denied."));
301 } 307 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function.cc ('k') | chrome/browser/extensions/extensions_quota_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698