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/file_path.h" | 10 #include "base/file_path.h" |
10 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
11 #include "content/common/child_process.h" | 12 #include "content/common/child_process.h" |
12 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
13 #include "content/common/indexed_db_key.h" | 14 #include "content/common/indexed_db_key.h" |
14 #include "content/common/utility_messages.h" | 15 #include "content/common/utility_messages.h" |
15 #include "content/common/webkitplatformsupport_impl.h" | 16 #include "content/common/webkitplatformsupport_impl.h" |
16 #include "content/public/utility/content_utility_client.h" | 17 #include "content/public/utility/content_utility_client.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" |
20 #include "webkit/glue/idb_bindings.h" | 21 #include "webkit/glue/idb_bindings.h" |
21 #include "webkit/plugins/npapi/plugin_list.h" | 22 #include "webkit/plugins/npapi/plugin_list.h" |
22 | 23 |
| 24 #if defined(TOOLKIT_USES_GTK) |
| 25 #include <gtk/gtk.h> |
| 26 |
| 27 #include "ui/gfx/gtk_util.h" |
| 28 #endif |
| 29 |
23 namespace { | 30 namespace { |
24 | 31 |
25 template<typename SRC, typename DEST> | 32 template<typename SRC, typename DEST> |
26 void ConvertVector(const SRC& src, DEST* dest) { | 33 void ConvertVector(const SRC& src, DEST* dest) { |
27 dest->reserve(src.size()); | 34 dest->reserve(src.size()); |
28 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) | 35 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) |
29 dest->push_back(typename DEST::value_type(*i)); | 36 dest->push_back(typename DEST::value_type(*i)); |
30 } | 37 } |
31 | 38 |
32 } // namespace | 39 } // namespace |
33 | 40 |
34 UtilityThreadImpl::UtilityThreadImpl() | 41 UtilityThreadImpl::UtilityThreadImpl() |
35 : batch_mode_(false) { | 42 : batch_mode_(false) { |
36 ChildProcess::current()->AddRefProcess(); | 43 ChildProcess::current()->AddRefProcess(); |
37 webkit_platform_support_.reset(new content::WebKitPlatformSupportImpl); | 44 webkit_platform_support_.reset(new content::WebKitPlatformSupportImpl); |
38 WebKit::initialize(webkit_platform_support_.get()); | 45 WebKit::initialize(webkit_platform_support_.get()); |
39 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 |
40 } | 54 } |
41 | 55 |
42 UtilityThreadImpl::~UtilityThreadImpl() { | 56 UtilityThreadImpl::~UtilityThreadImpl() { |
43 WebKit::shutdown(); | 57 WebKit::shutdown(); |
44 } | 58 } |
45 | 59 |
46 bool UtilityThreadImpl::Send(IPC::Message* msg) { | 60 bool UtilityThreadImpl::Send(IPC::Message* msg) { |
47 return ChildThread::Send(msg); | 61 return ChildThread::Send(msg); |
48 } | 62 } |
49 | 63 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const webkit::npapi::PluginGroup* group = plugin_groups[0]; | 153 const webkit::npapi::PluginGroup* group = plugin_groups[0]; |
140 DCHECK_EQ(group->web_plugin_infos().size(), 1u); | 154 DCHECK_EQ(group->web_plugin_infos().size(), 1u); |
141 | 155 |
142 Send(new UtilityHostMsg_LoadedPlugin(i, group->web_plugin_infos().front())); | 156 Send(new UtilityHostMsg_LoadedPlugin(i, group->web_plugin_infos().front())); |
143 } | 157 } |
144 | 158 |
145 ReleaseProcessIfNeeded(); | 159 ReleaseProcessIfNeeded(); |
146 } | 160 } |
147 #endif | 161 #endif |
148 | 162 |
OLD | NEW |