| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/utility/utility_thread_impl.h" | 5 #include "content/utility/utility_thread_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 12 #include "content/child/blink_platform_impl.h" | 11 #include "content/child/blink_platform_impl.h" |
| 13 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
| 14 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
| 15 #include "content/common/plugin_list.h" | |
| 16 #include "content/common/utility_messages.h" | 14 #include "content/common/utility_messages.h" |
| 17 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/utility/content_utility_client.h" | 16 #include "content/public/utility/content_utility_client.h" |
| 19 #include "ipc/ipc_sync_channel.h" | 17 #include "ipc/ipc_sync_channel.h" |
| 20 #include "third_party/WebKit/public/web/WebKit.h" | 18 #include "third_party/WebKit/public/web/WebKit.h" |
| 21 | 19 |
| 20 #if defined(OS_POSIX) && defined(ENABLE_PLUGINS) |
| 21 #include "base/files/file_path.h" |
| 22 #include "content/common/plugin_list.h" |
| 23 #endif |
| 24 |
| 22 namespace content { | 25 namespace content { |
| 23 | 26 |
| 24 namespace { | 27 namespace { |
| 25 | 28 |
| 26 template<typename SRC, typename DEST> | 29 template<typename SRC, typename DEST> |
| 27 void ConvertVector(const SRC& src, DEST* dest) { | 30 void ConvertVector(const SRC& src, DEST* dest) { |
| 28 dest->reserve(src.size()); | 31 dest->reserve(src.size()); |
| 29 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) | 32 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) |
| 30 dest->push_back(typename DEST::value_type(*i)); | 33 dest->push_back(typename DEST::value_type(*i)); |
| 31 } | 34 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 101 } |
| 99 | 102 |
| 100 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 103 bool UtilityThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 101 if (GetContentClient()->utility()->OnMessageReceived(msg)) | 104 if (GetContentClient()->utility()->OnMessageReceived(msg)) |
| 102 return true; | 105 return true; |
| 103 | 106 |
| 104 bool handled = true; | 107 bool handled = true; |
| 105 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) | 108 IPC_BEGIN_MESSAGE_MAP(UtilityThreadImpl, msg) |
| 106 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 109 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
| 107 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 110 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
| 108 #if defined(OS_POSIX) | 111 #if defined(OS_POSIX) && defined(ENABLE_PLUGINS) |
| 109 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) | 112 IPC_MESSAGE_HANDLER(UtilityMsg_LoadPlugins, OnLoadPlugins) |
| 110 #endif // OS_POSIX | 113 #endif |
| 111 IPC_MESSAGE_UNHANDLED(handled = false) | 114 IPC_MESSAGE_UNHANDLED(handled = false) |
| 112 IPC_END_MESSAGE_MAP() | 115 IPC_END_MESSAGE_MAP() |
| 113 return handled; | 116 return handled; |
| 114 } | 117 } |
| 115 | 118 |
| 116 void UtilityThreadImpl::OnBatchModeStarted() { | 119 void UtilityThreadImpl::OnBatchModeStarted() { |
| 117 batch_mode_ = true; | 120 batch_mode_ = true; |
| 118 } | 121 } |
| 119 | 122 |
| 120 void UtilityThreadImpl::OnBatchModeFinished() { | 123 void UtilityThreadImpl::OnBatchModeFinished() { |
| 121 batch_mode_ = false; | 124 batch_mode_ = false; |
| 122 ReleaseProcessIfNeeded(); | 125 ReleaseProcessIfNeeded(); |
| 123 } | 126 } |
| 124 | 127 |
| 125 #if defined(OS_POSIX) | 128 #if defined(OS_POSIX) && defined(ENABLE_PLUGINS) |
| 126 void UtilityThreadImpl::OnLoadPlugins( | 129 void UtilityThreadImpl::OnLoadPlugins( |
| 127 const std::vector<base::FilePath>& plugin_paths) { | 130 const std::vector<base::FilePath>& plugin_paths) { |
| 128 PluginList* plugin_list = PluginList::Singleton(); | 131 PluginList* plugin_list = PluginList::Singleton(); |
| 129 | 132 |
| 130 std::vector<WebPluginInfo> plugins; | 133 std::vector<WebPluginInfo> plugins; |
| 131 // TODO(bauerb): If we restart loading plug-ins, we might mess up the logic in | 134 // TODO(bauerb): If we restart loading plug-ins, we might mess up the logic in |
| 132 // PluginList::ShouldLoadPlugin due to missing the previously loaded plug-ins | 135 // PluginList::ShouldLoadPlugin due to missing the previously loaded plug-ins |
| 133 // in |plugin_groups|. | 136 // in |plugin_groups|. |
| 134 for (size_t i = 0; i < plugin_paths.size(); ++i) { | 137 for (size_t i = 0; i < plugin_paths.size(); ++i) { |
| 135 WebPluginInfo plugin; | 138 WebPluginInfo plugin; |
| 136 if (!plugin_list->LoadPluginIntoPluginList( | 139 if (!plugin_list->LoadPluginIntoPluginList( |
| 137 plugin_paths[i], &plugins, &plugin)) | 140 plugin_paths[i], &plugins, &plugin)) |
| 138 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); | 141 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); |
| 139 else | 142 else |
| 140 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); | 143 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); |
| 141 } | 144 } |
| 142 | 145 |
| 143 ReleaseProcessIfNeeded(); | 146 ReleaseProcessIfNeeded(); |
| 144 } | 147 } |
| 145 #endif | 148 #endif |
| 146 | 149 |
| 147 } // namespace content | 150 } // namespace content |
| OLD | NEW |