| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 ExtensionAPI::GetSharedInstance(), browser_context_, callback)); | 484 ExtensionAPI::GetSharedInstance(), browser_context_, callback)); |
| 485 if (!function.get()) | 485 if (!function.get()) |
| 486 return; | 486 return; |
| 487 | 487 |
| 488 UIThreadExtensionFunction* function_ui = | 488 UIThreadExtensionFunction* function_ui = |
| 489 function->AsUIThreadExtensionFunction(); | 489 function->AsUIThreadExtensionFunction(); |
| 490 if (!function_ui) { | 490 if (!function_ui) { |
| 491 NOTREACHED(); | 491 NOTREACHED(); |
| 492 return; | 492 return; |
| 493 } | 493 } |
| 494 function_ui->SetRenderFrameHost(render_frame_host); | 494 if (params.embedded_worker_id != -1) { |
| 495 function_ui->set_is_from_service_worker(true); |
| 496 } else { |
| 497 function_ui->SetRenderFrameHost(render_frame_host); |
| 498 } |
| 495 function_ui->set_dispatcher(AsWeakPtr()); | 499 function_ui->set_dispatcher(AsWeakPtr()); |
| 496 function_ui->set_browser_context(browser_context_); | 500 function_ui->set_browser_context(browser_context_); |
| 497 if (extension && | 501 if (extension && |
| 498 ExtensionsBrowserClient::Get()->CanExtensionCrossIncognito( | 502 ExtensionsBrowserClient::Get()->CanExtensionCrossIncognito( |
| 499 extension, browser_context_)) { | 503 extension, browser_context_)) { |
| 500 function->set_include_incognito(true); | 504 function->set_include_incognito(true); |
| 501 } | 505 } |
| 502 | 506 |
| 503 if (!CheckPermissions(function.get(), params, callback)) | 507 if (!CheckPermissions(function.get(), params, callback)) |
| 504 return; | 508 return; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 // static | 655 // static |
| 652 void ExtensionFunctionDispatcher::SendAccessDenied( | 656 void ExtensionFunctionDispatcher::SendAccessDenied( |
| 653 const ExtensionFunction::ResponseCallback& callback, | 657 const ExtensionFunction::ResponseCallback& callback, |
| 654 functions::HistogramValue histogram_value) { | 658 functions::HistogramValue histogram_value) { |
| 655 base::ListValue empty_list; | 659 base::ListValue empty_list; |
| 656 callback.Run(ExtensionFunction::FAILED, empty_list, | 660 callback.Run(ExtensionFunction::FAILED, empty_list, |
| 657 "Access to extension API denied.", histogram_value); | 661 "Access to extension API denied.", histogram_value); |
| 658 } | 662 } |
| 659 | 663 |
| 660 } // namespace extensions | 664 } // namespace extensions |
| OLD | NEW |