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/debug/leak_annotations.h" |
13 #include "base/environment.h" | 13 #include "base/environment.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
17 #include "ui/base/accelerators/accelerator.h" | 17 #include "ui/base/accelerators/accelerator.h" |
18 #include "ui/events/event_constants.h" | 18 #include "ui/events/event_constants.h" |
19 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 19 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
20 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kAuraTransientParent[] = "aura-transient-parent"; | 24 const char kAuraTransientParent[] = "aura-transient-parent"; |
25 | 25 |
26 void CommonInitFromCommandLine(const CommandLine& command_line, | 26 void CommonInitFromCommandLine(const base::CommandLine& command_line, |
27 void (*init_func)(gint*, gchar***)) { | 27 void (*init_func)(gint*, gchar***)) { |
28 const std::vector<std::string>& args = command_line.argv(); | 28 const std::vector<std::string>& args = command_line.argv(); |
29 int argc = args.size(); | 29 int argc = args.size(); |
30 scoped_ptr<char *[]> argv(new char *[argc + 1]); | 30 scoped_ptr<char *[]> argv(new char *[argc + 1]); |
31 for (size_t i = 0; i < args.size(); ++i) { | 31 for (size_t i = 0; i < args.size(); ++i) { |
32 // 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 |
33 // here. | 33 // here. |
34 argv[i] = strdup(args[i].c_str()); | 34 argv[i] = strdup(args[i].c_str()); |
35 } | 35 } |
36 argv[argc] = NULL; | 36 argv[argc] = NULL; |
37 char **argv_pointer = argv.get(); | 37 char **argv_pointer = argv.get(); |
38 | 38 |
39 { | 39 { |
40 // http://crbug.com/423873 | 40 // http://crbug.com/423873 |
41 ANNOTATE_SCOPED_MEMORY_LEAK; | 41 ANNOTATE_SCOPED_MEMORY_LEAK; |
42 init_func(&argc, &argv_pointer); | 42 init_func(&argc, &argv_pointer); |
43 } | 43 } |
44 for (size_t i = 0; i < args.size(); ++i) { | 44 for (size_t i = 0; i < args.size(); ++i) { |
45 free(argv[i]); | 45 free(argv[i]); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 namespace libgtk2ui { | 51 namespace libgtk2ui { |
52 | 52 |
53 void GtkInitFromCommandLine(const CommandLine& command_line) { | 53 void GtkInitFromCommandLine(const base::CommandLine& command_line) { |
54 CommonInitFromCommandLine(command_line, gtk_init); | 54 CommonInitFromCommandLine(command_line, gtk_init); |
55 } | 55 } |
56 | 56 |
57 // TODO(erg): This method was copied out of shell_integration_linux.cc. Because | 57 // TODO(erg): This method was copied out of shell_integration_linux.cc. Because |
58 // of how this library is structured as a stand alone .so, we can't call code | 58 // of how this library is structured as a stand alone .so, we can't call code |
59 // from browser and above. | 59 // from browser and above. |
60 std::string GetDesktopName(base::Environment* env) { | 60 std::string GetDesktopName(base::Environment* env) { |
61 #if defined(GOOGLE_CHROME_BUILD) | 61 #if defined(GOOGLE_CHROME_BUILD) |
62 return "google-chrome.desktop"; | 62 return "google-chrome.desktop"; |
63 #else // CHROMIUM_BUILD | 63 #else // CHROMIUM_BUILD |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 case ui::NativeTheme::kDisabled: return GTK_STATE_INSENSITIVE; | 140 case ui::NativeTheme::kDisabled: return GTK_STATE_INSENSITIVE; |
141 case ui::NativeTheme::kHovered: return GTK_STATE_PRELIGHT; | 141 case ui::NativeTheme::kHovered: return GTK_STATE_PRELIGHT; |
142 case ui::NativeTheme::kNormal: return GTK_STATE_NORMAL; | 142 case ui::NativeTheme::kNormal: return GTK_STATE_NORMAL; |
143 case ui::NativeTheme::kPressed: return GTK_STATE_ACTIVE; | 143 case ui::NativeTheme::kPressed: return GTK_STATE_ACTIVE; |
144 case ui::NativeTheme::kNumStates: NOTREACHED(); | 144 case ui::NativeTheme::kNumStates: NOTREACHED(); |
145 } | 145 } |
146 return GTK_STATE_NORMAL; | 146 return GTK_STATE_NORMAL; |
147 } | 147 } |
148 | 148 |
149 } // namespace libgtk2ui | 149 } // namespace libgtk2ui |
OLD | NEW |