| 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/renderer/dispatcher.h" | 5 #include "extensions/renderer/dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // |frame_helper| and |render_frame| might be dead by now. | 654 // |frame_helper| and |render_frame| might be dead by now. |
| 655 } | 655 } |
| 656 | 656 |
| 657 void Dispatcher::OnExtensionResponse(int request_id, | 657 void Dispatcher::OnExtensionResponse(int request_id, |
| 658 bool success, | 658 bool success, |
| 659 const base::ListValue& response, | 659 const base::ListValue& response, |
| 660 const std::string& error) { | 660 const std::string& error) { |
| 661 bindings_system_->HandleResponse(request_id, success, response, error); | 661 bindings_system_->HandleResponse(request_id, success, response, error); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void Dispatcher::DispatchEvent( | 664 void Dispatcher::DispatchEvent(const std::string& extension_id, |
| 665 const std::string& extension_id, | 665 const std::string& event_name, |
| 666 const std::string& event_name, | 666 const base::ListValue& event_args, |
| 667 const base::ListValue& event_args, | 667 const EventFilteringInfo& filtering_info) const { |
| 668 const base::DictionaryValue& filtering_info) const { | |
| 669 script_context_set_->ForEach( | 668 script_context_set_->ForEach( |
| 670 extension_id, nullptr, | 669 extension_id, nullptr, |
| 671 base::Bind(&ExtensionBindingsSystem::DispatchEventInContext, | 670 base::Bind(&ExtensionBindingsSystem::DispatchEventInContext, |
| 672 base::Unretained(bindings_system_.get()), event_name, | 671 base::Unretained(bindings_system_.get()), event_name, |
| 673 &event_args, &filtering_info)); | 672 &event_args, &filtering_info)); |
| 674 | 673 |
| 675 // Reset the idle handler each time there's any activity like event or message | 674 // Reset the idle handler each time there's any activity like event or message |
| 676 // dispatch. | 675 // dispatch. |
| 677 // TODO(devlin): It's likely this is totally wrong. See | 676 // TODO(devlin): It's likely this is totally wrong. See |
| 678 // https://groups.google.com/a/chromium.org/forum/#!msg/scheduler-dev/iTRVbcmm
pAs/pfqyUyEeAAAJ | 677 // https://groups.google.com/a/chromium.org/forum/#!msg/scheduler-dev/iTRVbcmm
pAs/pfqyUyEeAAAJ |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 extension_id); | 998 extension_id); |
| 1000 } | 999 } |
| 1001 | 1000 |
| 1002 InitOriginPermissions(extension); | 1001 InitOriginPermissions(extension); |
| 1003 | 1002 |
| 1004 UpdateActiveExtensions(); | 1003 UpdateActiveExtensions(); |
| 1005 } | 1004 } |
| 1006 | 1005 |
| 1007 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { | 1006 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { |
| 1008 DispatchEvent(extension_id, kOnSuspendCanceledEvent, base::ListValue(), | 1007 DispatchEvent(extension_id, kOnSuspendCanceledEvent, base::ListValue(), |
| 1009 base::DictionaryValue()); | 1008 EventFilteringInfo()); |
| 1010 } | 1009 } |
| 1011 | 1010 |
| 1012 void Dispatcher::OnDeliverMessage(const PortId& target_port_id, | 1011 void Dispatcher::OnDeliverMessage(const PortId& target_port_id, |
| 1013 const Message& message) { | 1012 const Message& message) { |
| 1014 MessagingBindings::DeliverMessage(*script_context_set_, target_port_id, | 1013 MessagingBindings::DeliverMessage(*script_context_set_, target_port_id, |
| 1015 message, | 1014 message, |
| 1016 NULL); // All render frames. | 1015 NULL); // All render frames. |
| 1017 } | 1016 } |
| 1018 | 1017 |
| 1019 void Dispatcher::OnDispatchOnConnect( | 1018 void Dispatcher::OnDispatchOnConnect( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 new ExtensionHostMsg_ShouldSuspendAck(extension_id, sequence_id)); | 1147 new ExtensionHostMsg_ShouldSuspendAck(extension_id, sequence_id)); |
| 1149 } | 1148 } |
| 1150 | 1149 |
| 1151 void Dispatcher::OnSuspend(const std::string& extension_id) { | 1150 void Dispatcher::OnSuspend(const std::string& extension_id) { |
| 1152 // Dispatch the suspend event. This doesn't go through the standard event | 1151 // Dispatch the suspend event. This doesn't go through the standard event |
| 1153 // dispatch machinery because it requires special handling. We need to let | 1152 // dispatch machinery because it requires special handling. We need to let |
| 1154 // the browser know when we are starting and stopping the event dispatch, so | 1153 // the browser know when we are starting and stopping the event dispatch, so |
| 1155 // that it still considers the extension idle despite any activity the suspend | 1154 // that it still considers the extension idle despite any activity the suspend |
| 1156 // event creates. | 1155 // event creates. |
| 1157 DispatchEvent(extension_id, kOnSuspendEvent, base::ListValue(), | 1156 DispatchEvent(extension_id, kOnSuspendEvent, base::ListValue(), |
| 1158 base::DictionaryValue()); | 1157 EventFilteringInfo()); |
| 1159 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id)); | 1158 RenderThread::Get()->Send(new ExtensionHostMsg_SuspendAck(extension_id)); |
| 1160 } | 1159 } |
| 1161 | 1160 |
| 1162 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) { | 1161 void Dispatcher::OnTransferBlobs(const std::vector<std::string>& blob_uuids) { |
| 1163 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); | 1162 RenderThread::Get()->Send(new ExtensionHostMsg_TransferBlobsAck(blob_uuids)); |
| 1164 } | 1163 } |
| 1165 | 1164 |
| 1166 void Dispatcher::OnUnloaded(const std::string& id) { | 1165 void Dispatcher::OnUnloaded(const std::string& id) { |
| 1167 // See comment in OnLoaded for why it would be nice, but perhaps incorrect, | 1166 // See comment in OnLoaded for why it would be nice, but perhaps incorrect, |
| 1168 // to CHECK here rather than guarding. | 1167 // to CHECK here rather than guarding. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 // The "guestViewDeny" module must always be loaded last. It registers | 1490 // The "guestViewDeny" module must always be loaded last. It registers |
| 1492 // error-providing custom elements for the GuestView types that are not | 1491 // error-providing custom elements for the GuestView types that are not |
| 1493 // available, and thus all of those types must have been checked and loaded | 1492 // available, and thus all of those types must have been checked and loaded |
| 1494 // (or not loaded) beforehand. | 1493 // (or not loaded) beforehand. |
| 1495 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 1494 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 1496 module_system->Require("guestViewDeny"); | 1495 module_system->Require("guestViewDeny"); |
| 1497 } | 1496 } |
| 1498 } | 1497 } |
| 1499 | 1498 |
| 1500 } // namespace extensions | 1499 } // namespace extensions |
| OLD | NEW |