OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "chrome/renderer/extensions/js_only_v8_extensions.h" | 44 #include "chrome/renderer/extensions/js_only_v8_extensions.h" |
45 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 45 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
46 #include "chrome/renderer/external_extension.h" | 46 #include "chrome/renderer/external_extension.h" |
47 #include "chrome/renderer/loadtimes_extension_bindings.h" | 47 #include "chrome/renderer/loadtimes_extension_bindings.h" |
48 #include "chrome/renderer/net/render_dns_master.h" | 48 #include "chrome/renderer/net/render_dns_master.h" |
49 #include "chrome/renderer/render_process.h" | 49 #include "chrome/renderer/render_process.h" |
50 #include "chrome/renderer/render_view.h" | 50 #include "chrome/renderer/render_view.h" |
51 #include "chrome/renderer/renderer_webkitclient_impl.h" | 51 #include "chrome/renderer/renderer_webkitclient_impl.h" |
52 #include "chrome/renderer/renderer_web_database_observer.h" | 52 #include "chrome/renderer/renderer_web_database_observer.h" |
53 #include "chrome/renderer/socket_stream_dispatcher.h" | 53 #include "chrome/renderer/socket_stream_dispatcher.h" |
| 54 #if defined(SPELLCHECKER_IN_RENDERER) |
| 55 #include "chrome/renderer/spellchecker/spellcheck.h" |
| 56 #endif |
54 #include "chrome/renderer/user_script_slave.h" | 57 #include "chrome/renderer/user_script_slave.h" |
55 #include "ipc/ipc_message.h" | 58 #include "ipc/ipc_message.h" |
56 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h" | 59 #include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h" |
57 #include "webkit/api/public/WebCache.h" | 60 #include "webkit/api/public/WebCache.h" |
58 #include "webkit/api/public/WebColor.h" | 61 #include "webkit/api/public/WebColor.h" |
59 #include "webkit/api/public/WebCrossOriginPreflightResultCache.h" | 62 #include "webkit/api/public/WebCrossOriginPreflightResultCache.h" |
60 #include "webkit/api/public/WebDatabase.h" | 63 #include "webkit/api/public/WebDatabase.h" |
61 #include "webkit/api/public/WebFontCache.h" | 64 #include "webkit/api/public/WebFontCache.h" |
62 #include "webkit/api/public/WebKit.h" | 65 #include "webkit/api/public/WebKit.h" |
63 #include "webkit/api/public/WebRuntimeFeatures.h" | 66 #include "webkit/api/public/WebRuntimeFeatures.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 visited_link_slave_.reset(new VisitedLinkSlave()); | 148 visited_link_slave_.reset(new VisitedLinkSlave()); |
146 user_script_slave_.reset(new UserScriptSlave()); | 149 user_script_slave_.reset(new UserScriptSlave()); |
147 dns_master_.reset(new RenderDnsMaster()); | 150 dns_master_.reset(new RenderDnsMaster()); |
148 histogram_snapshots_.reset(new RendererHistogramSnapshots()); | 151 histogram_snapshots_.reset(new RendererHistogramSnapshots()); |
149 appcache_dispatcher_.reset(new AppCacheDispatcher(this)); | 152 appcache_dispatcher_.reset(new AppCacheDispatcher(this)); |
150 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 153 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
151 devtools_agent_filter_ = new DevToolsAgentFilter(); | 154 devtools_agent_filter_ = new DevToolsAgentFilter(); |
152 AddFilter(devtools_agent_filter_.get()); | 155 AddFilter(devtools_agent_filter_.get()); |
153 db_message_filter_ = new DBMessageFilter(); | 156 db_message_filter_ = new DBMessageFilter(); |
154 AddFilter(db_message_filter_.get()); | 157 AddFilter(db_message_filter_.get()); |
| 158 #if defined(SPELLCHECKER_IN_RENDERER) |
| 159 spellchecker_.reset(new SpellCheck()); |
| 160 #endif |
155 | 161 |
156 #if defined(OS_POSIX) | 162 #if defined(OS_POSIX) |
157 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter; | 163 suicide_on_channel_error_filter_ = new SuicideOnChannelErrorFilter; |
158 AddFilter(suicide_on_channel_error_filter_.get()); | 164 AddFilter(suicide_on_channel_error_filter_.get()); |
159 #endif | 165 #endif |
160 } | 166 } |
161 | 167 |
162 RenderThread::~RenderThread() { | 168 RenderThread::~RenderThread() { |
163 // Shutdown in reverse of the initialization order. | 169 // Shutdown in reverse of the initialization order. |
164 RemoveFilter(devtools_agent_filter_.get()); | 170 RemoveFilter(devtools_agent_filter_.get()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, | 330 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, |
325 OnExtensionSetHostPermissions) | 331 OnExtensionSetHostPermissions) |
326 IPC_MESSAGE_HANDLER(ViewMsg_DOMStorageEvent, | 332 IPC_MESSAGE_HANDLER(ViewMsg_DOMStorageEvent, |
327 OnDOMStorageEvent) | 333 OnDOMStorageEvent) |
328 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetL10nMessages, | 334 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetL10nMessages, |
329 OnExtensionSetL10nMessages) | 335 OnExtensionSetL10nMessages) |
330 #if defined(IPC_MESSAGE_LOG_ENABLED) | 336 #if defined(IPC_MESSAGE_LOG_ENABLED) |
331 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, | 337 IPC_MESSAGE_HANDLER(ViewMsg_SetIPCLoggingEnabled, |
332 OnSetIPCLoggingEnabled) | 338 OnSetIPCLoggingEnabled) |
333 #endif | 339 #endif |
| 340 #if defined(SPELLCHECKER_IN_RENDERER) |
| 341 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_Init, |
| 342 OnInitSpellChecker) |
| 343 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_WordAdded, |
| 344 OnSpellCheckWordAdded) |
| 345 IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, |
| 346 OnSpellCheckEnableAutoSpellCorrect) |
| 347 #endif |
334 IPC_END_MESSAGE_MAP() | 348 IPC_END_MESSAGE_MAP() |
335 } | 349 } |
336 | 350 |
337 void RenderThread::OnSetNextPageID(int32 next_page_id) { | 351 void RenderThread::OnSetNextPageID(int32 next_page_id) { |
338 // This should only be called at process initialization time, so we shouldn't | 352 // This should only be called at process initialization time, so we shouldn't |
339 // have to worry about thread-safety. | 353 // have to worry about thread-safety. |
340 RenderView::SetNextPageID(next_page_id); | 354 RenderView::SetNextPageID(next_page_id); |
341 } | 355 } |
342 | 356 |
343 // Called when to register CSS Color name->system color mappings. | 357 // Called when to register CSS Color name->system color mappings. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } | 437 } |
424 | 438 |
425 void RenderThread::CloseIdleConnections() { | 439 void RenderThread::CloseIdleConnections() { |
426 Send(new ViewHostMsg_CloseIdleConnections()); | 440 Send(new ViewHostMsg_CloseIdleConnections()); |
427 } | 441 } |
428 | 442 |
429 void RenderThread::SetCacheMode(bool enabled) { | 443 void RenderThread::SetCacheMode(bool enabled) { |
430 Send(new ViewHostMsg_SetCacheMode(enabled)); | 444 Send(new ViewHostMsg_SetCacheMode(enabled)); |
431 } | 445 } |
432 | 446 |
| 447 #if defined(SPELLCHECKER_IN_RENDERER) |
| 448 void RenderThread::RequestSpellCheckDictionary() { |
| 449 Send(new ViewHostMsg_SpellChecker_RequestDictionary); |
| 450 } |
| 451 #endif |
| 452 |
433 static void* CreateHistogram( | 453 static void* CreateHistogram( |
434 const char *name, int min, int max, size_t buckets) { | 454 const char *name, int min, int max, size_t buckets) { |
435 Histogram* histogram = new Histogram(name, min, max, buckets); | 455 Histogram* histogram = new Histogram(name, min, max, buckets); |
436 if (histogram) { | 456 if (histogram) { |
437 histogram->SetFlags(kUmaTargetedHistogramFlag); | 457 histogram->SetFlags(kUmaTargetedHistogramFlag); |
438 } | 458 } |
439 return histogram; | 459 return histogram; |
440 } | 460 } |
441 | 461 |
442 static void AddHistogramSample(void* hist, int sample) { | 462 static void AddHistogramSample(void* hist, int sample) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 task_factory_->NewRunnableMethod(&RenderThread::IdleHandler), | 593 task_factory_->NewRunnableMethod(&RenderThread::IdleHandler), |
574 static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000); | 594 static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000); |
575 } | 595 } |
576 | 596 |
577 void RenderThread::OnExtensionMessageInvoke(const std::string& function_name, | 597 void RenderThread::OnExtensionMessageInvoke(const std::string& function_name, |
578 const ListValue& args) { | 598 const ListValue& args) { |
579 RendererExtensionBindings::Invoke(function_name, args, NULL); | 599 RendererExtensionBindings::Invoke(function_name, args, NULL); |
580 } | 600 } |
581 | 601 |
582 void RenderThread::OnPurgeMemory() { | 602 void RenderThread::OnPurgeMemory() { |
| 603 #if defined(SPELLCHECKER_IN_RENDERER) |
| 604 spellchecker_.reset(new SpellCheck()); |
| 605 #endif |
| 606 |
583 EnsureWebKitInitialized(); | 607 EnsureWebKitInitialized(); |
584 | 608 |
585 // Clear the object cache (as much as possible; some live objects cannot be | 609 // Clear the object cache (as much as possible; some live objects cannot be |
586 // freed). | 610 // freed). |
587 WebCache::clear(); | 611 WebCache::clear(); |
588 | 612 |
589 // Clear the font/glyph cache. | 613 // Clear the font/glyph cache. |
590 WebFontCache::clear(); | 614 WebFontCache::clear(); |
591 | 615 |
592 // Clear the Cross-Origin Preflight cache. | 616 // Clear the Cross-Origin Preflight cache. |
(...skipping 20 matching lines...) Expand all Loading... |
613 void RenderThread::OnPurgePluginListCache(bool reload_pages) { | 637 void RenderThread::OnPurgePluginListCache(bool reload_pages) { |
614 EnsureWebKitInitialized(); | 638 EnsureWebKitInitialized(); |
615 // The call below will cause a GetPlugins call with refresh=true, but at this | 639 // The call below will cause a GetPlugins call with refresh=true, but at this |
616 // point we already know that the browser has refreshed its list, so disable | 640 // point we already know that the browser has refreshed its list, so disable |
617 // refresh temporarily to prevent each renderer process causing the list to be | 641 // refresh temporarily to prevent each renderer process causing the list to be |
618 // regenerated. | 642 // regenerated. |
619 plugin_refresh_allowed_ = false; | 643 plugin_refresh_allowed_ = false; |
620 WebKit::resetPluginCache(reload_pages); | 644 WebKit::resetPluginCache(reload_pages); |
621 plugin_refresh_allowed_ = true; | 645 plugin_refresh_allowed_ = true; |
622 } | 646 } |
| 647 |
| 648 #if defined(SPELLCHECKER_IN_RENDERER) |
| 649 void RenderThread::OnInitSpellChecker( |
| 650 const base::FileDescriptor& bdict_fd, |
| 651 const std::vector<std::string>& custom_words, |
| 652 const std::string& language, |
| 653 bool auto_spell_correct) { |
| 654 spellchecker_->Init(bdict_fd, custom_words, language); |
| 655 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct); |
| 656 } |
| 657 |
| 658 void RenderThread::OnSpellCheckWordAdded(const std::string& word) { |
| 659 spellchecker_->WordAdded(word); |
| 660 } |
| 661 |
| 662 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { |
| 663 spellchecker_->EnableAutoSpellCorrect(enable); |
| 664 } |
| 665 #endif |
OLD | NEW |