| 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/simple_message_box.h" | 5 #include "chrome/browser/simple_message_box.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/gtk/gtk_util.h" | 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 void SetDialogTitle(GtkWidget* dialog, const string16& title) { | 13 void SetDialogTitle(GtkWidget* dialog, const string16& title) { |
| 14 gtk_window_set_title(GTK_WINDOW(dialog), UTF16ToUTF8(title).c_str()); | 14 gtk_window_set_title(GTK_WINDOW(dialog), UTF16ToUTF8(title).c_str()); |
| 15 | 15 |
| 16 // The following code requires the dialog to be realized. However, we host | 16 // The following code requires the dialog to be realized. |
| 17 // dialog's content in a Chrome window without really realize the dialog | |
| 18 // on ChromeOS. Thus, skip the following code for ChromeOS. | |
| 19 gtk_widget_realize(dialog); | 17 gtk_widget_realize(dialog); |
| 20 | 18 |
| 21 // Make sure it's big enough to show the title. | 19 // Make sure it's big enough to show the title. |
| 22 GtkRequisition req; | 20 GtkRequisition req; |
| 23 gtk_widget_size_request(dialog, &req); | 21 gtk_widget_size_request(dialog, &req); |
| 24 int width; | 22 int width; |
| 25 gtk_util::GetWidgetSizeFromCharacters(dialog, title.length(), 0, | 23 gtk_util::GetWidgetSizeFromCharacters(dialog, title.length(), 0, |
| 26 &width, NULL); | 24 &width, NULL); |
| 27 // The fudge factor accounts for extra space needed by the frame | 25 // The fudge factor accounts for extra space needed by the frame |
| 28 // decorations as well as width differences between average text and the | 26 // decorations as well as width differences between average text and the |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 "response", | 77 "response", |
| 80 G_CALLBACK(HandleOnResponseDialog), | 78 G_CALLBACK(HandleOnResponseDialog), |
| 81 NULL); | 79 NULL); |
| 82 gtk_util::ShowDialog(dialog); | 80 gtk_util::ShowDialog(dialog); |
| 83 // Not gtk_dialog_run as it prevents timers from running in the unit tests. | 81 // Not gtk_dialog_run as it prevents timers from running in the unit tests. |
| 84 MessageLoop::current()->Run(); | 82 MessageLoop::current()->Run(); |
| 85 return g_dialog_response == GTK_RESPONSE_YES; | 83 return g_dialog_response == GTK_RESPONSE_YES; |
| 86 } | 84 } |
| 87 | 85 |
| 88 } // namespace browser | 86 } // namespace browser |
| OLD | NEW |