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 "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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 UtilityThreadImpl::UtilityThreadImpl() | 41 UtilityThreadImpl::UtilityThreadImpl() |
42 : batch_mode_(false) { | 42 : batch_mode_(false) { |
43 ChildProcess::current()->AddRefProcess(); | 43 ChildProcess::current()->AddRefProcess(); |
44 webkit_platform_support_.reset(new content::WebKitPlatformSupportImpl); | 44 webkit_platform_support_.reset(new content::WebKitPlatformSupportImpl); |
45 WebKit::initialize(webkit_platform_support_.get()); | 45 WebKit::initialize(webkit_platform_support_.get()); |
46 content::GetContentClient()->utility()->UtilityThreadStarted(); | 46 content::GetContentClient()->utility()->UtilityThreadStarted(); |
47 | |
48 // On Linux, some plugins expect the browser to have loaded glib/gtk. Do that | |
49 // before attempting to call into the plugin. | |
50 #if defined(TOOLKIT_USES_GTK) | |
51 g_thread_init(NULL); | |
52 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); | |
53 #endif | |
54 } | 47 } |
55 | 48 |
56 UtilityThreadImpl::~UtilityThreadImpl() { | 49 UtilityThreadImpl::~UtilityThreadImpl() { |
57 WebKit::shutdown(); | 50 WebKit::shutdown(); |
58 } | 51 } |
59 | 52 |
60 bool UtilityThreadImpl::Send(IPC::Message* msg) { | 53 bool UtilityThreadImpl::Send(IPC::Message* msg) { |
61 return ChildThread::Send(msg); | 54 return ChildThread::Send(msg); |
62 } | 55 } |
63 | 56 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void UtilityThreadImpl::OnBatchModeFinished() { | 127 void UtilityThreadImpl::OnBatchModeFinished() { |
135 ChildProcess::current()->ReleaseProcess(); | 128 ChildProcess::current()->ReleaseProcess(); |
136 } | 129 } |
137 | 130 |
138 #if defined(OS_POSIX) | 131 #if defined(OS_POSIX) |
139 void UtilityThreadImpl::OnLoadPlugins( | 132 void UtilityThreadImpl::OnLoadPlugins( |
140 const std::vector<FilePath>& plugin_paths) { | 133 const std::vector<FilePath>& plugin_paths) { |
141 webkit::npapi::PluginList* plugin_list = | 134 webkit::npapi::PluginList* plugin_list = |
142 webkit::npapi::PluginList::Singleton(); | 135 webkit::npapi::PluginList::Singleton(); |
143 | 136 |
| 137 // On Linux, some plugins expect the browser to have loaded glib/gtk. Do that |
| 138 // before attempting to call into the plugin. |
| 139 #if defined(TOOLKIT_USES_GTK) |
| 140 CHECK(!g_thread_get_initialized()); |
| 141 g_thread_init(NULL); |
| 142 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); |
| 143 #endif |
| 144 |
144 for (size_t i = 0; i < plugin_paths.size(); ++i) { | 145 for (size_t i = 0; i < plugin_paths.size(); ++i) { |
145 ScopedVector<webkit::npapi::PluginGroup> plugin_groups; | 146 ScopedVector<webkit::npapi::PluginGroup> plugin_groups; |
146 plugin_list->LoadPlugin(plugin_paths[i], &plugin_groups); | 147 plugin_list->LoadPlugin(plugin_paths[i], &plugin_groups); |
147 | 148 |
148 if (plugin_groups.empty()) { | 149 if (plugin_groups.empty()) { |
149 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); | 150 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); |
150 continue; | 151 continue; |
151 } | 152 } |
152 | 153 |
153 const webkit::npapi::PluginGroup* group = plugin_groups[0]; | 154 const webkit::npapi::PluginGroup* group = plugin_groups[0]; |
154 DCHECK_EQ(group->web_plugin_infos().size(), 1u); | 155 DCHECK_EQ(group->web_plugin_infos().size(), 1u); |
155 | 156 |
156 Send(new UtilityHostMsg_LoadedPlugin(i, group->web_plugin_infos().front())); | 157 Send(new UtilityHostMsg_LoadedPlugin(i, group->web_plugin_infos().front())); |
157 } | 158 } |
158 | 159 |
159 ReleaseProcessIfNeeded(); | 160 ReleaseProcessIfNeeded(); |
160 } | 161 } |
161 #endif | 162 #endif |
162 | 163 |
OLD | NEW |