OLD | NEW |
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 #include "extensions/browser/extension_function_dispatcher.h" | 5 #include "extensions/browser/extension_function_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 ¶ms.arguments, | 267 ¶ms.arguments, |
268 base::TimeTicks::Now()); | 268 base::TimeTicks::Now()); |
269 if (violation_error.empty()) { | 269 if (violation_error.empty()) { |
270 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); | 270 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); |
271 NotifyApiFunctionCalled(extension->id(), | 271 NotifyApiFunctionCalled(extension->id(), |
272 params.name, | 272 params.name, |
273 args.Pass(), | 273 args.Pass(), |
274 static_cast<content::BrowserContext*>(profile_id)); | 274 static_cast<content::BrowserContext*>(profile_id)); |
275 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls", | 275 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls", |
276 function->histogram_value()); | 276 function->histogram_value()); |
277 function->Run(); | 277 function->Run()->Execute(); |
278 } else { | 278 } else { |
279 function->OnQuotaExceeded(violation_error); | 279 function->OnQuotaExceeded(violation_error); |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 ExtensionFunctionDispatcher::ExtensionFunctionDispatcher( | 283 ExtensionFunctionDispatcher::ExtensionFunctionDispatcher( |
284 content::BrowserContext* browser_context, | 284 content::BrowserContext* browser_context, |
285 Delegate* delegate) | 285 Delegate* delegate) |
286 : browser_context_(browser_context), | 286 : browser_context_(browser_context), |
287 delegate_(delegate) { | 287 delegate_(delegate) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 function.get(), | 375 function.get(), |
376 ¶ms.arguments, | 376 ¶ms.arguments, |
377 base::TimeTicks::Now()); | 377 base::TimeTicks::Now()); |
378 if (violation_error.empty()) { | 378 if (violation_error.empty()) { |
379 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); | 379 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); |
380 | 380 |
381 NotifyApiFunctionCalled( | 381 NotifyApiFunctionCalled( |
382 extension->id(), params.name, args.Pass(), browser_context_); | 382 extension->id(), params.name, args.Pass(), browser_context_); |
383 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls", | 383 UMA_HISTOGRAM_SPARSE_SLOWLY("Extensions.FunctionCalls", |
384 function->histogram_value()); | 384 function->histogram_value()); |
385 function->Run(); | 385 function->Run()->Execute(); |
386 } else { | 386 } else { |
387 function->OnQuotaExceeded(violation_error); | 387 function->OnQuotaExceeded(violation_error); |
388 } | 388 } |
389 | 389 |
390 // Note: do not access |this| after this point. We may have been deleted | 390 // Note: do not access |this| after this point. We may have been deleted |
391 // if function->Run() ended up closing the tab that owns us. | 391 // if function->Run() ended up closing the tab that owns us. |
392 | 392 |
393 // Check if extension was uninstalled by management.uninstall. | 393 // Check if extension was uninstalled by management.uninstall. |
394 if (!registry->enabled_extensions().GetByID(params.extension_id)) | 394 if (!registry->enabled_extensions().GetByID(params.extension_id)) |
395 return; | 395 return; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 508 |
509 // static | 509 // static |
510 void ExtensionFunctionDispatcher::SendAccessDenied( | 510 void ExtensionFunctionDispatcher::SendAccessDenied( |
511 const ExtensionFunction::ResponseCallback& callback) { | 511 const ExtensionFunction::ResponseCallback& callback) { |
512 base::ListValue empty_list; | 512 base::ListValue empty_list; |
513 callback.Run(ExtensionFunction::FAILED, empty_list, | 513 callback.Run(ExtensionFunction::FAILED, empty_list, |
514 "Access to extension API denied."); | 514 "Access to extension API denied."); |
515 } | 515 } |
516 | 516 |
517 } // namespace extensions | 517 } // namespace extensions |
OLD | NEW |