Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: chrome/browser/ui/views/extensions/extension_install_dialog_view.cc

Issue 11698005: Adjust fonts (part of 137349): use standard font sizes in chrome/browser/ui/views (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: crbug.com/166679 Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const int kNoPermissionsLeftColumnWidth = 200; 64 const int kNoPermissionsLeftColumnWidth = 200;
65 65
66 // Width of the left column for bundle install prompts. There's only one column 66 // Width of the left column for bundle install prompts. There's only one column
67 // in this case, so make it wider than normal. 67 // in this case, so make it wider than normal.
68 const int kBundleLeftColumnWidth = 300; 68 const int kBundleLeftColumnWidth = 300;
69 69
70 // Width of the left column for external install prompts. The text is long in 70 // Width of the left column for external install prompts. The text is long in
71 // this case, so make it wider than normal. 71 // this case, so make it wider than normal.
72 const int kExternalInstallLeftColumnWidth = 350; 72 const int kExternalInstallLeftColumnWidth = 350;
73 73
74 // Heading font size correction.
75 const int kHeadingFontSizeDelta = 1;
76
77 const int kRatingFontSizeDelta = -1;
78
79 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) { 74 void AddResourceIcon(const gfx::ImageSkia* skia_image, void* data) {
80 views::View* parent = static_cast<views::View*>(data); 75 views::View* parent = static_cast<views::View*>(data);
81 views::ImageView* image_view = new views::ImageView(); 76 views::ImageView* image_view = new views::ImageView();
82 image_view->SetImage(*skia_image); 77 image_view->SetImage(*skia_image);
83 parent->AddChildView(image_view); 78 parent->AddChildView(image_view);
84 } 79 }
85 80
86 // Creates a string for displaying |message| to the user. If it has to look 81 // Creates a string for displaying |message| to the user. If it has to look
87 // like a entry in a bullet point list, one is added. 82 // like a entry in a bullet point list, one is added.
88 string16 PrepareForDisplay(const string16& message, bool bullet_point) { 83 string16 PrepareForDisplay(const string16& message, bool bullet_point) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 column_set->AddColumn(views::GridLayout::LEADING, 339 column_set->AddColumn(views::GridLayout::LEADING,
345 views::GridLayout::LEADING, 340 views::GridLayout::LEADING,
346 0, // no resizing 341 0, // no resizing
347 views::GridLayout::USE_PREF, 342 views::GridLayout::USE_PREF,
348 0, // no fixed width 343 0, // no fixed width
349 kIconSize); 344 kIconSize);
350 } 345 }
351 346
352 layout->StartRow(0, column_set_id); 347 layout->StartRow(0, column_set_id);
353 348
349 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
350
354 views::Label* heading = new views::Label(prompt.GetHeading()); 351 views::Label* heading = new views::Label(prompt.GetHeading());
355 heading->SetFont(heading->font().DeriveFont(kHeadingFontSizeDelta, 352 heading->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont));
356 gfx::Font::BOLD));
357 heading->SetMultiLine(true); 353 heading->SetMultiLine(true);
358 heading->SetHorizontalAlignment(gfx::ALIGN_LEFT); 354 heading->SetHorizontalAlignment(gfx::ALIGN_LEFT);
359 heading->SizeToFit(left_column_width); 355 heading->SizeToFit(left_column_width);
360 layout->AddView(heading); 356 layout->AddView(heading);
361 357
362 if (!is_bundle_install()) { 358 if (!is_bundle_install()) {
363 // Scale down to icon size, but allow smaller icons (don't scale up). 359 // Scale down to icon size, but allow smaller icons (don't scale up).
364 const gfx::ImageSkia* image = prompt.icon().ToImageSkia(); 360 const gfx::ImageSkia* image = prompt.icon().ToImageSkia();
365 gfx::Size size(image->width(), image->height()); 361 gfx::Size size(image->width(), image->height());
366 if (size.width() > kIconSize || size.height() > kIconSize) 362 if (size.width() > kIconSize || size.height() > kIconSize)
(...skipping 21 matching lines...) Expand all
388 384
389 if (is_inline_install()) { 385 if (is_inline_install()) {
390 layout->StartRow(0, column_set_id); 386 layout->StartRow(0, column_set_id);
391 views::View* rating = new views::View(); 387 views::View* rating = new views::View();
392 rating->SetLayoutManager(new views::BoxLayout( 388 rating->SetLayoutManager(new views::BoxLayout(
393 views::BoxLayout::kHorizontal, 0, 0, 0)); 389 views::BoxLayout::kHorizontal, 0, 0, 0));
394 layout->AddView(rating); 390 layout->AddView(rating);
395 prompt.AppendRatingStars(AddResourceIcon, rating); 391 prompt.AppendRatingStars(AddResourceIcon, rating);
396 392
397 views::Label* rating_count = new views::Label(prompt.GetRatingCount()); 393 views::Label* rating_count = new views::Label(prompt.GetRatingCount());
398 rating_count->SetFont( 394 rating_count->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont));
399 rating_count->font().DeriveFont(kRatingFontSizeDelta));
400 // Add some space between the stars and the rating count. 395 // Add some space between the stars and the rating count.
401 rating_count->set_border(views::Border::CreateEmptyBorder(0, 2, 0, 0)); 396 rating_count->set_border(views::Border::CreateEmptyBorder(0, 2, 0, 0));
402 rating->AddChildView(rating_count); 397 rating->AddChildView(rating_count);
403 398
404 layout->StartRow(0, column_set_id); 399 layout->StartRow(0, column_set_id);
405 views::Label* user_count = new views::Label(prompt.GetUserCount()); 400 views::Label* user_count = new views::Label(prompt.GetUserCount());
406 user_count->SetAutoColorReadabilityEnabled(false); 401 user_count->SetAutoColorReadabilityEnabled(false);
407 user_count->SetEnabledColor(SK_ColorGRAY); 402 user_count->SetEnabledColor(SK_ColorGRAY);
408 user_count->SetFont(user_count->font().DeriveFont(kRatingFontSizeDelta)); 403 user_count->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont));
409 layout->AddView(user_count); 404 layout->AddView(user_count);
410 405
411 layout->StartRow(0, column_set_id); 406 layout->StartRow(0, column_set_id);
412 views::Link* store_link = new views::Link( 407 views::Link* store_link = new views::Link(
413 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK)); 408 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_STORE_LINK));
414 store_link->SetFont(store_link->font().DeriveFont(kRatingFontSizeDelta)); 409 store_link->SetFont(rb.GetFont(ui::ResourceBundle::SmallFont));
415 store_link->set_listener(this); 410 store_link->set_listener(this);
416 layout->AddView(store_link); 411 layout->AddView(store_link);
417 } 412 }
418 413
419 if (is_bundle_install()) { 414 if (is_bundle_install()) {
420 BundleInstaller::ItemList items = prompt_.bundle()->GetItemsWithState( 415 BundleInstaller::ItemList items = prompt_.bundle()->GetItemsWithState(
421 BundleInstaller::Item::STATE_PENDING); 416 BundleInstaller::Item::STATE_PENDING);
422 for (size_t i = 0; i < items.size(); ++i) { 417 for (size_t i = 0; i < items.size(); ++i) {
423 string16 extension_name = UTF8ToUTF16(items[i].localized_name); 418 string16 extension_name = UTF8ToUTF16(items[i].localized_name);
424 base::i18n::AdjustStringForLocaleDirection(&extension_name); 419 base::i18n::AdjustStringForLocaleDirection(&extension_name);
(...skipping 14 matching lines...) Expand all
439 if (is_inline_install()) { 434 if (is_inline_install()) {
440 layout->StartRow(0, column_set_id); 435 layout->StartRow(0, column_set_id);
441 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, 436 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL,
442 views::GridLayout::FILL); 437 views::GridLayout::FILL);
443 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 438 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
444 } 439 }
445 440
446 layout->StartRow(0, column_set_id); 441 layout->StartRow(0, column_set_id);
447 views::Label* permissions_header = NULL; 442 views::Label* permissions_header = NULL;
448 if (is_bundle_install()) { 443 if (is_bundle_install()) {
449 // We need to make the font bold like this, rather than using SetFont, 444 // We need to pass the Font in the constructor, rather than calling
450 // because otherwise SizeToFit mis-judges the width of the line. 445 // SetFont later, because otherwise SizeToFit mis-judges the width
451 gfx::Font bold_font = ui::ResourceBundle::GetSharedInstance().GetFont( 446 // of the line.
452 ui::ResourceBundle::BaseFont).DeriveFont(
453 kHeadingFontSizeDelta, gfx::Font::BOLD);
454 permissions_header = new views::Label( 447 permissions_header = new views::Label(
455 prompt.GetPermissionsHeading(), bold_font); 448 prompt.GetPermissionsHeading(),
449 rb.GetFont(ui::ResourceBundle::MediumFont));
456 } else { 450 } else {
457 permissions_header = new views::Label(prompt.GetPermissionsHeading()); 451 permissions_header = new views::Label(prompt.GetPermissionsHeading());
458 } 452 }
459 permissions_header->SetMultiLine(true); 453 permissions_header->SetMultiLine(true);
460 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT); 454 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
461 permissions_header->SizeToFit(left_column_width); 455 permissions_header->SizeToFit(left_column_width);
462 layout->AddView(permissions_header); 456 layout->AddView(permissions_header);
463 457
464 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { 458 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) {
465 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 459 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 views::GridLayout::FILL, 511 views::GridLayout::FILL,
518 1, 512 1,
519 views::GridLayout::USE_PREF, 513 views::GridLayout::USE_PREF,
520 0, // no fixed width 514 0, // no fixed width
521 left_column_width + kIconSize); 515 left_column_width + kIconSize);
522 layout->StartRowWithPadding(0, column_set_id, 516 layout->StartRowWithPadding(0, column_set_id,
523 0, views::kRelatedControlVerticalSpacing); 517 0, views::kRelatedControlVerticalSpacing);
524 app_launcher_opt_in_checkbox_ = new views::Checkbox( 518 app_launcher_opt_in_checkbox_ = new views::Checkbox(
525 l10n_util::GetStringUTF16(IDS_APP_LIST_OPT_IN_TEXT)); 519 l10n_util::GetStringUTF16(IDS_APP_LIST_OPT_IN_TEXT));
526 app_launcher_opt_in_checkbox_->SetFont( 520 app_launcher_opt_in_checkbox_->SetFont(
527 app_launcher_opt_in_checkbox_->font().DeriveFont(0, gfx::Font::BOLD)); 521 rb.GetFont(ui::ResourceBundle::BoldFont));
528 layout->AddView(app_launcher_opt_in_checkbox_); 522 layout->AddView(app_launcher_opt_in_checkbox_);
529 } 523 }
530 } 524 }
531 525
532 ExtensionInstallDialogView::~ExtensionInstallDialogView() {} 526 ExtensionInstallDialogView::~ExtensionInstallDialogView() {}
533 527
534 void ExtensionInstallDialogView::SizeToContents() { 528 void ExtensionInstallDialogView::SizeToContents() {
535 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); 529 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
536 } 530 }
537 531
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 rotate.Translate(-arrow_view_->width() / 2.0, 713 rotate.Translate(-arrow_view_->width() / 2.0,
720 -arrow_view_->height() / 2.0); 714 -arrow_view_->height() / 2.0);
721 } 715 }
722 arrow_view_->SetTransform(rotate); 716 arrow_view_->SetTransform(rotate);
723 } 717 }
724 } 718 }
725 719
726 void IssueAdviceView::ChildPreferredSizeChanged(views::View* child) { 720 void IssueAdviceView::ChildPreferredSizeChanged(views::View* child) {
727 owner_->SizeToContents(); 721 owner_->SizeToContents();
728 } 722 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698