| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| 6 |
| 7 #include <gtk/gtk.h> |
| 8 |
| 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 void CommonInitFromCommandLine(const CommandLine& command_line, |
| 15 void (*init_func)(gint*, gchar***)) { |
| 16 const std::vector<std::string>& args = command_line.argv(); |
| 17 int argc = args.size(); |
| 18 scoped_array<char *> argv(new char *[argc + 1]); |
| 19 for (size_t i = 0; i < args.size(); ++i) { |
| 20 // TODO(piman@google.com): can gtk_init modify argv? Just being safe |
| 21 // here. |
| 22 argv[i] = strdup(args[i].c_str()); |
| 23 } |
| 24 argv[argc] = NULL; |
| 25 char **argv_pointer = argv.get(); |
| 26 |
| 27 init_func(&argc, &argv_pointer); |
| 28 for (size_t i = 0; i < args.size(); ++i) { |
| 29 free(argv[i]); |
| 30 } |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
| 35 namespace libgtk2ui { |
| 36 |
| 37 void GtkInitFromCommandLine(const CommandLine& command_line) { |
| 38 CommonInitFromCommandLine(command_line, gtk_init); |
| 39 } |
| 40 |
| 41 } // namespace libgtk2ui |
| OLD | NEW |