OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/tab_contents_view_gtk.h" | 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 | 12 |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" | 17 #include "chrome/browser/tab_contents/render_view_context_menu_gtk.h" |
17 #include "chrome/browser/tab_contents/web_drag_dest_gtk.h" | 18 #include "chrome/browser/tab_contents/web_drag_dest_gtk.h" |
18 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | 19 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
19 #include "chrome/browser/ui/gtk/gtk_util.h" | 20 #include "chrome/browser/ui/gtk/gtk_util.h" |
20 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" | 21 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" |
21 #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" | 22 #include "chrome/browser/ui/gtk/tab_contents_drag_source.h" |
22 #include "content/browser/renderer_host/render_process_host.h" | 23 #include "content/browser/renderer_host/render_process_host.h" |
23 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
24 #include "content/browser/renderer_host/render_view_host_factory.h" | 25 #include "content/browser/renderer_host/render_view_host_factory.h" |
25 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" | 26 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void TabContentsViewGtk::SetPageTitle(const string16& title) { | 190 void TabContentsViewGtk::SetPageTitle(const string16& title) { |
190 // Set the window name to include the page title so it's easier to spot | 191 // Set the window name to include the page title so it's easier to spot |
191 // when debugging (e.g. via xwininfo -tree). | 192 // when debugging (e.g. via xwininfo -tree). |
192 gfx::NativeView content_view = GetContentNativeView(); | 193 gfx::NativeView content_view = GetContentNativeView(); |
193 if (content_view && content_view->window) | 194 if (content_view && content_view->window) |
194 gdk_window_set_title(content_view->window, UTF16ToUTF8(title).c_str()); | 195 gdk_window_set_title(content_view->window, UTF16ToUTF8(title).c_str()); |
195 } | 196 } |
196 | 197 |
197 void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus status, | 198 void TabContentsViewGtk::OnTabCrashed(base::TerminationStatus status, |
198 int error_code) { | 199 int error_code) { |
| 200 // Only show the sad tab if we're not in browser shutdown, so that TabContents |
| 201 // objects that are not in a browser (e.g., HTML dialogs) and thus are |
| 202 // visible do not flash a sad tab page. |
| 203 if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) |
| 204 return; |
| 205 |
199 if (tab_contents_ != NULL && !sad_tab_.get()) { | 206 if (tab_contents_ != NULL && !sad_tab_.get()) { |
200 sad_tab_.reset(new SadTabGtk( | 207 sad_tab_.reset(new SadTabGtk( |
201 tab_contents_, | 208 tab_contents_, |
202 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? | 209 status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ? |
203 SadTabGtk::KILLED : SadTabGtk::CRASHED)); | 210 SadTabGtk::KILLED : SadTabGtk::CRASHED)); |
204 InsertIntoContentArea(sad_tab_->widget()); | 211 InsertIntoContentArea(sad_tab_->widget()); |
205 gtk_widget_show(sad_tab_->widget()); | 212 gtk_widget_show(sad_tab_->widget()); |
206 } | 213 } |
207 } | 214 } |
208 | 215 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 g_value_set_int(&value, child_x); | 502 g_value_set_int(&value, child_x); |
496 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 503 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
497 widget, "x", &value); | 504 widget, "x", &value); |
498 | 505 |
499 int child_y = std::max((allocation->height - requisition.height) / 2, 0); | 506 int child_y = std::max((allocation->height - requisition.height) / 2, 0); |
500 g_value_set_int(&value, child_y); | 507 g_value_set_int(&value, child_y); |
501 gtk_container_child_set_property(GTK_CONTAINER(floating_container), | 508 gtk_container_child_set_property(GTK_CONTAINER(floating_container), |
502 widget, "y", &value); | 509 widget, "y", &value); |
503 g_value_unset(&value); | 510 g_value_unset(&value); |
504 } | 511 } |
OLD | NEW |