OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/renderer/render_thread.h" | 5 #include "chrome/renderer/render_thread.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
12 #include "base/stats_table.h" | 12 #include "base/stats_table.h" |
13 #include "chrome/common/chrome_plugin_lib.h" | |
14 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
16 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
17 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
18 #include "chrome/plugin/npobject_util.h" | 17 #include "chrome/plugin/npobject_util.h" |
19 // TODO(port) | 18 // TODO(port) |
20 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
21 #include "chrome/plugin/plugin_channel.h" | 20 #include "chrome/plugin/plugin_channel.h" |
22 #else | 21 #else |
23 #include "base/scoped_handle.h" | 22 #include "base/scoped_handle.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) | 150 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) |
152 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) | 151 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) |
153 // TODO(port): removed from render_messages_internal.h; | 152 // TODO(port): removed from render_messages_internal.h; |
154 // is there a new non-windows message I should add here? | 153 // is there a new non-windows message I should add here? |
155 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 154 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
156 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 155 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
157 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, | 156 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, |
158 OnGetRendererHistograms) | 157 OnGetRendererHistograms) |
159 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, | 158 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, |
160 OnGetCacheResourceStats) | 159 OnGetCacheResourceStats) |
161 IPC_MESSAGE_HANDLER(ViewMsg_PluginMessage, OnPluginMessage) | |
162 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts, | 160 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_NewScripts, |
163 OnUpdateUserScripts) | 161 OnUpdateUserScripts) |
164 IPC_END_MESSAGE_MAP() | 162 IPC_END_MESSAGE_MAP() |
165 } | 163 } |
166 | 164 |
167 void RenderThread::OnPluginMessage(const FilePath& plugin_path, | |
168 const std::vector<uint8>& data) { | |
169 if (!ChromePluginLib::IsInitialized()) { | |
170 return; | |
171 } | |
172 CHECK(ChromePluginLib::IsPluginThread()); | |
173 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(plugin_path); | |
174 if (chrome_plugin) { | |
175 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); | |
176 uint32 data_len = static_cast<uint32>(data.size()); | |
177 chrome_plugin->functions().on_message(data_ptr, data_len); | |
178 } | |
179 } | |
180 | |
181 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 165 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
182 // This should only be called at process initialization time, so we shouldn't | 166 // This should only be called at process initialization time, so we shouldn't |
183 // have to worry about thread-safety. | 167 // have to worry about thread-safety. |
184 // TODO(port) | 168 // TODO(port) |
185 #if !defined(OS_LINUX) | 169 #if !defined(OS_LINUX) |
186 RenderView::SetNextPageID(next_page_id); | 170 RenderView::SetNextPageID(next_page_id); |
187 #endif | 171 #endif |
188 } | 172 } |
189 | 173 |
190 void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd, | 174 void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 246 |
263 WebKit::registerExtension(extensions_v8::GearsExtension::Get()); | 247 WebKit::registerExtension(extensions_v8::GearsExtension::Get()); |
264 WebKit::registerExtension(extensions_v8::IntervalExtension::Get()); | 248 WebKit::registerExtension(extensions_v8::IntervalExtension::Get()); |
265 | 249 |
266 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 250 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
267 if (command_line.HasSwitch(switches::kPlaybackMode) || | 251 if (command_line.HasSwitch(switches::kPlaybackMode) || |
268 command_line.HasSwitch(switches::kRecordMode)) { | 252 command_line.HasSwitch(switches::kRecordMode)) { |
269 WebKit::registerExtension(extensions_v8::PlaybackExtension::Get()); | 253 WebKit::registerExtension(extensions_v8::PlaybackExtension::Get()); |
270 } | 254 } |
271 } | 255 } |
OLD | NEW |