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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 std::map<int, int>::const_iterator it = | 845 std::map<int, int>::const_iterator it = |
846 port_to_tab_id_map_.find(target_port_id); | 846 port_to_tab_id_map_.find(target_port_id); |
847 if (it != port_to_tab_id_map_.end()) { | 847 if (it != port_to_tab_id_map_.end()) { |
848 scoped_tab_id.reset( | 848 scoped_tab_id.reset( |
849 new RequestSender::ScopedTabID(request_sender(), it->second)); | 849 new RequestSender::ScopedTabID(request_sender(), it->second)); |
850 } | 850 } |
851 | 851 |
852 MessagingBindings::DeliverMessage(script_context_set_, | 852 MessagingBindings::DeliverMessage(script_context_set_, |
853 target_port_id, | 853 target_port_id, |
854 message, | 854 message, |
855 NULL); // All render views. | 855 NULL); // All render frames. |
856 } | 856 } |
857 | 857 |
858 void Dispatcher::OnDispatchOnConnect( | 858 void Dispatcher::OnDispatchOnConnect( |
859 int target_port_id, | 859 int target_port_id, |
860 const std::string& channel_name, | 860 const std::string& channel_name, |
861 const base::DictionaryValue& source_tab, | 861 const ExtensionMsg_TabConnectionInfo& source, |
862 const ExtensionMsg_ExternalConnectionInfo& info, | 862 const ExtensionMsg_ExternalConnectionInfo& info, |
863 const std::string& tls_channel_id) { | 863 const std::string& tls_channel_id) { |
864 DCHECK(!ContainsKey(port_to_tab_id_map_, target_port_id)); | 864 DCHECK(!ContainsKey(port_to_tab_id_map_, target_port_id)); |
865 DCHECK_EQ(1, target_port_id % 2); // target renderer ports have odd IDs. | 865 DCHECK_EQ(1, target_port_id % 2); // target renderer ports have odd IDs. |
866 int sender_tab_id = -1; | 866 int sender_tab_id = -1; |
867 source_tab.GetInteger("id", &sender_tab_id); | 867 source.tab.GetInteger("id", &sender_tab_id); |
868 port_to_tab_id_map_[target_port_id] = sender_tab_id; | 868 port_to_tab_id_map_[target_port_id] = sender_tab_id; |
869 | 869 |
870 MessagingBindings::DispatchOnConnect(script_context_set_, | 870 MessagingBindings::DispatchOnConnect(script_context_set_, |
871 target_port_id, | 871 target_port_id, |
872 channel_name, | 872 channel_name, |
873 source_tab, | 873 source, |
874 info, | 874 info, |
875 tls_channel_id, | 875 tls_channel_id, |
876 NULL); // All render views. | 876 NULL); // All render frames. |
877 } | 877 } |
878 | 878 |
879 void Dispatcher::OnDispatchOnDisconnect(int port_id, | 879 void Dispatcher::OnDispatchOnDisconnect(int port_id, |
880 const std::string& error_message) { | 880 const std::string& error_message) { |
881 MessagingBindings::DispatchOnDisconnect(script_context_set_, | 881 MessagingBindings::DispatchOnDisconnect(script_context_set_, |
882 port_id, | 882 port_id, |
883 error_message, | 883 error_message, |
884 NULL); // All render views. | 884 NULL); // All render frames. |
885 } | 885 } |
886 | 886 |
887 void Dispatcher::OnLoaded( | 887 void Dispatcher::OnLoaded( |
888 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions) { | 888 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions) { |
889 std::vector<ExtensionMsg_Loaded_Params>::const_iterator i; | 889 std::vector<ExtensionMsg_Loaded_Params>::const_iterator i; |
890 for (i = loaded_extensions.begin(); i != loaded_extensions.end(); ++i) { | 890 for (i = loaded_extensions.begin(); i != loaded_extensions.end(); ++i) { |
891 std::string error; | 891 std::string error; |
892 scoped_refptr<const Extension> extension = i->ConvertToExtension(&error); | 892 scoped_refptr<const Extension> extension = i->ConvertToExtension(&error); |
893 if (!extension.get()) { | 893 if (!extension.get()) { |
894 extension_load_errors_[i->id] = error; | 894 extension_load_errors_[i->id] = error; |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 return v8::Handle<v8::Object>(); | 1403 return v8::Handle<v8::Object>(); |
1404 | 1404 |
1405 if (bind_name) | 1405 if (bind_name) |
1406 *bind_name = split.back(); | 1406 *bind_name = split.back(); |
1407 | 1407 |
1408 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1408 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
1409 : bind_object; | 1409 : bind_object; |
1410 } | 1410 } |
1411 | 1411 |
1412 } // namespace extensions | 1412 } // namespace extensions |
OLD | NEW |