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_util.h" | 20 #include "chrome/browser/extensions/extension_util.h" |
21 #include "chrome/browser/extensions/extension_web_ui.h" | 21 #include "chrome/browser/extensions/extension_web_ui.h" |
22 #include "chrome/browser/external_protocol/external_protocol_handler.h" | |
23 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 22 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
24 #include "chrome/common/extensions/extension_messages.h" | 23 #include "chrome/common/extensions/extension_messages.h" |
25 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
26 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
28 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
29 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
30 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
31 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
32 #include "content/public/browser/web_contents_observer.h" | 31 #include "content/public/browser/web_contents_observer.h" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 if (!CheckPermissions(function.get(), extension, params, callback)) | 374 if (!CheckPermissions(function.get(), extension, params, callback)) |
376 return; | 375 return; |
377 | 376 |
378 extensions::QuotaService* quota = service->quota_service(); | 377 extensions::QuotaService* quota = service->quota_service(); |
379 std::string violation_error = quota->Assess(extension->id(), | 378 std::string violation_error = quota->Assess(extension->id(), |
380 function.get(), | 379 function.get(), |
381 ¶ms.arguments, | 380 ¶ms.arguments, |
382 base::TimeTicks::Now()); | 381 base::TimeTicks::Now()); |
383 if (violation_error.empty()) { | 382 if (violation_error.empty()) { |
384 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); | 383 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); |
385 | |
386 // See crbug.com/39178. | |
387 ExternalProtocolHandler::PermitLaunchUrl(); | |
not at google - send to devlin
2014/02/01 02:02:54
I wonder whether a simpler fix to this would be to
| |
388 LogSuccess(extension->id(), params.name, args.Pass(), browser_context_); | 384 LogSuccess(extension->id(), params.name, args.Pass(), browser_context_); |
389 function->Run(); | 385 function->Run(); |
390 } else { | 386 } else { |
391 function->OnQuotaExceeded(violation_error); | 387 function->OnQuotaExceeded(violation_error); |
392 } | 388 } |
393 | 389 |
394 // 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 |
395 // if function->Run() ended up closing the tab that owns us. | 391 // if function->Run() ended up closing the tab that owns us. |
396 | 392 |
397 // Check if extension was uninstalled by management.uninstall. | 393 // Check if extension was uninstalled by management.uninstall. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 return function; | 505 return function; |
510 } | 506 } |
511 | 507 |
512 // static | 508 // static |
513 void ExtensionFunctionDispatcher::SendAccessDenied( | 509 void ExtensionFunctionDispatcher::SendAccessDenied( |
514 const ExtensionFunction::ResponseCallback& callback) { | 510 const ExtensionFunction::ResponseCallback& callback) { |
515 base::ListValue empty_list; | 511 base::ListValue empty_list; |
516 callback.Run(ExtensionFunction::FAILED, empty_list, | 512 callback.Run(ExtensionFunction::FAILED, empty_list, |
517 "Access to extension API denied."); | 513 "Access to extension API denied."); |
518 } | 514 } |
OLD | NEW |