| 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 #include "chrome/renderer/render_thread.h" | 5 #include "chrome/renderer/render_thread.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 17 #include "base/metrics/stats_table.h" | 17 #include "base/metrics/stats_table.h" |
| 18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 19 #include "base/shared_memory.h" | 19 #include "base/shared_memory.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/task.h" | 21 #include "base/task.h" |
| 22 #include "base/threading/thread_local.h" | 22 #include "base/threading/thread_local.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "base/values.h" | 24 #include "base/values.h" |
| 25 #include "chrome/common/child_process_logging.h" | 25 #include "chrome/common/child_process_logging.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 28 #include "chrome/common/extensions/extension_localization_peer.h" | 28 #include "chrome/common/extensions/extension_localization_peer.h" |
| 29 #include "chrome/common/extensions/extension_messages.h" |
| 29 #include "chrome/common/extensions/extension_set.h" | 30 #include "chrome/common/extensions/extension_set.h" |
| 30 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
| 31 #include "chrome/common/spellcheck_messages.h" | 32 #include "chrome/common/spellcheck_messages.h" |
| 32 #include "chrome/common/safebrowsing_messages.h" | 33 #include "chrome/common/safebrowsing_messages.h" |
| 33 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/renderer/automation/dom_automation_v8_extension.h" | 35 #include "chrome/renderer/automation/dom_automation_v8_extension.h" |
| 35 #include "chrome/renderer/devtools_agent_filter.h" | 36 #include "chrome/renderer/devtools_agent_filter.h" |
| 36 #include "chrome/renderer/extension_groups.h" | 37 #include "chrome/renderer/extension_groups.h" |
| 37 #include "chrome/renderer/extensions/chrome_app_bindings.h" | 38 #include "chrome/renderer/extensions/chrome_app_bindings.h" |
| 38 #include "chrome/renderer/extensions/event_bindings.h" | 39 #include "chrome/renderer/extensions/event_bindings.h" |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; | 572 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; |
| 572 user_script_slave_->UpdateScripts(scripts); | 573 user_script_slave_->UpdateScripts(scripts); |
| 573 UpdateActiveExtensions(); | 574 UpdateActiveExtensions(); |
| 574 } | 575 } |
| 575 | 576 |
| 576 void RenderThread::OnSetExtensionFunctionNames( | 577 void RenderThread::OnSetExtensionFunctionNames( |
| 577 const std::vector<std::string>& names) { | 578 const std::vector<std::string>& names) { |
| 578 ExtensionProcessBindings::SetFunctionNames(names); | 579 ExtensionProcessBindings::SetFunctionNames(names); |
| 579 } | 580 } |
| 580 | 581 |
| 581 void RenderThread::OnExtensionLoaded( | 582 void RenderThread::OnExtensionLoaded(const ExtensionMsg_Loaded_Params& params) { |
| 582 const ViewMsg_ExtensionLoaded_Params& params) { | |
| 583 scoped_refptr<const Extension> extension(params.ConvertToExtension()); | 583 scoped_refptr<const Extension> extension(params.ConvertToExtension()); |
| 584 if (!extension) { | 584 if (!extension) { |
| 585 // This can happen if extension parsing fails for any reason. One reason | 585 // This can happen if extension parsing fails for any reason. One reason |
| 586 // this can legitimately happen is if the | 586 // this can legitimately happen is if the |
| 587 // --enable-experimental-extension-apis changes at runtime, which happens | 587 // --enable-experimental-extension-apis changes at runtime, which happens |
| 588 // during browser tests. Existing renderers won't know about the change. | 588 // during browser tests. Existing renderers won't know about the change. |
| 589 return; | 589 return; |
| 590 } | 590 } |
| 591 | 591 |
| 592 extensions_.Insert(extension); | 592 extensions_.Insert(extension); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 IPC_MESSAGE_HANDLER(ViewMsg_ClearCache, OnClearCache) | 659 IPC_MESSAGE_HANDLER(ViewMsg_ClearCache, OnClearCache) |
| 660 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, OnGetRendererHistograms) | 660 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, OnGetRendererHistograms) |
| 661 #if defined(USE_TCMALLOC) | 661 #if defined(USE_TCMALLOC) |
| 662 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, OnGetRendererTcmalloc) | 662 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, OnGetRendererTcmalloc) |
| 663 #endif | 663 #endif |
| 664 IPC_MESSAGE_HANDLER(ViewMsg_GetV8HeapStats, OnGetV8HeapStats) | 664 IPC_MESSAGE_HANDLER(ViewMsg_GetV8HeapStats, OnGetV8HeapStats) |
| 665 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) | 665 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) |
| 666 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts, OnUpdateUserScripts) | 666 IPC_MESSAGE_HANDLER(ViewMsg_UserScripts_UpdatedScripts, OnUpdateUserScripts) |
| 667 // TODO(rafaelw): create an ExtensionDispatcher that handles extension | 667 // TODO(rafaelw): create an ExtensionDispatcher that handles extension |
| 668 // messages seperates their handling from the RenderThread. | 668 // messages seperates their handling from the RenderThread. |
| 669 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionMessageInvoke, | 669 IPC_MESSAGE_HANDLER(ExtensionMsg_MessageInvoke, OnExtensionMessageInvoke) |
| 670 OnExtensionMessageInvoke) | 670 IPC_MESSAGE_HANDLER(ExtensionMsg_SetFunctionNames, |
| 671 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetFunctionNames, | |
| 672 OnSetExtensionFunctionNames) | 671 OnSetExtensionFunctionNames) |
| 673 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionLoaded, OnExtensionLoaded) | 672 IPC_MESSAGE_HANDLER(ExtensionMsg_Loaded, OnExtensionLoaded) |
| 674 IPC_MESSAGE_HANDLER(ViewMsg_ExtensionUnloaded, OnExtensionUnloaded) | 673 IPC_MESSAGE_HANDLER(ExtensionMsg_Unloaded, OnExtensionUnloaded) |
| 675 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetScriptingWhitelist, | 674 IPC_MESSAGE_HANDLER(ExtensionMsg_SetScriptingWhitelist, |
| 676 OnSetExtensionScriptingWhitelist) | 675 OnSetExtensionScriptingWhitelist) |
| 677 IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory) | 676 IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory) |
| 678 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | 677 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) |
| 679 IPC_MESSAGE_HANDLER(ViewMsg_Extension_UpdatePageActions, | 678 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdatePageActions, OnPageActionsUpdated) |
| 680 OnPageActionsUpdated) | 679 IPC_MESSAGE_HANDLER(ExtensionMsg_SetAPIPermissions, |
| 681 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetAPIPermissions, | |
| 682 OnExtensionSetAPIPermissions) | 680 OnExtensionSetAPIPermissions) |
| 683 IPC_MESSAGE_HANDLER(ViewMsg_Extension_SetHostPermissions, | 681 IPC_MESSAGE_HANDLER(ExtensionMsg_SetHostPermissions, |
| 684 OnExtensionSetHostPermissions) | 682 OnExtensionSetHostPermissions) |
| 685 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) | 683 IPC_MESSAGE_HANDLER(DOMStorageMsg_Event, OnDOMStorageEvent) |
| 686 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInitSpellChecker) | 684 IPC_MESSAGE_HANDLER(SpellCheckMsg_Init, OnInitSpellChecker) |
| 687 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnSpellCheckWordAdded) | 685 IPC_MESSAGE_HANDLER(SpellCheckMsg_WordAdded, OnSpellCheckWordAdded) |
| 688 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, | 686 IPC_MESSAGE_HANDLER(SpellCheckMsg_EnableAutoSpellCorrect, |
| 689 OnSpellCheckEnableAutoSpellCorrect) | 687 OnSpellCheckEnableAutoSpellCorrect) |
| 690 IPC_MESSAGE_HANDLER(GpuMsg_GpuChannelEstablished, OnGpuChannelEstablished) | 688 IPC_MESSAGE_HANDLER(GpuMsg_GpuChannelEstablished, OnGpuChannelEstablished) |
| 691 IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel) | 689 IPC_MESSAGE_HANDLER(SafeBrowsingMsg_SetPhishingModel, OnSetPhishingModel) |
| 692 IPC_MESSAGE_UNHANDLED(handled = false) | 690 IPC_MESSAGE_UNHANDLED(handled = false) |
| 693 IPC_END_MESSAGE_MAP() | 691 IPC_END_MESSAGE_MAP() |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 } | 1169 } |
| 1172 | 1170 |
| 1173 return false; | 1171 return false; |
| 1174 } | 1172 } |
| 1175 | 1173 |
| 1176 void RenderThread::RegisterExtension(v8::Extension* extension, | 1174 void RenderThread::RegisterExtension(v8::Extension* extension, |
| 1177 bool restrict_to_extensions) { | 1175 bool restrict_to_extensions) { |
| 1178 WebScriptController::registerExtension(extension); | 1176 WebScriptController::registerExtension(extension); |
| 1179 v8_extensions_[extension->name()] = restrict_to_extensions; | 1177 v8_extensions_[extension->name()] = restrict_to_extensions; |
| 1180 } | 1178 } |
| OLD | NEW |