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

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

Issue 11377005: Replace Label::Alignment with gfx::HorizontalAlignment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix remaining Label::Alignment references. Created 8 years, 1 month 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 | Annotate | Revision Log
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/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 0, // no fixed width 280 0, // no fixed width
281 kIconSize); 281 kIconSize);
282 } 282 }
283 283
284 layout->StartRow(0, column_set_id); 284 layout->StartRow(0, column_set_id);
285 285
286 views::Label* heading = new views::Label(prompt.GetHeading()); 286 views::Label* heading = new views::Label(prompt.GetHeading());
287 heading->SetFont(heading->font().DeriveFont(kHeadingFontSizeDelta, 287 heading->SetFont(heading->font().DeriveFont(kHeadingFontSizeDelta,
288 gfx::Font::BOLD)); 288 gfx::Font::BOLD));
289 heading->SetMultiLine(true); 289 heading->SetMultiLine(true);
290 heading->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 290 heading->SetHorizontalAlignment(gfx::ALIGN_LEFT);
291 heading->SizeToFit(left_column_width); 291 heading->SizeToFit(left_column_width);
292 layout->AddView(heading); 292 layout->AddView(heading);
293 293
294 if (!is_bundle_install()) { 294 if (!is_bundle_install()) {
295 // Scale down to icon size, but allow smaller icons (don't scale up). 295 // Scale down to icon size, but allow smaller icons (don't scale up).
296 const gfx::ImageSkia* image = prompt.icon().ToImageSkia(); 296 const gfx::ImageSkia* image = prompt.icon().ToImageSkia();
297 gfx::Size size(image->width(), image->height()); 297 gfx::Size size(image->width(), image->height());
298 if (size.width() > kIconSize || size.height() > kIconSize) 298 if (size.width() > kIconSize || size.height() > kIconSize)
299 size = gfx::Size(kIconSize, kIconSize); 299 size = gfx::Size(kIconSize, kIconSize);
300 views::ImageView* icon = new views::ImageView(); 300 views::ImageView* icon = new views::ImageView();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 BundleInstaller::ItemList items = prompt_.bundle()->GetItemsWithState( 352 BundleInstaller::ItemList items = prompt_.bundle()->GetItemsWithState(
353 BundleInstaller::Item::STATE_PENDING); 353 BundleInstaller::Item::STATE_PENDING);
354 for (size_t i = 0; i < items.size(); ++i) { 354 for (size_t i = 0; i < items.size(); ++i) {
355 string16 extension_name = UTF8ToUTF16(items[i].localized_name); 355 string16 extension_name = UTF8ToUTF16(items[i].localized_name);
356 base::i18n::AdjustStringForLocaleDirection(&extension_name); 356 base::i18n::AdjustStringForLocaleDirection(&extension_name);
357 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 357 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
358 layout->StartRow(0, column_set_id); 358 layout->StartRow(0, column_set_id);
359 views::Label* extension_label = new views::Label( 359 views::Label* extension_label = new views::Label(
360 PrepareForDisplay(extension_name, true)); 360 PrepareForDisplay(extension_name, true));
361 extension_label->SetMultiLine(true); 361 extension_label->SetMultiLine(true);
362 extension_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 362 extension_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
363 extension_label->SizeToFit(left_column_width); 363 extension_label->SizeToFit(left_column_width);
364 layout->AddView(extension_label); 364 layout->AddView(extension_label);
365 } 365 }
366 } 366 }
367 367
368 if (prompt.GetPermissionCount()) { 368 if (prompt.GetPermissionCount()) {
369 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 369 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
370 370
371 if (is_inline_install()) { 371 if (is_inline_install()) {
372 layout->StartRow(0, column_set_id); 372 layout->StartRow(0, column_set_id);
373 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL, 373 layout->AddView(new views::Separator(), 3, 1, views::GridLayout::FILL,
374 views::GridLayout::FILL); 374 views::GridLayout::FILL);
375 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 375 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
376 } 376 }
377 377
378 layout->StartRow(0, column_set_id); 378 layout->StartRow(0, column_set_id);
379 views::Label* permissions_header = NULL; 379 views::Label* permissions_header = NULL;
380 if (is_bundle_install()) { 380 if (is_bundle_install()) {
381 // We need to make the font bold like this, rather than using SetFont, 381 // We need to make the font bold like this, rather than using SetFont,
382 // because otherwise SizeToFit mis-judges the width of the line. 382 // because otherwise SizeToFit mis-judges the width of the line.
383 gfx::Font bold_font = ui::ResourceBundle::GetSharedInstance().GetFont( 383 gfx::Font bold_font = ui::ResourceBundle::GetSharedInstance().GetFont(
384 ui::ResourceBundle::BaseFont).DeriveFont( 384 ui::ResourceBundle::BaseFont).DeriveFont(
385 kHeadingFontSizeDelta, gfx::Font::BOLD); 385 kHeadingFontSizeDelta, gfx::Font::BOLD);
386 permissions_header = new views::Label( 386 permissions_header = new views::Label(
387 prompt.GetPermissionsHeading(), bold_font); 387 prompt.GetPermissionsHeading(), bold_font);
388 } else { 388 } else {
389 permissions_header = new views::Label(prompt.GetPermissionsHeading()); 389 permissions_header = new views::Label(prompt.GetPermissionsHeading());
390 } 390 }
391 permissions_header->SetMultiLine(true); 391 permissions_header->SetMultiLine(true);
392 permissions_header->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 392 permissions_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
393 permissions_header->SizeToFit(left_column_width); 393 permissions_header->SizeToFit(left_column_width);
394 layout->AddView(permissions_header); 394 layout->AddView(permissions_header);
395 395
396 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) { 396 for (size_t i = 0; i < prompt.GetPermissionCount(); ++i) {
397 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 397 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
398 layout->StartRow(0, column_set_id); 398 layout->StartRow(0, column_set_id);
399 views::Label* permission_label = new views::Label(PrepareForDisplay( 399 views::Label* permission_label = new views::Label(PrepareForDisplay(
400 prompt.GetPermission(i), true)); 400 prompt.GetPermission(i), true));
401 permission_label->SetMultiLine(true); 401 permission_label->SetMultiLine(true);
402 permission_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 402 permission_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
403 permission_label->SizeToFit(left_column_width); 403 permission_label->SizeToFit(left_column_width);
404 layout->AddView(permission_label); 404 layout->AddView(permission_label);
405 } 405 }
406 } 406 }
407 407
408 if (prompt.GetOAuthIssueCount()) { 408 if (prompt.GetOAuthIssueCount()) {
409 // Slide in under the permissions; stretch all the way to the right of the 409 // Slide in under the permissions; stretch all the way to the right of the
410 // dialog. 410 // dialog.
411 int space_for_oauth = left_column_width; 411 int space_for_oauth = left_column_width;
412 if (prompt.GetPermissionCount()) { 412 if (prompt.GetPermissionCount()) {
413 space_for_oauth += kIconSize; 413 space_for_oauth += kIconSize;
414 column_set = layout->AddColumnSet(++column_set_id); 414 column_set = layout->AddColumnSet(++column_set_id);
415 column_set->AddColumn(views::GridLayout::FILL, 415 column_set->AddColumn(views::GridLayout::FILL,
416 views::GridLayout::FILL, 416 views::GridLayout::FILL,
417 1, 417 1,
418 views::GridLayout::USE_PREF, 418 views::GridLayout::USE_PREF,
419 0, // no fixed width 419 0, // no fixed width
420 space_for_oauth); 420 space_for_oauth);
421 } 421 }
422 422
423 layout->StartRowWithPadding(0, column_set_id, 423 layout->StartRowWithPadding(0, column_set_id,
424 0, views::kRelatedControlVerticalSpacing); 424 0, views::kRelatedControlVerticalSpacing);
425 views::Label* oauth_header = new views::Label(prompt.GetOAuthHeading()); 425 views::Label* oauth_header = new views::Label(prompt.GetOAuthHeading());
426 oauth_header->SetMultiLine(true); 426 oauth_header->SetMultiLine(true);
427 oauth_header->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 427 oauth_header->SetHorizontalAlignment(gfx::ALIGN_LEFT);
428 oauth_header->SizeToFit(left_column_width); 428 oauth_header->SizeToFit(left_column_width);
429 layout->AddView(oauth_header); 429 layout->AddView(oauth_header);
430 430
431 for (size_t i = 0; i < prompt.GetOAuthIssueCount(); ++i) { 431 for (size_t i = 0; i < prompt.GetOAuthIssueCount(); ++i) {
432 layout->StartRowWithPadding( 432 layout->StartRowWithPadding(
433 0, column_set_id, 433 0, column_set_id,
434 0, views::kRelatedControlVerticalSpacing); 434 0, views::kRelatedControlVerticalSpacing);
435 435
436 IssueAdviceView* issue_advice_view = 436 IssueAdviceView* issue_advice_view =
437 new IssueAdviceView(this, prompt.GetOAuthIssue(i), space_for_oauth); 437 new IssueAdviceView(this, prompt.GetOAuthIssue(i), space_for_oauth);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 horizontal_space, 519 horizontal_space,
520 0); 520 0);
521 } 521 }
522 522
523 void IssueAdviceView::DetailsView::AddDetail(const string16& detail) { 523 void IssueAdviceView::DetailsView::AddDetail(const string16& detail) {
524 layout_->StartRowWithPadding(0, 0, 524 layout_->StartRowWithPadding(0, 0,
525 0, views::kRelatedControlSmallVerticalSpacing); 525 0, views::kRelatedControlSmallVerticalSpacing);
526 views::Label* detail_label = 526 views::Label* detail_label =
527 new views::Label(PrepareForDisplay(detail, true)); 527 new views::Label(PrepareForDisplay(detail, true));
528 detail_label->SetMultiLine(true); 528 detail_label->SetMultiLine(true);
529 detail_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 529 detail_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
530 layout_->AddView(detail_label); 530 layout_->AddView(detail_label);
531 } 531 }
532 532
533 gfx::Size IssueAdviceView::DetailsView::GetPreferredSize() { 533 gfx::Size IssueAdviceView::DetailsView::GetPreferredSize() {
534 gfx::Size size = views::View::GetPreferredSize(); 534 gfx::Size size = views::View::GetPreferredSize();
535 return gfx::Size(size.width(), size.height() * state_); 535 return gfx::Size(size.width(), size.height() * state_);
536 } 536 }
537 537
538 void IssueAdviceView::DetailsView::AnimateToState(double state) { 538 void IssueAdviceView::DetailsView::AnimateToState(double state) {
539 state_ = state; 539 state_ = state;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 arrow_view_ = new views::ImageView(); 580 arrow_view_ = new views::ImageView();
581 arrow_view_->SetImage(image); 581 arrow_view_->SetImage(image);
582 arrow_view_->SetVerticalAlignment(views::ImageView::CENTER); 582 arrow_view_->SetVerticalAlignment(views::ImageView::CENTER);
583 layout->AddView(arrow_view_); 583 layout->AddView(arrow_view_);
584 } 584 }
585 585
586 views::Label* description_label = 586 views::Label* description_label =
587 new views::Label(PrepareForDisplay(issue_advice.description, 587 new views::Label(PrepareForDisplay(issue_advice.description,
588 !details_view_)); 588 !details_view_));
589 description_label->SetMultiLine(true); 589 description_label->SetMultiLine(true);
590 description_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 590 description_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
591 description_label->SizeToFit(horizontal_space); 591 description_label->SizeToFit(horizontal_space);
592 layout->AddView(description_label); 592 layout->AddView(description_label);
593 593
594 if (!details_view_) 594 if (!details_view_)
595 return; 595 return;
596 596
597 layout->StartRow(0, column_set_id); 597 layout->StartRow(0, column_set_id);
598 layout->SkipColumns(1); 598 layout->SkipColumns(1);
599 layout->AddView(details_view_); 599 layout->AddView(details_view_);
600 600
(...skipping 29 matching lines...) Expand all
630 rotate.ConcatTranslate(arrow_view_->width() / 2.0, 630 rotate.ConcatTranslate(arrow_view_->width() / 2.0,
631 arrow_view_->height() / 2.0); 631 arrow_view_->height() / 2.0);
632 } 632 }
633 arrow_view_->SetTransform(rotate); 633 arrow_view_->SetTransform(rotate);
634 } 634 }
635 } 635 }
636 636
637 void IssueAdviceView::ChildPreferredSizeChanged(views::View* child) { 637 void IssueAdviceView::ChildPreferredSizeChanged(views::View* child) {
638 owner_->SizeToContents(); 638 owner_->SizeToContents();
639 } 639 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698