| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 char* markup = g_markup_printf_escaped(format, str.c_str()); | 34 char* markup = g_markup_printf_escaped(format, str.c_str()); |
| 35 gtk_label_set_markup(GTK_LABEL(label), markup); | 35 gtk_label_set_markup(GTK_LABEL(label), markup); |
| 36 g_free(markup); | 36 g_free(markup); |
| 37 | 37 |
| 38 // Left align it. | 38 // Left align it. |
| 39 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | 39 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
| 40 | 40 |
| 41 return label; | 41 return label; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void OnDialogResponse(GtkDialog* dialog, int response_id, | 44 void OnResponse(GtkWidget* dialog, int response_id, |
| 45 ExtensionInstallUI::Delegate* delegate) { | 45 ExtensionInstallUI::Delegate* delegate) { |
| 46 if (response_id == GTK_RESPONSE_ACCEPT) { | 46 if (response_id == GTK_RESPONSE_ACCEPT) { |
| 47 delegate->InstallUIProceed(); | 47 delegate->InstallUIProceed(); |
| 48 } else { | 48 } else { |
| 49 delegate->InstallUIAbort(); | 49 delegate->InstallUIAbort(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 gtk_widget_destroy(GTK_WIDGET(dialog)); | 52 gtk_widget_destroy(dialog); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ShowInstallPromptDialog2(GtkWindow* parent, SkBitmap* skia_icon, | 55 void ShowInstallPromptDialog2(GtkWindow* parent, SkBitmap* skia_icon, |
| 56 const Extension* extension, | 56 const Extension* extension, |
| 57 ExtensionInstallUI::Delegate *delegate, | 57 ExtensionInstallUI::Delegate *delegate, |
| 58 const std::vector<string16>& permissions, | 58 const std::vector<string16>& permissions, |
| 59 ExtensionInstallUI::PromptType type) { | 59 ExtensionInstallUI::PromptType type) { |
| 60 // Build the dialog. | 60 // Build the dialog. |
| 61 GtkWidget* dialog = gtk_dialog_new_with_buttons( | 61 GtkWidget* dialog = gtk_dialog_new_with_buttons( |
| 62 l10n_util::GetStringUTF8(ExtensionInstallUI::kTitleIds[type]).c_str(), | 62 l10n_util::GetStringUTF8(ExtensionInstallUI::kTitleIds[type]).c_str(), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (iter != permissions.begin()) | 153 if (iter != permissions.begin()) |
| 154 gtk_text_buffer_insert(buffer, &end_iter, "\n", -1); | 154 gtk_text_buffer_insert(buffer, &end_iter, "\n", -1); |
| 155 gtk_text_buffer_insert_with_tags( | 155 gtk_text_buffer_insert_with_tags( |
| 156 buffer, &end_iter, UTF16ToUTF8(*iter).c_str(), -1, | 156 buffer, &end_iter, UTF16ToUTF8(*iter).c_str(), -1, |
| 157 padding_below_tag, | 157 padding_below_tag, |
| 158 iter == permissions.begin() ? padding_above_tag : NULL, | 158 iter == permissions.begin() ? padding_above_tag : NULL, |
| 159 NULL); | 159 NULL); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), delegate); | 163 g_signal_connect(dialog, "response", G_CALLBACK(OnResponse), delegate); |
| 164 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | 164 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
| 165 | 165 |
| 166 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); | 166 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); |
| 167 gtk_widget_show_all(dialog); | 167 gtk_widget_show_all(dialog); |
| 168 gtk_widget_grab_focus(close_button); | 168 gtk_widget_grab_focus(close_button); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace | 171 } // namespace |
| 172 | 172 |
| 173 void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( | 173 void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 186 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( | 186 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( |
| 187 browser->window()); | 187 browser->window()); |
| 188 if (!browser_window) { | 188 if (!browser_window) { |
| 189 delegate->InstallUIAbort(); | 189 delegate->InstallUIAbort(); |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 ShowInstallPromptDialog2(browser_window->window(), icon, extension, | 193 ShowInstallPromptDialog2(browser_window->window(), icon, extension, |
| 194 delegate, permissions, type); | 194 delegate, permissions, type); |
| 195 } | 195 } |
| OLD | NEW |