| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 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" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 column_set->AddPaddingColumn(0, views::kPanelHorizMargin); | 155 column_set->AddPaddingColumn(0, views::kPanelHorizMargin); |
| 156 column_set->AddColumn(GridLayout::LEADING, | 156 column_set->AddColumn(GridLayout::LEADING, |
| 157 GridLayout::LEADING, | 157 GridLayout::LEADING, |
| 158 0, // no resizing | 158 0, // no resizing |
| 159 GridLayout::USE_PREF, | 159 GridLayout::USE_PREF, |
| 160 0, // no fixed width | 160 0, // no fixed width |
| 161 kIconSize); | 161 kIconSize); |
| 162 | 162 |
| 163 layout->StartRow(0, column_set_id); | 163 layout->StartRow(0, column_set_id); |
| 164 | 164 |
| 165 views::Label* heading = new views::Label(UTF16ToWide( | 165 views::Label* heading = new views::Label( |
| 166 prompt.GetHeading(extension->name()))); | 166 prompt.GetHeading(extension->name())); |
| 167 heading->SetFont(heading->font().DeriveFont(kHeadingFontSizeDelta, | 167 heading->SetFont(heading->font().DeriveFont(kHeadingFontSizeDelta, |
| 168 gfx::Font::BOLD)); | 168 gfx::Font::BOLD)); |
| 169 heading->SetMultiLine(true); | 169 heading->SetMultiLine(true); |
| 170 heading->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 170 heading->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 171 heading->SizeToFit(left_column_width); | 171 heading->SizeToFit(left_column_width); |
| 172 layout->AddView(heading); | 172 layout->AddView(heading); |
| 173 | 173 |
| 174 // Scale down to icon size, but allow smaller icons (don't scale up). | 174 // Scale down to icon size, but allow smaller icons (don't scale up). |
| 175 gfx::Size size(skia_icon->width(), skia_icon->height()); | 175 gfx::Size size(skia_icon->width(), skia_icon->height()); |
| 176 if (size.width() > kIconSize || size.height() > kIconSize) | 176 if (size.width() > kIconSize || size.height() > kIconSize) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 192 layout->AddView(icon, 1, icon_row_span); | 192 layout->AddView(icon, 1, icon_row_span); |
| 193 | 193 |
| 194 if (is_inline_install()) { | 194 if (is_inline_install()) { |
| 195 layout->StartRow(0, column_set_id); | 195 layout->StartRow(0, column_set_id); |
| 196 views::View* rating = new views::View(); | 196 views::View* rating = new views::View(); |
| 197 rating->SetLayoutManager(new views::BoxLayout( | 197 rating->SetLayoutManager(new views::BoxLayout( |
| 198 views::BoxLayout::kHorizontal, 0, 0, 0)); | 198 views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 199 layout->AddView(rating); | 199 layout->AddView(rating); |
| 200 prompt.AppendRatingStars(AddResourceIcon, rating); | 200 prompt.AppendRatingStars(AddResourceIcon, rating); |
| 201 | 201 |
| 202 views::Label* rating_count = new views::Label( | 202 views::Label* rating_count = new views::Label(prompt.GetRatingCount()); |
| 203 UTF16ToWide(prompt.GetRatingCount())); | |
| 204 rating_count->SetFont( | 203 rating_count->SetFont( |
| 205 rating_count->font().DeriveFont(kRatingFontSizeDelta)); | 204 rating_count->font().DeriveFont(kRatingFontSizeDelta)); |
| 206 // Add some space between the stars and the rating count. | 205 // Add some space between the stars and the rating count. |
| 207 rating_count->set_border(views::Border::CreateEmptyBorder(0, 2, 0, 0)); | 206 rating_count->set_border(views::Border::CreateEmptyBorder(0, 2, 0, 0)); |
| 208 rating->AddChildView(rating_count); | 207 rating->AddChildView(rating_count); |
| 209 | 208 |
| 210 layout->StartRow(0, column_set_id); | 209 layout->StartRow(0, column_set_id); |
| 211 views::Label* user_count = new views::Label( | 210 views::Label* user_count = new views::Label(prompt.GetUserCount()); |
| 212 UTF16ToWide(prompt.GetUserCount())); | |
| 213 user_count->SetColor(SK_ColorGRAY); | 211 user_count->SetColor(SK_ColorGRAY); |
| 214 user_count->SetFont(user_count->font().DeriveFont(kRatingFontSizeDelta)); | 212 user_count->SetFont(user_count->font().DeriveFont(kRatingFontSizeDelta)); |
| 215 layout->AddView(user_count); | 213 layout->AddView(user_count); |
| 216 | 214 |
| 217 layout->StartRow(0, column_set_id); | 215 layout->StartRow(0, column_set_id); |
| 218 views::Link* store_link = new views::Link(UTF16ToWide( | 216 views::Link* store_link = new views::Link( |
| 219 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK))); | 217 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); |
| 220 store_link->SetFont(store_link->font().DeriveFont(kRatingFontSizeDelta)); | 218 store_link->SetFont(store_link->font().DeriveFont(kRatingFontSizeDelta)); |
| 221 store_link->set_listener(this); | 219 store_link->set_listener(this); |
| 222 layout->AddView(store_link); | 220 layout->AddView(store_link); |
| 223 } | 221 } |
| 224 | 222 |
| 225 if (prompt.GetPermissionCount()) { | 223 if (prompt.GetPermissionCount()) { |
| 226 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 224 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 227 | 225 |
| 228 if (is_inline_install()) { | 226 if (is_inline_install()) { |
| 229 layout->StartRow(0, column_set_id); | 227 layout->StartRow(0, column_set_id); |
| 230 views::Separator* separator = new views::Separator(); | 228 views::Separator* separator = new views::Separator(); |
| 231 layout->AddView(separator, 3, 1, GridLayout::FILL, GridLayout::FILL); | 229 layout->AddView(separator, 3, 1, GridLayout::FILL, GridLayout::FILL); |
| 232 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 230 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 233 } | 231 } |
| 234 | 232 |
| 235 layout->StartRow(0, column_set_id); | 233 layout->StartRow(0, column_set_id); |
| 236 views::Label* permissions_header = new views::Label(UTF16ToWide( | 234 views::Label* permissions_header = new views::Label( |
| 237 prompt.GetPermissionsHeader())); | 235 prompt.GetPermissionsHeader()); |
| 238 permissions_header->SetMultiLine(true); | 236 permissions_header->SetMultiLine(true); |
| 239 permissions_header->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 237 permissions_header->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 240 permissions_header->SizeToFit(left_column_width); | 238 permissions_header->SizeToFit(left_column_width); |
| 241 layout->AddView(permissions_header); | 239 layout->AddView(permissions_header); |
| 242 | 240 |
| 243 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { | 241 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { |
| 244 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 242 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 245 layout->StartRow(0, column_set_id); | 243 layout->StartRow(0, column_set_id); |
| 246 views::Label* permission_label = new views::Label( | 244 views::Label* permission_label = new views::Label( |
| 247 UTF16ToWide(prompt.GetPermission(i))); | 245 prompt.GetPermission(i)); |
| 248 permission_label->SetMultiLine(true); | 246 permission_label->SetMultiLine(true); |
| 249 permission_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 247 permission_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 250 permission_label->SizeToFit(left_column_width); | 248 permission_label->SizeToFit(left_column_width); |
| 251 layout->AddView(permission_label); | 249 layout->AddView(permission_label); |
| 252 } | 250 } |
| 253 } | 251 } |
| 254 } | 252 } |
| 255 | 253 |
| 256 ExtensionInstallDialogView::~ExtensionInstallDialogView() { | 254 ExtensionInstallDialogView::~ExtensionInstallDialogView() { |
| 257 } | 255 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 328 } |
| 331 | 329 |
| 332 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView( | 330 ExtensionInstallDialogView* dialog = new ExtensionInstallDialogView( |
| 333 delegate, extension, icon, prompt); | 331 delegate, extension, icon, prompt); |
| 334 | 332 |
| 335 views::Widget* window = browser::CreateViewsWindow( | 333 views::Widget* window = browser::CreateViewsWindow( |
| 336 browser_window->GetNativeHandle(), dialog); | 334 browser_window->GetNativeHandle(), dialog); |
| 337 | 335 |
| 338 window->Show(); | 336 window->Show(); |
| 339 } | 337 } |
| OLD | NEW |