| 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/extensions/extension_install_dialog.h" | 9 #include "chrome/browser/extensions/extension_install_dialog.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 14 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "skia/ext/image_operations.h" | 17 #include "skia/ext/image_operations.h" |
| 18 #include "ui/base/gtk/gtk_hig_constants.h" | |
| 19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/gfx/gtk_util.h" | 19 #include "ui/gfx/gtk_util.h" |
| 21 | 20 |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 const int kRightColumnMinWidth = 290; | 23 const int kRightColumnMinWidth = 290; |
| 25 const int kImageSize = 69; | 24 const int kImageSize = 69; |
| 26 | 25 |
| 27 // Padding on all sides of each permission in the permissions list. | 26 // Padding on all sides of each permission in the permissions list. |
| 28 const int kPermissionsPadding = 8; | 27 const int kPermissionsPadding = 8; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 cancel > 0 ? l10n_util::GetStringUTF8(cancel).c_str(): GTK_STOCK_CANCEL, | 68 cancel > 0 ? l10n_util::GetStringUTF8(cancel).c_str(): GTK_STOCK_CANCEL, |
| 70 GTK_RESPONSE_CLOSE); | 69 GTK_RESPONSE_CLOSE); |
| 71 gtk_dialog_add_button( | 70 gtk_dialog_add_button( |
| 72 GTK_DIALOG(dialog), | 71 GTK_DIALOG(dialog), |
| 73 l10n_util::GetStringUTF8(ExtensionInstallUI::kButtonIds[type]).c_str(), | 72 l10n_util::GetStringUTF8(ExtensionInstallUI::kButtonIds[type]).c_str(), |
| 74 GTK_RESPONSE_ACCEPT); | 73 GTK_RESPONSE_ACCEPT); |
| 75 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | 74 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
| 76 | 75 |
| 77 // Create a two column layout. | 76 // Create a two column layout. |
| 78 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); | 77 GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); |
| 79 gtk_box_set_spacing(GTK_BOX(content_area), ui::kContentAreaSpacing); | 78 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); |
| 80 | 79 |
| 81 GtkWidget* icon_hbox = gtk_hbox_new(FALSE, ui::kContentAreaSpacing); | 80 GtkWidget* icon_hbox = gtk_hbox_new(FALSE, gtk_util::kContentAreaSpacing); |
| 82 gtk_box_pack_start(GTK_BOX(content_area), icon_hbox, TRUE, TRUE, 0); | 81 gtk_box_pack_start(GTK_BOX(content_area), icon_hbox, TRUE, TRUE, 0); |
| 83 | 82 |
| 84 // Resize the icon if necessary. | 83 // Resize the icon if necessary. |
| 85 SkBitmap scaled_icon = *skia_icon; | 84 SkBitmap scaled_icon = *skia_icon; |
| 86 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) { | 85 if (scaled_icon.width() > kImageSize || scaled_icon.height() > kImageSize) { |
| 87 scaled_icon = skia::ImageOperations::Resize(scaled_icon, | 86 scaled_icon = skia::ImageOperations::Resize(scaled_icon, |
| 88 skia::ImageOperations::RESIZE_LANCZOS3, | 87 skia::ImageOperations::RESIZE_LANCZOS3, |
| 89 kImageSize, kImageSize); | 88 kImageSize, kImageSize); |
| 90 } | 89 } |
| 91 | 90 |
| 92 // Put Icon in the left column. | 91 // Put Icon in the left column. |
| 93 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon); | 92 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&scaled_icon); |
| 94 GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf); | 93 GtkWidget* icon = gtk_image_new_from_pixbuf(pixbuf); |
| 95 g_object_unref(pixbuf); | 94 g_object_unref(pixbuf); |
| 96 gtk_box_pack_start(GTK_BOX(icon_hbox), icon, FALSE, FALSE, 0); | 95 gtk_box_pack_start(GTK_BOX(icon_hbox), icon, FALSE, FALSE, 0); |
| 97 // Top justify the image. | 96 // Top justify the image. |
| 98 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); | 97 gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0); |
| 99 | 98 |
| 100 // Create a new vbox for the right column. | 99 // Create a new vbox for the right column. |
| 101 GtkWidget* right_column_area = gtk_vbox_new(FALSE, ui::kControlSpacing); | 100 GtkWidget* right_column_area = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 102 gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0); | 101 gtk_box_pack_start(GTK_BOX(icon_hbox), right_column_area, TRUE, TRUE, 0); |
| 103 | 102 |
| 104 std::string heading_text = l10n_util::GetStringFUTF8( | 103 std::string heading_text = l10n_util::GetStringFUTF8( |
| 105 ExtensionInstallUI::kHeadingIds[type], UTF8ToUTF16(extension->name())); | 104 ExtensionInstallUI::kHeadingIds[type], UTF8ToUTF16(extension->name())); |
| 106 GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>", | 105 GtkWidget* heading_label = MakeMarkupLabel("<span weight=\"bold\">%s</span>", |
| 107 heading_text); | 106 heading_text); |
| 108 gtk_label_set_line_wrap(GTK_LABEL(heading_label), true); | 107 gtk_label_set_line_wrap(GTK_LABEL(heading_label), true); |
| 109 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5); | 108 gtk_misc_set_alignment(GTK_MISC(heading_label), 0.0, 0.5); |
| 110 bool show_permissions = !permissions.empty(); | 109 bool show_permissions = !permissions.empty(); |
| 111 // If we are not going to show the permissions, vertically center the title. | 110 // If we are not going to show the permissions, vertically center the title. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( | 188 BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>( |
| 190 browser->window()); | 189 browser->window()); |
| 191 if (!browser_window) { | 190 if (!browser_window) { |
| 192 delegate->InstallUIAbort(false); | 191 delegate->InstallUIAbort(false); |
| 193 return; | 192 return; |
| 194 } | 193 } |
| 195 | 194 |
| 196 ShowInstallDialog( | 195 ShowInstallDialog( |
| 197 browser_window->window(), icon, extension, delegate, permissions, type); | 196 browser_window->window(), icon, extension, delegate, permissions, type); |
| 198 } | 197 } |
| OLD | NEW |