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

Side by Side Diff: chrome/browser/ui/views/translate/translate_bubble_view.cc

Issue 2904443006: Views/Harmony Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Remove includes of layout_constants.h from ui/views Created 3 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/translate/translate_bubble_view.h" 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/i18n/string_compare.h" 13 #include "base/i18n/string_compare.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/translate/chrome_translate_client.h" 19 #include "chrome/browser/translate/chrome_translate_client.h"
20 #include "chrome/browser/translate/translate_service.h" 20 #include "chrome/browser/translate/translate_service.h"
21 #include "chrome/browser/ui/browser_dialogs.h" 21 #include "chrome/browser/ui/browser_dialogs.h"
22 #include "chrome/browser/ui/chrome_pages.h" 22 #include "chrome/browser/ui/chrome_pages.h"
23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" 23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h"
24 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" 24 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h"
25 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
27 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
28 #include "components/strings/grit/components_strings.h" 29 #include "components/strings/grit/components_strings.h"
29 #include "components/translate/core/browser/translate_download_manager.h" 30 #include "components/translate/core/browser/translate_download_manager.h"
30 #include "components/translate/core/browser/translate_manager.h" 31 #include "components/translate/core/browser/translate_manager.h"
31 #include "components/translate/core/browser/translate_prefs.h" 32 #include "components/translate/core/browser/translate_prefs.h"
32 #include "components/translate/core/browser/translate_ui_delegate.h" 33 #include "components/translate/core/browser/translate_ui_delegate.h"
33 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
34 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/models/combobox_model.h" 36 #include "ui/base/models/combobox_model.h"
36 #include "ui/base/models/simple_combobox_model.h" 37 #include "ui/base/models/simple_combobox_model.h"
37 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/resources/grit/ui_resources.h" 39 #include "ui/resources/grit/ui_resources.h"
39 #include "ui/views/bubble/bubble_frame_view.h" 40 #include "ui/views/bubble/bubble_frame_view.h"
40 #include "ui/views/controls/button/blue_button.h" 41 #include "ui/views/controls/button/blue_button.h"
41 #include "ui/views/controls/button/checkbox.h" 42 #include "ui/views/controls/button/checkbox.h"
42 #include "ui/views/controls/button/label_button.h" 43 #include "ui/views/controls/button/label_button.h"
43 #include "ui/views/controls/button/md_text_button.h" 44 #include "ui/views/controls/button/md_text_button.h"
44 #include "ui/views/controls/button/menu_button.h" 45 #include "ui/views/controls/button/menu_button.h"
45 #include "ui/views/controls/combobox/combobox.h" 46 #include "ui/views/controls/combobox/combobox.h"
46 #include "ui/views/controls/label.h" 47 #include "ui/views/controls/label.h"
47 #include "ui/views/controls/link.h" 48 #include "ui/views/controls/link.h"
48 #include "ui/views/controls/styled_label.h" 49 #include "ui/views/controls/styled_label.h"
49 #include "ui/views/layout/box_layout.h" 50 #include "ui/views/layout/box_layout.h"
50 #include "ui/views/layout/grid_layout.h" 51 #include "ui/views/layout/grid_layout.h"
51 #include "ui/views/layout/layout_constants.h"
52 #include "ui/views/widget/widget.h" 52 #include "ui/views/widget/widget.h"
53 53
54 namespace { 54 namespace {
55 55
56 views::Link* CreateLink(views::LinkListener* listener, 56 views::Link* CreateLink(views::LinkListener* listener,
57 int resource_id, 57 int resource_id,
58 int id) { 58 int id) {
59 views::Link* link = new views::Link(l10n_util::GetStringUTF16(resource_id)); 59 views::Link* link = new views::Link(l10n_util::GetStringUTF16(resource_id));
60 link->set_listener(listener); 60 link->set_listener(listener);
61 link->set_id(id); 61 link->set_id(id);
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 views::GridLayout* layout = new views::GridLayout(view); 539 views::GridLayout* layout = new views::GridLayout(view);
540 view->SetLayoutManager(layout); 540 view->SetLayoutManager(layout);
541 541
542 using views::GridLayout; 542 using views::GridLayout;
543 543
544 enum { 544 enum {
545 COLUMN_SET_ID_MESSAGE, 545 COLUMN_SET_ID_MESSAGE,
546 COLUMN_SET_ID_CONTENT, 546 COLUMN_SET_ID_CONTENT,
547 }; 547 };
548 548
549 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
550 const int button_spacing =
551 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
552
549 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 553 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
550 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 554 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
551 GridLayout::USE_PREF, 0, 0); 555 GridLayout::USE_PREF, 0, 0);
552 if (Use2016Q2UI()) { 556 if (Use2016Q2UI()) {
553 // Add padding between the icon and the text. 557 // Add padding between the icon and the text.
554 cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); 558 cs->AddPaddingColumn(
559 0, provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL));
555 } else { 560 } else {
556 // Add padding between the text and the link. 561 // Add padding between the text and the link.
557 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 562 cs->AddPaddingColumn(0, button_spacing);
558 } 563 }
559 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, 564 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
560 GridLayout::USE_PREF, 0, 0); 565 GridLayout::USE_PREF, 0, 0);
561 cs->AddPaddingColumn(1, 0); 566 cs->AddPaddingColumn(1, 0);
562 567
563 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 568 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
564 cs->AddPaddingColumn(1, 0); 569 cs->AddPaddingColumn(1, 0);
565 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 570 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
566 GridLayout::USE_PREF, 0, 0); 571 GridLayout::USE_PREF, 0, 0);
567 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 572 cs->AddPaddingColumn(0, button_spacing);
568 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 573 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
569 GridLayout::USE_PREF, 0, 0); 574 GridLayout::USE_PREF, 0, 0);
570 575
571 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 576 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
572 if (Use2016Q2UI()) { 577 if (Use2016Q2UI()) {
573 AddIconToLayout(layout); 578 AddIconToLayout(layout);
574 579
575 base::string16 target_language_name = 580 base::string16 target_language_name =
576 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); 581 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex());
577 std::vector<size_t> offsets; 582 std::vector<size_t> offsets;
(...skipping 17 matching lines...) Expand all
595 layout->AddView(styled_label); 600 layout->AddView(styled_label);
596 } else { 601 } else {
597 layout->AddView(new views::Label( 602 layout->AddView(new views::Label(
598 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE))); 603 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE)));
599 layout->AddView( 604 layout->AddView(
600 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 605 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
601 } 606 }
602 607
603 // In an incognito window, the "Always translate" checkbox shouldn't be shown. 608 // In an incognito window, the "Always translate" checkbox shouldn't be shown.
604 if (Use2016Q2UI() && !is_in_incognito_window_) { 609 if (Use2016Q2UI() && !is_in_incognito_window_) {
605 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 610 layout->AddPaddingRow(0, provider->GetDistanceMetric(
611 views::DISTANCE_RELATED_CONTROL_VERTICAL));
606 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 612 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
607 layout->SkipColumns(1); 613 layout->SkipColumns(1);
608 before_always_translate_checkbox_ = new views::Checkbox( 614 before_always_translate_checkbox_ = new views::Checkbox(
609 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS_DO_THIS)); 615 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS_DO_THIS));
610 before_always_translate_checkbox_->set_id(BUTTON_ID_ALWAYS_TRANSLATE); 616 before_always_translate_checkbox_->set_id(BUTTON_ID_ALWAYS_TRANSLATE);
611 before_always_translate_checkbox_->set_listener(this); 617 before_always_translate_checkbox_->set_listener(this);
612 layout->AddView(before_always_translate_checkbox_); 618 layout->AddView(before_always_translate_checkbox_);
613 } 619 }
620
621 int vertical_spacing = provider->GetDistanceMetric(
622 DISTANCE_UNRELATED_CONTROL_VERTICAL);
614 if (Use2016Q2UI()) { 623 if (Use2016Q2UI()) {
615 layout->AddPaddingRow(0, views::kPanelSubVerticalSpacing); 624 layout->AddPaddingRow(0, vertical_spacing);
616 } else { 625 } else {
617 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 626 layout->AddPaddingRow(0, vertical_spacing);
618 } 627 }
619 628
620 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 629 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
621 views::LabelButton* accept_button = 630 views::LabelButton* accept_button =
622 Use2016Q2UI() 631 Use2016Q2UI()
623 ? views::MdTextButton::CreateSecondaryUiBlueButton( 632 ? views::MdTextButton::CreateSecondaryUiBlueButton(
624 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT)) 633 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT))
625 : views::MdTextButton::CreateSecondaryUiButton( 634 : views::MdTextButton::CreateSecondaryUiButton(
626 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT)); 635 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT));
627 accept_button->set_id(BUTTON_ID_TRANSLATE); 636 accept_button->set_id(BUTTON_ID_TRANSLATE);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 views::GridLayout* layout = new views::GridLayout(view); 673 views::GridLayout* layout = new views::GridLayout(view);
665 view->SetLayoutManager(layout); 674 view->SetLayoutManager(layout);
666 675
667 using views::GridLayout; 676 using views::GridLayout;
668 677
669 enum { 678 enum {
670 COLUMN_SET_ID_MESSAGE, 679 COLUMN_SET_ID_MESSAGE,
671 COLUMN_SET_ID_CONTENT, 680 COLUMN_SET_ID_CONTENT,
672 }; 681 };
673 682
683 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
674 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 684 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
675 if (Use2016Q2UI()) { 685 if (Use2016Q2UI()) {
676 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 686 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
677 views::GridLayout::USE_PREF, 0, 0); 687 views::GridLayout::USE_PREF, 0, 0);
678 // Add padding between the icon and the text. 688 // Add padding between the icon and the text.
679 cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); 689 cs->AddPaddingColumn(
690 0, provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL));
680 } 691 }
681 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 692 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
682 GridLayout::USE_PREF, 0, 0); 693 GridLayout::USE_PREF, 0, 0);
683 cs->AddPaddingColumn(1, 0); 694 cs->AddPaddingColumn(1, 0);
684 695
685 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 696 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
686 cs->AddPaddingColumn(1, 0); 697 cs->AddPaddingColumn(1, 0);
687 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 698 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
688 GridLayout::USE_PREF, 0, 0); 699 GridLayout::USE_PREF, 0, 0);
689 700
690 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 701 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
691 if (Use2016Q2UI()) 702 if (Use2016Q2UI())
692 AddIconToLayout(layout); 703 AddIconToLayout(layout);
693 layout->AddView(label); 704 layout->AddView(label);
694 705
695 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 706 layout->AddPaddingRow(
707 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
696 708
697 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 709 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
698 views::LabelButton* revert_button = 710 views::LabelButton* revert_button =
699 views::MdTextButton::CreateSecondaryUiButton( 711 views::MdTextButton::CreateSecondaryUiButton(
700 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT)); 712 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT));
701 revert_button->set_id(BUTTON_ID_SHOW_ORIGINAL); 713 revert_button->set_id(BUTTON_ID_SHOW_ORIGINAL);
702 revert_button->SetEnabled(false); 714 revert_button->SetEnabled(false);
703 layout->AddView(revert_button); 715 layout->AddView(revert_button);
704 716
705 return view; 717 return view;
706 } 718 }
707 719
708 views::View* TranslateBubbleView::CreateViewAfterTranslate() { 720 views::View* TranslateBubbleView::CreateViewAfterTranslate() {
709 views::Label* label = new views::Label( 721 views::Label* label = new views::Label(
710 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRANSLATED)); 722 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRANSLATED));
711 723
712 views::View* view = new views::View(); 724 views::View* view = new views::View();
713 views::GridLayout* layout = new views::GridLayout(view); 725 views::GridLayout* layout = new views::GridLayout(view);
714 view->SetLayoutManager(layout); 726 view->SetLayoutManager(layout);
715 727
716 using views::GridLayout; 728 using views::GridLayout;
717 729
718 enum { 730 enum {
719 COLUMN_SET_ID_MESSAGE, 731 COLUMN_SET_ID_MESSAGE,
720 COLUMN_SET_ID_CONTENT, 732 COLUMN_SET_ID_CONTENT,
721 }; 733 };
722 734
735 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
736
723 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 737 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
724 738
725 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351 739 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351
726 740
727 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 741 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
728 GridLayout::USE_PREF, 0, 0); 742 GridLayout::USE_PREF, 0, 0);
729 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 743 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
744 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
730 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 745 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
731 GridLayout::USE_PREF, 0, 0); 746 GridLayout::USE_PREF, 0, 0);
732 cs->AddPaddingColumn(1, 0); 747 cs->AddPaddingColumn(1, 0);
733 748
734 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 749 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
735 cs->AddPaddingColumn(1, 0); 750 cs->AddPaddingColumn(1, 0);
736 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 751 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
737 GridLayout::USE_PREF, 0, 0); 752 GridLayout::USE_PREF, 0, 0);
738 753
739 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 754 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
740 layout->AddView(label); 755 layout->AddView(label);
741 layout->AddView( 756 layout->AddView(
742 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 757 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
743 758
744 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 759 layout->AddPaddingRow(
760 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
745 761
746 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 762 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
747 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 763 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
748 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT)); 764 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT));
749 button->set_id(BUTTON_ID_SHOW_ORIGINAL); 765 button->set_id(BUTTON_ID_SHOW_ORIGINAL);
750 layout->AddView(button); 766 layout->AddView(button);
751 767
752 return view; 768 return view;
753 } 769 }
754 770
755 views::View* TranslateBubbleView::CreateViewError() { 771 views::View* TranslateBubbleView::CreateViewError() {
756 views::Label* label = new views::Label( 772 views::Label* label = new views::Label(
757 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_COULD_NOT_TRANSLATE)); 773 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_COULD_NOT_TRANSLATE));
758 774
759 views::View* view = new views::View(); 775 views::View* view = new views::View();
760 views::GridLayout* layout = new views::GridLayout(view); 776 views::GridLayout* layout = new views::GridLayout(view);
761 view->SetLayoutManager(layout); 777 view->SetLayoutManager(layout);
762 778
763 using views::GridLayout; 779 using views::GridLayout;
764 780
765 enum { 781 enum {
766 COLUMN_SET_ID_MESSAGE, 782 COLUMN_SET_ID_MESSAGE,
767 COLUMN_SET_ID_CONTENT, 783 COLUMN_SET_ID_CONTENT,
768 }; 784 };
769 785
786 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
787
770 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 788 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
771 789
772 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351 790 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351
773 791
774 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 792 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
775 GridLayout::USE_PREF, 0, 0); 793 GridLayout::USE_PREF, 0, 0);
776 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 794 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
795 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
777 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 796 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
778 GridLayout::USE_PREF, 0, 0); 797 GridLayout::USE_PREF, 0, 0);
779 cs->AddPaddingColumn(1, 0); 798 cs->AddPaddingColumn(1, 0);
780 799
781 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 800 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
782 cs->AddPaddingColumn(1, 0); 801 cs->AddPaddingColumn(1, 0);
783 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 802 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
784 GridLayout::USE_PREF, 0, 0); 803 GridLayout::USE_PREF, 0, 0);
785 804
786 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 805 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
787 layout->AddView(label); 806 layout->AddView(label);
788 layout->AddView( 807 layout->AddView(
789 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 808 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
790 809
791 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 810 layout->AddPaddingRow(
811 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
792 812
793 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 813 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
794 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 814 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
795 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRY_AGAIN)); 815 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRY_AGAIN));
796 button->set_id(BUTTON_ID_TRY_AGAIN); 816 button->set_id(BUTTON_ID_TRY_AGAIN);
797 layout->AddView(button); 817 layout->AddView(button);
798 818
799 return view; 819 return view;
800 } 820 }
801 821
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 views::GridLayout* layout = new views::GridLayout(view); 857 views::GridLayout* layout = new views::GridLayout(view);
838 view->SetLayoutManager(layout); 858 view->SetLayoutManager(layout);
839 859
840 using views::GridLayout; 860 using views::GridLayout;
841 861
842 enum { 862 enum {
843 COLUMN_SET_ID_LANGUAGES, 863 COLUMN_SET_ID_LANGUAGES,
844 COLUMN_SET_ID_BUTTONS, 864 COLUMN_SET_ID_BUTTONS,
845 }; 865 };
846 866
867 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
868
847 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_LANGUAGES); 869 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_LANGUAGES);
848 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 870 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
849 GridLayout::USE_PREF, 0, 0); 871 GridLayout::USE_PREF, 0, 0);
850 cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 872 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
873 views::DISTANCE_RELATED_CONTROL_HORIZONTAL));
851 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF, 874 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF,
852 0, 0); 875 0, 0);
853 cs->AddPaddingColumn(1, 0); 876 cs->AddPaddingColumn(1, 0);
854 877
855 cs = layout->AddColumnSet(COLUMN_SET_ID_BUTTONS); 878 cs = layout->AddColumnSet(COLUMN_SET_ID_BUTTONS);
856 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 879 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
857 GridLayout::USE_PREF, 0, 0); 880 GridLayout::USE_PREF, 0, 0);
858 cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing); 881 cs->AddPaddingColumn(
882 1, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
859 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 883 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
860 GridLayout::USE_PREF, 0, 0); 884 GridLayout::USE_PREF, 0, 0);
861 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 885 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
886 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
862 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 887 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
863 GridLayout::USE_PREF, 0, 0); 888 GridLayout::USE_PREF, 0, 0);
864 889
865 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 890 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
866 layout->AddView(source_language_label); 891 layout->AddView(source_language_label);
867 layout->AddView(source_language_combobox_); 892 layout->AddView(source_language_combobox_);
868 893
869 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 894 const int vertical_spacing =
895 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
896 layout->AddPaddingRow(0, vertical_spacing);
870 897
871 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 898 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
872 layout->AddView(target_language_label); 899 layout->AddView(target_language_label);
873 layout->AddView(target_language_combobox_); 900 layout->AddView(target_language_combobox_);
874 901
875 if (!is_in_incognito_window_) { 902 if (!is_in_incognito_window_) {
876 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 903 layout->AddPaddingRow(0, vertical_spacing);
877 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 904 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
878 layout->SkipColumns(1); 905 layout->SkipColumns(1);
879 layout->AddView(advanced_always_translate_checkbox_); 906 layout->AddView(advanced_always_translate_checkbox_);
880 } 907 }
881 908
882 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 909 layout->AddPaddingRow(
910 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
883 911
884 layout->StartRow(0, COLUMN_SET_ID_BUTTONS); 912 layout->StartRow(0, COLUMN_SET_ID_BUTTONS);
885 // TODO(estade): this should use CreateExtraView(). 913 // TODO(estade): this should use CreateExtraView().
886 layout->AddView(CreateLink(this, IDS_TRANSLATE_BUBBLE_LANGUAGE_SETTINGS, 914 layout->AddView(CreateLink(this, IDS_TRANSLATE_BUBBLE_LANGUAGE_SETTINGS,
887 LINK_ID_LANGUAGE_SETTINGS)); 915 LINK_ID_LANGUAGE_SETTINGS));
888 advanced_done_button_ = 916 advanced_done_button_ =
889 Use2016Q2UI() ? views::MdTextButton::CreateSecondaryUiBlueButton( 917 Use2016Q2UI() ? views::MdTextButton::CreateSecondaryUiBlueButton(
890 this, l10n_util::GetStringUTF16(IDS_DONE)) 918 this, l10n_util::GetStringUTF16(IDS_DONE))
891 : views::MdTextButton::CreateSecondaryUiButton( 919 : views::MdTextButton::CreateSecondaryUiButton(
892 this, l10n_util::GetStringUTF16(IDS_DONE)); 920 this, l10n_util::GetStringUTF16(IDS_DONE));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 base::string16 label; 982 base::string16 label;
955 if (model_->IsPageTranslatedInCurrentLanguages()) 983 if (model_->IsPageTranslatedInCurrentLanguages())
956 label = l10n_util::GetStringUTF16(IDS_DONE); 984 label = l10n_util::GetStringUTF16(IDS_DONE);
957 else 985 else
958 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 986 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
959 advanced_done_button_->SetText(label); 987 advanced_done_button_->SetText(label);
960 advanced_done_button_->SizeToPreferredSize(); 988 advanced_done_button_->SizeToPreferredSize();
961 if (advanced_view_) 989 if (advanced_view_)
962 advanced_view_->Layout(); 990 advanced_view_->Layout();
963 } 991 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698