Chromium Code Reviews| 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 "content/shell/shell.h" | 5 #include "content/shell/shell.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 15 #include "content/public/browser/native_web_keyboard_event.h" | 15 #include "content/public/browser/native_web_keyboard_event.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/browser/web_contents_view.h" | 17 #include "content/public/browser/web_contents_view.h" |
| 18 #include "content/public/common/renderer_preferences.h" | 18 #include "content/public/common/renderer_preferences.h" |
| 19 #include "content/shell/shell_browser_context.h" | |
| 20 #include "content/shell/shell_content_browser_client.h" | |
| 19 #include "content/shell/shell_switches.h" | 21 #include "content/shell/shell_switches.h" |
| 20 #include "third_party/skia/include/core/SkColor.h" | 22 #include "third_party/skia/include/core/SkColor.h" |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 | 25 |
| 24 void Shell::PlatformInitialize() { | 26 void Shell::PlatformInitialize() { |
| 25 } | 27 } |
| 26 | 28 |
| 27 base::StringPiece Shell::PlatformResourceProvider(int key) { | 29 base::StringPiece Shell::PlatformResourceProvider(int key) { |
| 28 NOTIMPLEMENTED(); | 30 NOTIMPLEMENTED(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 GtkAccelGroup* accel_group = gtk_accel_group_new(); | 77 GtkAccelGroup* accel_group = gtk_accel_group_new(); |
| 76 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); | 78 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); |
| 77 | 79 |
| 78 // Set global window handling accelerators: | 80 // Set global window handling accelerators: |
| 79 gtk_accel_group_connect( | 81 gtk_accel_group_connect( |
| 80 accel_group, GDK_w, GDK_CONTROL_MASK, | 82 accel_group, GDK_w, GDK_CONTROL_MASK, |
| 81 GTK_ACCEL_VISIBLE, | 83 GTK_ACCEL_VISIBLE, |
| 82 g_cclosure_new(G_CALLBACK(OnCloseWindowKeyPressedThunk), | 84 g_cclosure_new(G_CALLBACK(OnCloseWindowKeyPressedThunk), |
| 83 this, NULL)); | 85 this, NULL)); |
| 84 | 86 |
| 87 gtk_accel_group_connect( | |
| 88 accel_group, GDK_n, GDK_CONTROL_MASK, | |
| 89 GTK_ACCEL_VISIBLE, | |
| 90 g_cclosure_new(G_CALLBACK(OnNewWindowKeyPressedThunk), | |
| 91 this, NULL)); | |
| 92 | |
| 85 GtkWidget* toolbar = gtk_toolbar_new(); | 93 GtkWidget* toolbar = gtk_toolbar_new(); |
| 86 // Turn off the labels on the toolbar buttons. | 94 // Turn off the labels on the toolbar buttons. |
| 87 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); | 95 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); |
| 88 | 96 |
| 89 back_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); | 97 back_button_ = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK); |
| 90 g_signal_connect(back_button_, "clicked", | 98 g_signal_connect(back_button_, "clicked", |
| 91 G_CALLBACK(&OnBackButtonClickedThunk), this); | 99 G_CALLBACK(&OnBackButtonClickedThunk), this); |
| 92 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back_button_, -1 /* append */); | 100 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), back_button_, -1 /* append */); |
| 93 gtk_widget_add_accelerator(GTK_WIDGET(back_button_), "clicked", accel_group, | 101 gtk_widget_add_accelerator(GTK_WIDGET(back_button_), "clicked", accel_group, |
| 94 GDK_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); | 102 GDK_Left, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 } | 225 } |
| 218 | 226 |
| 219 gboolean Shell::OnCloseWindowKeyPressed(GtkAccelGroup* accel_group, | 227 gboolean Shell::OnCloseWindowKeyPressed(GtkAccelGroup* accel_group, |
| 220 GObject* acceleratable, | 228 GObject* acceleratable, |
| 221 guint keyval, | 229 guint keyval, |
| 222 GdkModifierType modifier) { | 230 GdkModifierType modifier) { |
| 223 gtk_widget_destroy(GTK_WIDGET(window_)); | 231 gtk_widget_destroy(GTK_WIDGET(window_)); |
| 224 return TRUE; | 232 return TRUE; |
| 225 } | 233 } |
| 226 | 234 |
| 235 gboolean Shell::OnNewWindowKeyPressed(GtkAccelGroup* accel_group, | |
| 236 GObject* acceleratable, | |
| 237 guint keyval, | |
| 238 GdkModifierType modifier) { | |
| 239 ShellBrowserContext* browserContext = | |
|
jochen (gone - plz use gerrit)
2012/08/09 08:34:25
browser_context
Shouqun Liu
2012/08/09 08:39:50
Done.
| |
| 240 static_cast<ShellContentBrowserClient*>( | |
| 241 GetContentClient()->browser())->browser_context(); | |
| 242 Shell::CreateNewWindow(browserContext, | |
| 243 GURL(), | |
| 244 NULL, | |
| 245 MSG_ROUTING_NONE, | |
| 246 NULL); | |
| 247 return TRUE; | |
| 248 } | |
| 249 | |
| 227 gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group, | 250 gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group, |
| 228 GObject* acceleratable, | 251 GObject* acceleratable, |
| 229 guint keyval, | 252 guint keyval, |
| 230 GdkModifierType modifier) { | 253 GdkModifierType modifier) { |
| 231 gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_)); | 254 gtk_widget_grab_focus(GTK_WIDGET(url_edit_view_)); |
| 232 return TRUE; | 255 return TRUE; |
| 233 } | 256 } |
| 234 | 257 |
| 235 void Shell::PlatformSetTitle(const string16& title) { | 258 void Shell::PlatformSetTitle(const string16& title) { |
| 236 std::string title_utf8 = UTF16ToUTF8(title); | 259 std::string title_utf8 = UTF16ToUTF8(title); |
| 237 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); | 260 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); |
| 238 } | 261 } |
| 239 | 262 |
| 240 } // namespace content | 263 } // namespace content |
| OLD | NEW |