| OLD | NEW |
| 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 "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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" | 15 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" |
| 16 #include "chrome/browser/extensions/activity_log/activity_log.h" | 16 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 17 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" | 17 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat
e_api.h" |
| 18 #include "chrome/browser/extensions/extension_function_registry.h" | 18 #include "chrome/browser/extensions/extension_function_registry.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_system.h" | 20 #include "chrome/browser/extensions/extension_system.h" |
| 21 #include "chrome/browser/extensions/extension_util.h" | 21 #include "chrome/browser/extensions/extension_util.h" |
| 22 #include "chrome/browser/extensions/extension_web_ui.h" | 22 #include "chrome/browser/extensions/extension_web_ui.h" |
| 23 #include "chrome/browser/external_protocol/external_protocol_handler.h" | |
| 24 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 23 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 25 #include "chrome/common/extensions/extension_messages.h" | 24 #include "chrome/common/extensions/extension_messages.h" |
| 26 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 29 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 30 #include "content/public/browser/render_view_host.h" | 29 #include "content/public/browser/render_view_host.h" |
| 31 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
| 32 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/browser/web_contents_observer.h" | 32 #include "content/public/browser/web_contents_observer.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 if (!CheckPermissions(function.get(), extension, params, callback)) | 375 if (!CheckPermissions(function.get(), extension, params, callback)) |
| 377 return; | 376 return; |
| 378 | 377 |
| 379 extensions::QuotaService* quota = service->quota_service(); | 378 extensions::QuotaService* quota = service->quota_service(); |
| 380 std::string violation_error = quota->Assess(extension->id(), | 379 std::string violation_error = quota->Assess(extension->id(), |
| 381 function.get(), | 380 function.get(), |
| 382 ¶ms.arguments, | 381 ¶ms.arguments, |
| 383 base::TimeTicks::Now()); | 382 base::TimeTicks::Now()); |
| 384 if (violation_error.empty()) { | 383 if (violation_error.empty()) { |
| 385 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); | 384 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); |
| 386 | |
| 387 // See crbug.com/39178. | |
| 388 ExternalProtocolHandler::PermitLaunchUrl(); | |
| 389 LogSuccess(extension->id(), params.name, args.Pass(), browser_context_); | 385 LogSuccess(extension->id(), params.name, args.Pass(), browser_context_); |
| 390 function->Run(); | 386 function->Run(); |
| 391 } else { | 387 } else { |
| 392 function->OnQuotaExceeded(violation_error); | 388 function->OnQuotaExceeded(violation_error); |
| 393 } | 389 } |
| 394 | 390 |
| 395 // Note: do not access |this| after this point. We may have been deleted | 391 // Note: do not access |this| after this point. We may have been deleted |
| 396 // if function->Run() ended up closing the tab that owns us. | 392 // if function->Run() ended up closing the tab that owns us. |
| 397 | 393 |
| 398 // Check if extension was uninstalled by management.uninstall. | 394 // Check if extension was uninstalled by management.uninstall. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 return function; | 506 return function; |
| 511 } | 507 } |
| 512 | 508 |
| 513 // static | 509 // static |
| 514 void ExtensionFunctionDispatcher::SendAccessDenied( | 510 void ExtensionFunctionDispatcher::SendAccessDenied( |
| 515 const ExtensionFunction::ResponseCallback& callback) { | 511 const ExtensionFunction::ResponseCallback& callback) { |
| 516 base::ListValue empty_list; | 512 base::ListValue empty_list; |
| 517 callback.Run(ExtensionFunction::FAILED, empty_list, | 513 callback.Run(ExtensionFunction::FAILED, empty_list, |
| 518 "Access to extension API denied."); | 514 "Access to extension API denied."); |
| 519 } | 515 } |
| OLD | NEW |