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/logging.h" | 10 #include "base/logging.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 if (headless_) | 94 if (headless_) |
95 return; | 95 return; |
96 | 96 |
97 if (loading) | 97 if (loading) |
98 gtk_spinner_start(GTK_SPINNER(spinner_)); | 98 gtk_spinner_start(GTK_SPINNER(spinner_)); |
99 else | 99 else |
100 gtk_spinner_stop(GTK_SPINNER(spinner_)); | 100 gtk_spinner_stop(GTK_SPINNER(spinner_)); |
101 } | 101 } |
102 | 102 |
103 void Shell::PlatformCreateWindow(int width, int height) { | 103 void Shell::PlatformCreateWindow(int width, int height) { |
104 | |
105 if (!headless_) { | |
106 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | |
107 gtk_window_set_title(window_, "Content Shell"); | |
108 g_signal_connect(G_OBJECT(window_), "destroy", | |
109 G_CALLBACK(OnWindowDestroyedThunk), this); | |
110 } | |
104 SizeTo(width, height); | 111 SizeTo(width, height); |
105 | 112 |
106 if (headless_) | 113 if (headless_) |
107 return; | 114 return; |
108 | 115 |
109 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | |
110 gtk_window_set_title(window_, "Content Shell"); | |
111 g_signal_connect(G_OBJECT(window_), "destroy", | |
112 G_CALLBACK(OnWindowDestroyedThunk), this); | |
113 | |
114 vbox_ = gtk_vbox_new(FALSE, 0); | 116 vbox_ = gtk_vbox_new(FALSE, 0); |
115 | 117 |
116 // Create the menu bar. | 118 // Create the menu bar. |
117 GtkWidget* menu_bar = CreateMenuBar(this); | 119 GtkWidget* menu_bar = CreateMenuBar(this); |
118 gtk_box_pack_start(GTK_BOX(vbox_), menu_bar, FALSE, FALSE, 0); | 120 gtk_box_pack_start(GTK_BOX(vbox_), menu_bar, FALSE, FALSE, 0); |
119 | 121 |
120 // Create the object that mediates accelerators. | 122 // Create the object that mediates accelerators. |
121 GtkAccelGroup* accel_group = gtk_accel_group_new(); | 123 GtkAccelGroup* accel_group = gtk_accel_group_new(); |
122 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); | 124 gtk_window_add_accel_group(GTK_WINDOW(window_), accel_group); |
123 | 125 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 if (headless_) | 204 if (headless_) |
203 return; | 205 return; |
204 | 206 |
205 WebContentsView* content_view = web_contents_->GetView(); | 207 WebContentsView* content_view = web_contents_->GetView(); |
206 gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView()); | 208 gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView()); |
207 } | 209 } |
208 | 210 |
209 void Shell::SizeTo(int width, int height) { | 211 void Shell::SizeTo(int width, int height) { |
210 content_width_ = width; | 212 content_width_ = width; |
211 content_height_ = height; | 213 content_height_ = height; |
212 if (web_contents_) { | 214 if (window_) |
213 gtk_widget_set_size_request(web_contents_->GetView()->GetNativeView(), | 215 gtk_window_resize(window_, width, height); |
jochen (gone - plz use gerrit)
2013/05/14 07:25:33
this will break headless mode where window_ is alw
mstensho (USE GERRIT)
2013/05/14 09:28:24
So would the right thing be to keep the old code f
jochen (gone - plz use gerrit)
2013/05/14 09:31:39
Not sure. We always want the native view to be the
mstensho (USE GERRIT)
2013/05/14 09:40:16
I'm sorry, I don't understand. Can you provide me
| |
214 width, height); | |
215 } | |
216 } | 216 } |
217 | 217 |
218 void Shell::PlatformResizeSubViews() { | 218 void Shell::PlatformResizeSubViews() { |
219 SizeTo(content_width_, content_height_); | 219 SizeTo(content_width_, content_height_); |
220 } | 220 } |
221 | 221 |
222 void Shell::Close() { | 222 void Shell::Close() { |
223 if (headless_) { | 223 if (headless_) { |
224 delete this; | 224 delete this; |
225 return; | 225 return; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 | 290 |
291 void Shell::PlatformSetTitle(const string16& title) { | 291 void Shell::PlatformSetTitle(const string16& title) { |
292 if (headless_) | 292 if (headless_) |
293 return; | 293 return; |
294 | 294 |
295 std::string title_utf8 = UTF16ToUTF8(title); | 295 std::string title_utf8 = UTF16ToUTF8(title); |
296 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); | 296 gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str()); |
297 } | 297 } |
298 | 298 |
299 } // namespace content | 299 } // namespace content |
OLD | NEW |