OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 45 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
46 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" | 46 #include "chrome/browser/search_engines/search_provider_install_state_message_fi
lter.h" |
47 #include "chrome/browser/spellcheck_host.h" | 47 #include "chrome/browser/spellcheck_host.h" |
48 #include "chrome/browser/spellcheck_message_filter.h" | 48 #include "chrome/browser/spellcheck_message_filter.h" |
49 #include "chrome/browser/metrics/user_metrics.h" | 49 #include "chrome/browser/metrics/user_metrics.h" |
50 #include "chrome/browser/visitedlink/visitedlink_master.h" | 50 #include "chrome/browser/visitedlink/visitedlink_master.h" |
51 #include "chrome/common/chrome_paths.h" | 51 #include "chrome/common/chrome_paths.h" |
52 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
53 #include "chrome/common/extensions/extension.h" | 53 #include "chrome/common/extensions/extension.h" |
54 #include "chrome/common/extensions/extension_icon_set.h" | 54 #include "chrome/common/extensions/extension_icon_set.h" |
| 55 #include "chrome/common/extensions/extension_messages.h" |
55 #include "chrome/common/logging_chrome.h" | 56 #include "chrome/common/logging_chrome.h" |
56 #include "chrome/common/net/url_request_context_getter.h" | 57 #include "chrome/common/net/url_request_context_getter.h" |
57 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
58 #include "chrome/common/render_messages.h" | 59 #include "chrome/common/render_messages.h" |
59 #include "chrome/common/safebrowsing_messages.h" | 60 #include "chrome/common/safebrowsing_messages.h" |
60 #include "chrome/common/spellcheck_messages.h" | 61 #include "chrome/common/spellcheck_messages.h" |
61 #include "chrome/renderer/render_process_impl.h" | 62 #include "chrome/renderer/render_process_impl.h" |
62 #include "chrome/renderer/render_thread.h" | 63 #include "chrome/renderer/render_thread.h" |
63 #include "content/browser/appcache/appcache_dispatcher_host.h" | 64 #include "content/browser/appcache/appcache_dispatcher_host.h" |
64 #include "content/browser/browser_child_process_host.h" | 65 #include "content/browser/browser_child_process_host.h" |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 } | 824 } |
824 | 825 |
825 // Update the renderer process with the current scripts. | 826 // Update the renderer process with the current scripts. |
826 SendUserScriptsUpdate(user_script_master->GetSharedMemory()); | 827 SendUserScriptsUpdate(user_script_master->GetSharedMemory()); |
827 } | 828 } |
828 | 829 |
829 void BrowserRenderProcessHost::InitExtensions() { | 830 void BrowserRenderProcessHost::InitExtensions() { |
830 // Valid extension function names, used to setup bindings in renderer. | 831 // Valid extension function names, used to setup bindings in renderer. |
831 std::vector<std::string> function_names; | 832 std::vector<std::string> function_names; |
832 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); | 833 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); |
833 Send(new ViewMsg_Extension_SetFunctionNames(function_names)); | 834 Send(new ExtensionMsg_SetFunctionNames(function_names)); |
834 | 835 |
835 // Scripting whitelist. This is modified by tests and must be communicated to | 836 // Scripting whitelist. This is modified by tests and must be communicated to |
836 // renderers. | 837 // renderers. |
837 Send(new ViewMsg_Extension_SetScriptingWhitelist( | 838 Send(new ExtensionMsg_SetScriptingWhitelist( |
838 *Extension::GetScriptingWhitelist())); | 839 *Extension::GetScriptingWhitelist())); |
839 | 840 |
840 // Loaded extensions. | 841 // Loaded extensions. |
841 ExtensionService* service = profile()->GetExtensionService(); | 842 ExtensionService* service = profile()->GetExtensionService(); |
842 if (service) { | 843 if (service) { |
843 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 844 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
844 Send(new ViewMsg_ExtensionLoaded( | 845 Send(new ExtensionMsg_Loaded( |
845 ViewMsg_ExtensionLoaded_Params(service->extensions()->at(i)))); | 846 ExtensionMsg_Loaded_Params(service->extensions()->at(i)))); |
846 } | 847 } |
847 } | 848 } |
848 } | 849 } |
849 | 850 |
850 void BrowserRenderProcessHost::SendUserScriptsUpdate( | 851 void BrowserRenderProcessHost::SendUserScriptsUpdate( |
851 base::SharedMemory *shared_memory) { | 852 base::SharedMemory *shared_memory) { |
852 // Process is being started asynchronously. We'll end up calling | 853 // Process is being started asynchronously. We'll end up calling |
853 // InitUserScripts when it's created which will call this again. | 854 // InitUserScripts when it's created which will call this again. |
854 if (child_process_.get() && child_process_->IsStarting()) | 855 if (child_process_.get() && child_process_->IsStarting()) |
855 return; | 856 return; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 996 |
996 mark_child_process_activity_time(); | 997 mark_child_process_activity_time(); |
997 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 998 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
998 // Dispatch control messages. | 999 // Dispatch control messages. |
999 bool msg_is_ok = true; | 1000 bool msg_is_ok = true; |
1000 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) | 1001 IPC_BEGIN_MESSAGE_MAP_EX(BrowserRenderProcessHost, msg, msg_is_ok) |
1001 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, | 1002 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdatedCacheStats, |
1002 OnUpdatedCacheStats) | 1003 OnUpdatedCacheStats) |
1003 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 1004 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
1004 SuddenTerminationChanged); | 1005 SuddenTerminationChanged); |
1005 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionAddListener, | 1006 IPC_MESSAGE_HANDLER(ExtensionHostMsg_AddListener, OnExtensionAddListener) |
1006 OnExtensionAddListener) | 1007 IPC_MESSAGE_HANDLER(ExtensionHostMsg_RemoveListener, |
1007 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRemoveListener, | |
1008 OnExtensionRemoveListener) | 1008 OnExtensionRemoveListener) |
1009 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionCloseChannel, | 1009 IPC_MESSAGE_HANDLER(ExtensionHostMsg_CloseChannel, |
1010 OnExtensionCloseChannel) | 1010 OnExtensionCloseChannel) |
1011 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 1011 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
1012 OnUserMetricsRecordAction) | 1012 OnUserMetricsRecordAction) |
1013 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_RequestDictionary, | 1013 IPC_MESSAGE_HANDLER(SpellCheckHostMsg_RequestDictionary, |
1014 OnSpellCheckerRequestDictionary) | 1014 OnSpellCheckerRequestDictionary) |
1015 IPC_MESSAGE_UNHANDLED_ERROR() | 1015 IPC_MESSAGE_UNHANDLED_ERROR() |
1016 IPC_END_MESSAGE_MAP_EX() | 1016 IPC_END_MESSAGE_MAP_EX() |
1017 | 1017 |
1018 if (!msg_is_ok) { | 1018 if (!msg_is_ok) { |
1019 // The message had a handler, but its de-serialization failed. | 1019 // The message had a handler, but its de-serialization failed. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 switch (type.value) { | 1137 switch (type.value) { |
1138 case NotificationType::USER_SCRIPTS_UPDATED: { | 1138 case NotificationType::USER_SCRIPTS_UPDATED: { |
1139 base::SharedMemory* shared_memory = | 1139 base::SharedMemory* shared_memory = |
1140 Details<base::SharedMemory>(details).ptr(); | 1140 Details<base::SharedMemory>(details).ptr(); |
1141 if (shared_memory) { | 1141 if (shared_memory) { |
1142 SendUserScriptsUpdate(shared_memory); | 1142 SendUserScriptsUpdate(shared_memory); |
1143 } | 1143 } |
1144 break; | 1144 break; |
1145 } | 1145 } |
1146 case NotificationType::EXTENSION_LOADED: { | 1146 case NotificationType::EXTENSION_LOADED: { |
1147 Send(new ViewMsg_ExtensionLoaded( | 1147 Send(new ExtensionMsg_Loaded( |
1148 ViewMsg_ExtensionLoaded_Params( | 1148 ExtensionMsg_Loaded_Params(Details<const Extension>(details).ptr()))); |
1149 Details<const Extension>(details).ptr()))); | |
1150 break; | 1149 break; |
1151 } | 1150 } |
1152 case NotificationType::EXTENSION_UNLOADED: { | 1151 case NotificationType::EXTENSION_UNLOADED: { |
1153 Send(new ViewMsg_ExtensionUnloaded( | 1152 Send(new ExtensionMsg_Unloaded( |
1154 Details<UnloadedExtensionInfo>(details).ptr()->extension->id())); | 1153 Details<UnloadedExtensionInfo>(details).ptr()->extension->id())); |
1155 break; | 1154 break; |
1156 } | 1155 } |
1157 case NotificationType::SPELLCHECK_HOST_REINITIALIZED: { | 1156 case NotificationType::SPELLCHECK_HOST_REINITIALIZED: { |
1158 InitSpellChecker(); | 1157 InitSpellChecker(); |
1159 break; | 1158 break; |
1160 } | 1159 } |
1161 case NotificationType::SPELLCHECK_WORD_ADDED: { | 1160 case NotificationType::SPELLCHECK_WORD_ADDED: { |
1162 AddSpellCheckWord( | 1161 AddSpellCheckWord( |
1163 reinterpret_cast<const Source<SpellCheckHost>*>(&source)-> | 1162 reinterpret_cast<const Source<SpellCheckHost>*>(&source)-> |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 IPC::PlatformFileForTransit file; | 1311 IPC::PlatformFileForTransit file; |
1313 #if defined(OS_POSIX) | 1312 #if defined(OS_POSIX) |
1314 file = base::FileDescriptor(model_file, false); | 1313 file = base::FileDescriptor(model_file, false); |
1315 #elif defined(OS_WIN) | 1314 #elif defined(OS_WIN) |
1316 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 1315 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
1317 false, DUPLICATE_SAME_ACCESS); | 1316 false, DUPLICATE_SAME_ACCESS); |
1318 #endif | 1317 #endif |
1319 Send(new SafeBrowsingMsg_SetPhishingModel(file)); | 1318 Send(new SafeBrowsingMsg_SetPhishingModel(file)); |
1320 } | 1319 } |
1321 } | 1320 } |
OLD | NEW |