blob: e9720d640e47a5a9c8fe6b20f08cd2ac1ff7d6e5 [file] [log] [blame]
[email protected]45776222009-07-15 20:21:581// Copyright (c) 2009 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
initial.commit09911bf2008-07-26 23:55:295#include "chrome/renderer/render_thread.h"
6
[email protected]da00a2882009-03-09 17:51:197#include <algorithm>
8#include <vector>
9
[email protected]06533c0b2009-03-05 21:39:1110#include "base/command_line.h"
[email protected]94f9a0f682009-06-15 18:30:3011#include "base/lazy_instance.h"
initial.commit09911bf2008-07-26 23:55:2912#include "base/shared_memory.h"
[email protected]da00a2882009-03-09 17:51:1913#include "base/stats_table.h"
[email protected]94f9a0f682009-06-15 18:30:3014#include "base/thread_local.h"
[email protected]1edc16b82009-04-07 17:45:5415#include "chrome/common/app_cache/app_cache_context_impl.h"
16#include "chrome/common/app_cache/app_cache_dispatcher.h"
[email protected]06533c0b2009-03-05 21:39:1117#include "chrome/common/chrome_switches.h"
[email protected]017022b2009-07-27 23:06:3418#include "chrome/common/db_message_filter.h"
[email protected]e09ba552009-02-05 03:26:2919#include "chrome/common/render_messages.h"
[email protected]9b6f40e2009-06-11 15:54:2620#include "chrome/common/renderer_preferences.h"
[email protected]90a3fbb12009-02-28 01:13:4721#include "chrome/common/url_constants.h"
[email protected]8930d472009-02-21 08:05:2822#include "chrome/plugin/npobject_util.h"
[email protected]2c62b562009-01-27 19:04:5023// TODO(port)
24#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:2925#include "chrome/plugin/plugin_channel.h"
[email protected]2c62b562009-01-27 19:04:5026#else
[email protected]2c62b562009-01-27 19:04:5027#include "base/scoped_handle.h"
28#include "chrome/plugin/plugin_channel_base.h"
[email protected]2c62b562009-01-27 19:04:5029#endif
[email protected]a8624712009-04-17 00:51:3530#include "chrome/renderer/devtools_agent_filter.h"
[email protected]ad1f9bd2009-07-30 20:23:1531#include "chrome/renderer/extension_groups.h"
[email protected]a40caa972009-04-08 18:35:3432#include "chrome/renderer/extensions/event_bindings.h"
[email protected]309d7a282009-03-24 09:18:2733#include "chrome/renderer/extensions/extension_process_bindings.h"
[email protected]0aa477bd2009-03-23 22:21:4334#include "chrome/renderer/extensions/renderer_extension_bindings.h"
[email protected]3c8e3702009-05-01 16:27:4235#include "chrome/renderer/external_extension.h"
[email protected]a1a0df02009-04-09 08:18:0436#include "chrome/renderer/js_only_v8_extensions.h"
[email protected]0bc46552009-04-07 21:56:4237#include "chrome/renderer/loadtimes_extension_bindings.h"
initial.commit09911bf2008-07-26 23:55:2938#include "chrome/renderer/net/render_dns_master.h"
39#include "chrome/renderer/render_process.h"
40#include "chrome/renderer/render_view.h"
[email protected]8d86fce2009-02-26 23:37:5541#include "chrome/renderer/renderer_webkitclient_impl.h"
[email protected]0938d3c2009-01-09 20:37:3542#include "chrome/renderer/user_script_slave.h"
[email protected]afdcf5c2009-05-10 20:30:4143#include "webkit/api/public/WebCache.h"
44#include "webkit/api/public/WebKit.h"
45#include "webkit/api/public/WebString.h"
[email protected]b07f29092009-06-05 07:33:2146#include "webkit/extensions/v8/benchmarking_extension.h"
[email protected]06533c0b2009-03-05 21:39:1147#include "webkit/extensions/v8/gears_extension.h"
48#include "webkit/extensions/v8/interval_extension.h"
49#include "webkit/extensions/v8/playback_extension.h"
[email protected]2c62b562009-01-27 19:04:5050
[email protected]da00a2882009-03-09 17:51:1951#if defined(OS_WIN)
52#include <windows.h>
53#include <objbase.h>
54#endif
55
[email protected]2c434b32009-03-19 06:27:4756using WebKit::WebCache;
57using WebKit::WebString;
initial.commit09911bf2008-07-26 23:55:2958
[email protected]42f1d7822009-07-23 18:17:5559namespace {
[email protected]2c434b32009-03-19 06:27:4760static const unsigned int kCacheStatsDelayMS = 2000 /* milliseconds */;
[email protected]94f9a0f682009-06-15 18:30:3061static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls(
62 base::LINKER_INITIALIZED);
[email protected]1edc16b82009-04-07 17:45:5463static WebAppCacheContext* CreateAppCacheContextForRenderer() {
64 return new AppCacheContextImpl(RenderThread::current());
65}
66
[email protected]5fa1c542009-05-05 20:36:0767#if defined(OS_POSIX)
68class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
69 void OnChannelError() {
70 // On POSIX, at least, one can install an unload handler which loops
71 // forever and leave behind a renderer process which eats 100% CPU forever.
72 //
73 // This is because the terminate signals (ViewMsg_ShouldClose and the error
74 // from the IPC channel) are routed to the main message loop but never
75 // processed (because that message loop is stuck in V8).
76 //
77 // One could make the browser SIGKILL the renderers, but that leaves open a
78 // large window where a browser failure (or a user, manually terminating
79 // the browser because "it's stuck") will leave behind a process eating all
80 // the CPU.
81 //
82 // So, we install a filter on the channel so that we can process this event
83 // here and kill the process.
84 _exit(0);
85 }
86};
87#endif
[email protected]42f1d7822009-07-23 18:17:5588} // namespace
89
90// When we run plugins in process, we actually run them on the render thread,
91// which means that we need to make the render thread pump UI events.
92RenderThread::RenderThread() {
93 Init();
94}
95
96RenderThread::RenderThread(const std::string& channel_name)
97 : ChildThread(channel_name) {
98 Init();
99}
[email protected]5fa1c542009-05-05 20:36:07100
initial.commit09911bf2008-07-26 23:55:29101void RenderThread::Init() {
[email protected]94f9a0f682009-06-15 18:30:30102 lazy_tls.Pointer()->Set(this);
[email protected]2c62b562009-01-27 19:04:50103#if defined(OS_WIN)
[email protected]bdef78b52009-04-16 19:31:34104 // If you are running plugins in this thread you need COM active but in
105 // the normal case you don't.
106 if (RenderProcess::InProcessPlugins())
107 CoInitialize(0);
[email protected]2c62b562009-01-27 19:04:50108#endif
initial.commit09911bf2008-07-26 23:55:29109
[email protected]42f1d7822009-07-23 18:17:55110 plugin_refresh_allowed_ = true;
[email protected]8d86fce2009-02-26 23:37:55111 cache_stats_factory_.reset(
112 new ScopedRunnableMethodFactory<RenderThread>(this));
113
[email protected]8d86fce2009-02-26 23:37:55114 visited_link_slave_.reset(new VisitedLinkSlave());
115 user_script_slave_.reset(new UserScriptSlave());
116 dns_master_.reset(new RenderDnsMaster());
117 histogram_snapshots_.reset(new RendererHistogramSnapshots());
[email protected]1edc16b82009-04-07 17:45:54118 app_cache_dispatcher_.reset(new AppCacheDispatcher());
119 WebAppCacheContext::SetFactory(CreateAppCacheContextForRenderer);
[email protected]a8624712009-04-17 00:51:35120 devtools_agent_filter_ = new DevToolsAgentFilter();
121 AddFilter(devtools_agent_filter_.get());
[email protected]017022b2009-07-27 23:06:34122 db_message_filter_ = new DBMessageFilter();
123 AddFilter(db_message_filter_.get());
[email protected]5fa1c542009-05-05 20:36:07124
125#if defined(OS_POSIX)
126 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter;
127 AddFilter(suicide_on_channel_error_filter_.get());
128#endif
initial.commit09911bf2008-07-26 23:55:29129}
130
[email protected]42f1d7822009-07-23 18:17:55131RenderThread::~RenderThread() {
[email protected]8d86fce2009-02-26 23:37:55132 // Shutdown in reverse of the initialization order.
[email protected]a8624712009-04-17 00:51:35133 RemoveFilter(devtools_agent_filter_.get());
[email protected]017022b2009-07-27 23:06:34134 RemoveFilter(db_message_filter_.get());
135 db_message_filter_ = NULL;
[email protected]1edc16b82009-04-07 17:45:54136 WebAppCacheContext::SetFactory(NULL);
[email protected]42f1d7822009-07-23 18:17:55137 if (webkit_client_.get())
[email protected]9291ed12009-07-23 17:33:22138 WebKit::shutdown();
[email protected]9291ed12009-07-23 17:33:22139
[email protected]94f9a0f682009-06-15 18:30:30140 lazy_tls.Pointer()->Set(NULL);
[email protected]8fd8de92008-08-12 23:50:30141
[email protected]8d86fce2009-02-26 23:37:55142 // TODO(port)
[email protected]2c62b562009-01-27 19:04:50143#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29144 // Clean up plugin channels before this thread goes away.
145 PluginChannelBase::CleanupChannels();
[email protected]bdef78b52009-04-16 19:31:34146 // Don't call COM if the renderer is in the sandbox.
147 if (RenderProcess::InProcessPlugins())
148 CoUninitialize();
[email protected]2c62b562009-01-27 19:04:50149#endif
initial.commit09911bf2008-07-26 23:55:29150}
151
[email protected]42f1d7822009-07-23 18:17:55152RenderThread* RenderThread::current() {
153 return lazy_tls.Pointer()->Get();
154}
155
156void RenderThread::AddFilter(IPC::ChannelProxy::MessageFilter* filter) {
157 channel()->AddFilter(filter);
158}
159
160void RenderThread::RemoveFilter(IPC::ChannelProxy::MessageFilter* filter) {
161 channel()->RemoveFilter(filter);
162}
163
164void RenderThread::Resolve(const char* name, size_t length) {
165 return dns_master_->Resolve(name, length);
166}
167
168void RenderThread::SendHistograms(int sequence_number) {
169 return histogram_snapshots_->SendHistograms(sequence_number);
170}
171
[email protected]176aa482008-11-14 03:25:15172void RenderThread::OnUpdateVisitedLinks(base::SharedMemoryHandle table) {
[email protected]5fe733de2009-02-11 18:59:20173 DCHECK(base::SharedMemory::IsHandleValid(table)) << "Bad table handle";
initial.commit09911bf2008-07-26 23:55:29174 visited_link_slave_->Init(table);
175}
176
[email protected]3e90d4a2009-07-03 17:38:39177void RenderThread::OnAddVisitedLinks(
178 const VisitedLinkSlave::Fingerprints& fingerprints) {
179 for (size_t i = 0; i < fingerprints.size(); ++i)
180 WebView::UpdateVisitedLinkState(fingerprints[i]);
181}
182
183void RenderThread::OnResetVisitedLinks() {
184 WebView::ResetVisitedLinkState();
185}
186
[email protected]0938d3c2009-01-09 20:37:35187void RenderThread::OnUpdateUserScripts(
[email protected]176aa482008-11-14 03:25:15188 base::SharedMemoryHandle scripts) {
[email protected]5fe733de2009-02-11 18:59:20189 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle";
[email protected]0938d3c2009-01-09 20:37:35190 user_script_slave_->UpdateScripts(scripts);
[email protected]1e0f70402008-10-16 23:57:47191}
192
[email protected]703e807a2009-03-28 19:56:51193void RenderThread::OnSetExtensionFunctionNames(
194 const std::vector<std::string>& names) {
[email protected]a1a0df02009-04-09 08:18:04195 ExtensionProcessBindings::SetFunctionNames(names);
[email protected]703e807a2009-03-28 19:56:51196}
197
[email protected]45776222009-07-15 20:21:58198void RenderThread::OnPageActionsUpdated(
199 const std::string& extension_id,
200 const std::vector<std::string>& page_actions) {
201 ExtensionProcessBindings::SetPageActions(extension_id, page_actions);
202}
203
[email protected]8930d472009-02-21 08:05:28204void RenderThread::OnControlMessageReceived(const IPC::Message& msg) {
[email protected]1edc16b82009-04-07 17:45:54205 // App cache messages are handled by a delegate.
206 if (app_cache_dispatcher_->OnMessageReceived(msg))
207 return;
208
[email protected]8930d472009-02-21 08:05:28209 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg)
210 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks)
[email protected]3e90d4a2009-07-03 17:38:39211 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks)
212 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks)
[email protected]8930d472009-02-21 08:05:28213 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)
214 // TODO(port): removed from render_messages_internal.h;
215 // is there a new non-windows message I should add here?
216 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
217 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities)
[email protected]55e57d42009-02-25 06:10:17218 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms,
[email protected]c9a3ef82009-05-28 22:02:46219 OnGetRendererHistograms)
[email protected]8930d472009-02-21 08:05:28220 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats,
221 OnGetCacheResourceStats)
[email protected]2f2243e2009-05-26 02:27:02222 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts,
[email protected]8930d472009-02-21 08:05:28223 OnUpdateUserScripts)
[email protected]b68d5ed2009-04-16 02:41:28224 // TODO(rafaelw): create an ExtensionDispatcher that handles extension
225 // messages seperates their handling from the RenderThread.
[email protected]dfcb62a2009-06-17 19:32:43226 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke,
227 OnExtensionMessageInvoke)
[email protected]703e807a2009-03-28 19:56:51228 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames,
229 OnSetExtensionFunctionNames)
[email protected]b547fd42009-04-23 23:16:27230 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache,
231 OnPurgePluginListCache)
[email protected]45776222009-07-15 20:21:58232 IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions,
233 OnPageActionsUpdated)
[email protected]8930d472009-02-21 08:05:28234 IPC_END_MESSAGE_MAP()
initial.commit09911bf2008-07-26 23:55:29235}
236
237void RenderThread::OnSetNextPageID(int32 next_page_id) {
238 // This should only be called at process initialization time, so we shouldn't
239 // have to worry about thread-safety.
240 RenderView::SetNextPageID(next_page_id);
241}
242
[email protected]18bcc3c2009-01-27 21:39:15243void RenderThread::OnCreateNewView(gfx::NativeViewId parent_hwnd,
244 ModalDialogEvent modal_dialog_event,
[email protected]80d96fa2009-06-10 22:34:51245 const RendererPreferences& renderer_prefs,
initial.commit09911bf2008-07-26 23:55:29246 const WebPreferences& webkit_prefs,
247 int32 view_id) {
[email protected]90a3fbb12009-02-28 01:13:47248 EnsureWebKitInitialized();
249
[email protected]be645db2009-02-06 20:36:33250 // When bringing in render_view, also bring in webkit's glue and jsbindings.
[email protected]18bcc3c2009-01-27 21:39:15251 base::WaitableEvent* waitable_event = new base::WaitableEvent(
252#if defined(OS_WIN)
253 modal_dialog_event.event);
254#else
255 true, false);
256#endif
257
initial.commit09911bf2008-07-26 23:55:29258 RenderView::Create(
[email protected]80d96fa2009-06-10 22:34:51259 this, parent_hwnd, waitable_event, MSG_ROUTING_NONE, renderer_prefs,
260 webkit_prefs, new SharedRenderViewCounter(0), view_id);
[email protected]7f874dec2009-02-06 01:48:27261}
[email protected]4274e582009-01-27 22:09:56262
initial.commit09911bf2008-07-26 23:55:29263void RenderThread::OnSetCacheCapacities(size_t min_dead_capacity,
264 size_t max_dead_capacity,
265 size_t capacity) {
[email protected]90a3fbb12009-02-28 01:13:47266 EnsureWebKitInitialized();
[email protected]2c434b32009-03-19 06:27:47267 WebCache::setCapacities(
268 min_dead_capacity, max_dead_capacity, capacity);
initial.commit09911bf2008-07-26 23:55:29269}
270
271void RenderThread::OnGetCacheResourceStats() {
[email protected]90a3fbb12009-02-28 01:13:47272 EnsureWebKitInitialized();
[email protected]2c434b32009-03-19 06:27:47273 WebCache::ResourceTypeStats stats;
274 WebCache::getResourceTypeStats(&stats);
initial.commit09911bf2008-07-26 23:55:29275 Send(new ViewHostMsg_ResourceTypeStats(stats));
276}
277
[email protected]c9a3ef82009-05-28 22:02:46278void RenderThread::OnGetRendererHistograms(int sequence_number) {
279 SendHistograms(sequence_number);
[email protected]55e57d42009-02-25 06:10:17280}
281
initial.commit09911bf2008-07-26 23:55:29282void RenderThread::InformHostOfCacheStats() {
[email protected]90a3fbb12009-02-28 01:13:47283 EnsureWebKitInitialized();
[email protected]2c434b32009-03-19 06:27:47284 WebCache::UsageStats stats;
285 WebCache::getUsageStats(&stats);
initial.commit09911bf2008-07-26 23:55:29286 Send(new ViewHostMsg_UpdatedCacheStats(stats));
287}
288
289void RenderThread::InformHostOfCacheStatsLater() {
290 // Rate limit informing the host of our cache stats.
291 if (!cache_stats_factory_->empty())
292 return;
293
294 MessageLoop::current()->PostDelayedTask(FROM_HERE,
295 cache_stats_factory_->NewRunnableMethod(
296 &RenderThread::InformHostOfCacheStats),
297 kCacheStatsDelayMS);
298}
[email protected]90a3fbb12009-02-28 01:13:47299
[email protected]b07f29092009-06-05 07:33:21300void RenderThread::CloseIdleConnections() {
301 Send(new ViewHostMsg_CloseIdleConnections());
302}
303
304void RenderThread::SetCacheMode(bool enabled) {
305 Send(new ViewHostMsg_SetCacheMode(enabled));
306}
307
[email protected]3df0c202009-03-31 23:51:26308static void* CreateHistogram(
309 const char *name, int min, int max, size_t buckets) {
[email protected]56a27b22009-05-21 00:44:37310 Histogram* histogram = new Histogram(name, min, max, buckets);
311 if (histogram) {
312 histogram->SetFlags(kUmaTargetedHistogramFlag);
313 }
314 return histogram;
[email protected]3df0c202009-03-31 23:51:26315}
316
317static void AddHistogramSample(void* hist, int sample) {
318 Histogram* histogram = static_cast<Histogram *>(hist);
319 histogram->Add(sample);
320}
321
[email protected]90a3fbb12009-02-28 01:13:47322void RenderThread::EnsureWebKitInitialized() {
323 if (webkit_client_.get())
324 return;
[email protected]da00a2882009-03-09 17:51:19325
326 v8::V8::SetCounterFunction(StatsTable::FindLocation);
[email protected]3df0c202009-03-31 23:51:26327 v8::V8::SetCreateHistogramFunction(CreateHistogram);
328 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample);
[email protected]da00a2882009-03-09 17:51:19329
[email protected]90a3fbb12009-02-28 01:13:47330 webkit_client_.reset(new RendererWebKitClientImpl);
331 WebKit::initialize(webkit_client_.get());
[email protected]8881eca82009-03-12 18:20:44332
[email protected]60e448982009-05-06 04:21:16333 // chrome: pages should not be accessible by normal content, and should
[email protected]8881eca82009-03-12 18:20:44334 // also be unable to script anything but themselves (to help limit the damage
[email protected]60e448982009-05-06 04:21:16335 // that a corrupt chrome: page could cause).
[email protected]2c434b32009-03-19 06:27:47336 WebString chrome_ui_scheme(ASCIIToUTF16(chrome::kChromeUIScheme));
[email protected]8881eca82009-03-12 18:20:44337 WebKit::registerURLSchemeAsLocal(chrome_ui_scheme);
338 WebKit::registerURLSchemeAsNoAccess(chrome_ui_scheme);
[email protected]da00a2882009-03-09 17:51:19339
[email protected]d53d8492009-07-14 01:51:32340 // print: pages should be not accessible by normal context.
341 WebString print_ui_scheme(ASCIIToUTF16(chrome::kPrintScheme));
342 WebKit::registerURLSchemeAsLocal(print_ui_scheme);
343 WebKit::registerURLSchemeAsNoAccess(print_ui_scheme);
344
[email protected]6cf8b1a22009-05-26 23:36:00345#if defined(OS_WIN)
346 // We don't yet support Gears on non-Windows, so don't tell pages that we do.
[email protected]06533c0b2009-03-05 21:39:11347 WebKit::registerExtension(extensions_v8::GearsExtension::Get());
[email protected]6cf8b1a22009-05-26 23:36:00348#endif
[email protected]06533c0b2009-03-05 21:39:11349 WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
[email protected]c20210e62009-04-03 21:39:26350 WebKit::registerExtension(extensions_v8::LoadTimesExtension::Get());
[email protected]3c8e3702009-05-01 16:27:42351 WebKit::registerExtension(extensions_v8::ExternalExtension::Get());
[email protected]309d7a282009-03-24 09:18:27352
[email protected]ad1f9bd2009-07-30 20:23:15353 const WebKit::WebString kExtensionScheme =
354 WebKit::WebString::fromUTF8(chrome::kExtensionScheme);
355
356 WebKit::registerExtension(ExtensionProcessBindings::Get(), kExtensionScheme);
357
358 WebKit::registerExtension(BaseJsV8Extension::Get(),
359 EXTENSION_GROUP_CONTENT_SCRIPTS);
360 WebKit::registerExtension(BaseJsV8Extension::Get(), kExtensionScheme);
361 WebKit::registerExtension(JsonSchemaJsV8Extension::Get(),
362 EXTENSION_GROUP_CONTENT_SCRIPTS);
363 WebKit::registerExtension(JsonSchemaJsV8Extension::Get(), kExtensionScheme);
364 WebKit::registerExtension(EventBindings::Get(),
365 EXTENSION_GROUP_CONTENT_SCRIPTS);
366 WebKit::registerExtension(EventBindings::Get(), kExtensionScheme);
367 WebKit::registerExtension(RendererExtensionBindings::Get(),
368 EXTENSION_GROUP_CONTENT_SCRIPTS);
369 WebKit::registerExtension(RendererExtensionBindings::Get(), kExtensionScheme);
[email protected]a1a0df02009-04-09 08:18:04370
[email protected]06533c0b2009-03-05 21:39:11371 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
[email protected]a1a0df02009-04-09 08:18:04372
[email protected]b07f29092009-06-05 07:33:21373 if (command_line.HasSwitch(switches::kEnableBenchmarking))
374 WebKit::registerExtension(extensions_v8::BenchmarkingExtension::Get());
375
[email protected]06533c0b2009-03-05 21:39:11376 if (command_line.HasSwitch(switches::kPlaybackMode) ||
[email protected]ca12c842009-04-14 22:20:18377 command_line.HasSwitch(switches::kRecordMode) ||
378 command_line.HasSwitch(switches::kNoJsRandomness)) {
[email protected]06533c0b2009-03-05 21:39:11379 WebKit::registerExtension(extensions_v8::PlaybackExtension::Get());
380 }
[email protected]2cb82332009-03-18 17:24:55381
[email protected]b08eebe2009-05-18 22:37:21382 if (RenderProcess::current()->initialized_media_library())
383 WebKit::enableMediaPlayer();
[email protected]017022b2009-07-27 23:06:34384
385 if (command_line.HasSwitch(switches::kEnableDatabases)) {
386 WebKit::enableDatabases();
387 }
[email protected]90a3fbb12009-02-28 01:13:47388}
[email protected]75e5a872009-04-02 23:56:11389
[email protected]dfcb62a2009-06-17 19:32:43390void RenderThread::OnExtensionMessageInvoke(const std::string& function_name,
391 const ListValue& args) {
[email protected]7120f132009-07-20 21:05:37392 RendererExtensionBindings::Invoke(function_name, args, NULL);
[email protected]b68d5ed2009-04-16 02:41:28393}
[email protected]b547fd42009-04-23 23:16:27394
395void RenderThread::OnPurgePluginListCache() {
396 // The call below will cause a GetPlugins call with refresh=true, but at this
397 // point we already know that the browser has refreshed its list, so disable
398 // refresh temporarily to prevent each renderer process causing the list to be
399 // regenerated.
400 plugin_refresh_allowed_ = false;
401 WebKit::resetPluginCache();
402 plugin_refresh_allowed_ = true;
403}