| 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 "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/debug/leak_annotations.h" |
| 12 #include "base/environment.h" | 13 #include "base/environment.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
| 16 #include "ui/base/accelerators/accelerator.h" | 17 #include "ui/base/accelerators/accelerator.h" |
| 17 #include "ui/events/event_constants.h" | 18 #include "ui/events/event_constants.h" |
| 18 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 19 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 19 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const char kAuraTransientParent[] = "aura-transient-parent"; | 24 const char kAuraTransientParent[] = "aura-transient-parent"; |
| 24 | 25 |
| 25 void CommonInitFromCommandLine(const CommandLine& command_line, | 26 void CommonInitFromCommandLine(const CommandLine& command_line, |
| 26 void (*init_func)(gint*, gchar***)) { | 27 void (*init_func)(gint*, gchar***)) { |
| 27 const std::vector<std::string>& args = command_line.argv(); | 28 const std::vector<std::string>& args = command_line.argv(); |
| 28 int argc = args.size(); | 29 int argc = args.size(); |
| 29 scoped_ptr<char *[]> argv(new char *[argc + 1]); | 30 scoped_ptr<char *[]> argv(new char *[argc + 1]); |
| 30 for (size_t i = 0; i < args.size(); ++i) { | 31 for (size_t i = 0; i < args.size(); ++i) { |
| 31 // TODO(piman@google.com): can gtk_init modify argv? Just being safe | 32 // TODO(piman@google.com): can gtk_init modify argv? Just being safe |
| 32 // here. | 33 // here. |
| 33 argv[i] = strdup(args[i].c_str()); | 34 argv[i] = strdup(args[i].c_str()); |
| 34 } | 35 } |
| 35 argv[argc] = NULL; | 36 argv[argc] = NULL; |
| 36 char **argv_pointer = argv.get(); | 37 char **argv_pointer = argv.get(); |
| 37 | 38 |
| 38 init_func(&argc, &argv_pointer); | 39 { |
| 40 // http://crbug.com/423873 |
| 41 ANNOTATE_SCOPED_MEMORY_LEAK; |
| 42 init_func(&argc, &argv_pointer); |
| 43 } |
| 39 for (size_t i = 0; i < args.size(); ++i) { | 44 for (size_t i = 0; i < args.size(); ++i) { |
| 40 free(argv[i]); | 45 free(argv[i]); |
| 41 } | 46 } |
| 42 } | 47 } |
| 43 | 48 |
| 44 } // namespace | 49 } // namespace |
| 45 | 50 |
| 46 namespace libgtk2ui { | 51 namespace libgtk2ui { |
| 47 | 52 |
| 48 void GtkInitFromCommandLine(const CommandLine& command_line) { | 53 void GtkInitFromCommandLine(const CommandLine& command_line) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 case ui::NativeTheme::kDisabled: return GTK_STATE_INSENSITIVE; | 140 case ui::NativeTheme::kDisabled: return GTK_STATE_INSENSITIVE; |
| 136 case ui::NativeTheme::kHovered: return GTK_STATE_PRELIGHT; | 141 case ui::NativeTheme::kHovered: return GTK_STATE_PRELIGHT; |
| 137 case ui::NativeTheme::kNormal: return GTK_STATE_NORMAL; | 142 case ui::NativeTheme::kNormal: return GTK_STATE_NORMAL; |
| 138 case ui::NativeTheme::kPressed: return GTK_STATE_ACTIVE; | 143 case ui::NativeTheme::kPressed: return GTK_STATE_ACTIVE; |
| 139 case ui::NativeTheme::kNumStates: NOTREACHED(); | 144 case ui::NativeTheme::kNumStates: NOTREACHED(); |
| 140 } | 145 } |
| 141 return GTK_STATE_NORMAL; | 146 return GTK_STATE_NORMAL; |
| 142 } | 147 } |
| 143 | 148 |
| 144 } // namespace libgtk2ui | 149 } // namespace libgtk2ui |
| OLD | NEW |