Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/utility/utility_thread_impl.cc

Issue 34123003: Utility process: initialize GTK when the sandbox is disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix non-GTK compile. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/utility/utility_main.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "content/child/child_process.h" 12 #include "content/child/child_process.h"
13 #include "content/child/webkitplatformsupport_impl.h" 13 #include "content/child/webkitplatformsupport_impl.h"
14 #include "content/common/child_process_messages.h" 14 #include "content/common/child_process_messages.h"
15 #include "content/common/plugin_list.h" 15 #include "content/common/plugin_list.h"
16 #include "content/common/utility_messages.h" 16 #include "content/common/utility_messages.h"
17 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
18 #include "content/public/utility/content_utility_client.h" 18 #include "content/public/utility/content_utility_client.h"
19 #include "ipc/ipc_sync_channel.h" 19 #include "ipc/ipc_sync_channel.h"
20 #include "third_party/WebKit/public/web/WebKit.h" 20 #include "third_party/WebKit/public/web/WebKit.h"
21 21
22 #if defined(TOOLKIT_GTK)
23 #include <gtk/gtk.h>
24
25 #include "ui/gfx/gtk_util.h"
26 #endif
27
28 namespace content { 22 namespace content {
29 23
30 namespace { 24 namespace {
31 25
32 template<typename SRC, typename DEST> 26 template<typename SRC, typename DEST>
33 void ConvertVector(const SRC& src, DEST* dest) { 27 void ConvertVector(const SRC& src, DEST* dest) {
34 dest->reserve(src.size()); 28 dest->reserve(src.size());
35 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) 29 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i)
36 dest->push_back(typename DEST::value_type(*i)); 30 dest->push_back(typename DEST::value_type(*i));
37 } 31 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 119
126 void UtilityThreadImpl::OnBatchModeFinished() { 120 void UtilityThreadImpl::OnBatchModeFinished() {
127 ChildProcess::current()->ReleaseProcess(); 121 ChildProcess::current()->ReleaseProcess();
128 } 122 }
129 123
130 #if defined(OS_POSIX) 124 #if defined(OS_POSIX)
131 void UtilityThreadImpl::OnLoadPlugins( 125 void UtilityThreadImpl::OnLoadPlugins(
132 const std::vector<base::FilePath>& plugin_paths) { 126 const std::vector<base::FilePath>& plugin_paths) {
133 PluginList* plugin_list = PluginList::Singleton(); 127 PluginList* plugin_list = PluginList::Singleton();
134 128
135 // On Linux, some plugins expect the browser to have loaded glib/gtk. Do that
136 // before attempting to call into the plugin.
137 // g_thread_init API is deprecated since glib 2.31.0, please see release note:
138 // http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.ht ml
139 #if defined(TOOLKIT_GTK)
140 #if !(GLIB_CHECK_VERSION(2, 31, 0))
141 if (!g_thread_get_initialized()) {
142 g_thread_init(NULL);
143 }
144 #endif
145 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess());
146 #endif
147
148 std::vector<WebPluginInfo> plugins; 129 std::vector<WebPluginInfo> plugins;
149 // TODO(bauerb): If we restart loading plug-ins, we might mess up the logic in 130 // TODO(bauerb): If we restart loading plug-ins, we might mess up the logic in
150 // PluginList::ShouldLoadPlugin due to missing the previously loaded plug-ins 131 // PluginList::ShouldLoadPlugin due to missing the previously loaded plug-ins
151 // in |plugin_groups|. 132 // in |plugin_groups|.
152 for (size_t i = 0; i < plugin_paths.size(); ++i) { 133 for (size_t i = 0; i < plugin_paths.size(); ++i) {
153 WebPluginInfo plugin; 134 WebPluginInfo plugin;
154 if (!plugin_list->LoadPluginIntoPluginList( 135 if (!plugin_list->LoadPluginIntoPluginList(
155 plugin_paths[i], &plugins, &plugin)) 136 plugin_paths[i], &plugins, &plugin))
156 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i])); 137 Send(new UtilityHostMsg_LoadPluginFailed(i, plugin_paths[i]));
157 else 138 else
158 Send(new UtilityHostMsg_LoadedPlugin(i, plugin)); 139 Send(new UtilityHostMsg_LoadedPlugin(i, plugin));
159 } 140 }
160 141
161 ReleaseProcessIfNeeded(); 142 ReleaseProcessIfNeeded();
162 } 143 }
163 #endif 144 #endif
164 145
165 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « content/utility/utility_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698