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

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

Issue 2902873002: Views/Harmony Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Fix patch failures. 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
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 views::GridLayout* layout = new views::GridLayout(view); 536 views::GridLayout* layout = new views::GridLayout(view);
537 view->SetLayoutManager(layout); 537 view->SetLayoutManager(layout);
538 538
539 using views::GridLayout; 539 using views::GridLayout;
540 540
541 enum { 541 enum {
542 COLUMN_SET_ID_MESSAGE, 542 COLUMN_SET_ID_MESSAGE,
543 COLUMN_SET_ID_CONTENT, 543 COLUMN_SET_ID_CONTENT,
544 }; 544 };
545 545
546 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
547 const int button_spacing =
548 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
549
546 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 550 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
547 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 551 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
548 GridLayout::USE_PREF, 0, 0); 552 GridLayout::USE_PREF, 0, 0);
549 if (Use2016Q2UI()) { 553 if (Use2016Q2UI()) {
550 // Add padding between the icon and the text. 554 // Add padding between the icon and the text.
551 cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); 555 cs->AddPaddingColumn(
556 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
552 } else { 557 } else {
553 // Add padding between the text and the link. 558 // Add padding between the text and the link.
554 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 559 cs->AddPaddingColumn(0, button_spacing);
555 } 560 }
556 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, 561 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
557 GridLayout::USE_PREF, 0, 0); 562 GridLayout::USE_PREF, 0, 0);
558 cs->AddPaddingColumn(1, 0); 563 cs->AddPaddingColumn(1, 0);
559 564
560 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 565 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
561 cs->AddPaddingColumn(1, 0); 566 cs->AddPaddingColumn(1, 0);
562 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 567 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
563 GridLayout::USE_PREF, 0, 0); 568 GridLayout::USE_PREF, 0, 0);
564 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 569 cs->AddPaddingColumn(0, button_spacing);
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 572
568 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 573 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
569 if (Use2016Q2UI()) { 574 if (Use2016Q2UI()) {
570 AddIconToLayout(layout); 575 AddIconToLayout(layout);
571 576
572 base::string16 target_language_name = 577 base::string16 target_language_name =
573 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); 578 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex());
574 std::vector<size_t> offsets; 579 std::vector<size_t> offsets;
(...skipping 17 matching lines...) Expand all
592 layout->AddView(styled_label); 597 layout->AddView(styled_label);
593 } else { 598 } else {
594 layout->AddView(new views::Label( 599 layout->AddView(new views::Label(
595 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE))); 600 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE)));
596 layout->AddView( 601 layout->AddView(
597 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 602 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
598 } 603 }
599 604
600 // In an incognito window, the "Always translate" checkbox shouldn't be shown. 605 // In an incognito window, the "Always translate" checkbox shouldn't be shown.
601 if (Use2016Q2UI() && !is_in_incognito_window_) { 606 if (Use2016Q2UI() && !is_in_incognito_window_) {
602 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 607 layout->AddPaddingRow(0, provider->GetDistanceMetric(
608 views::DISTANCE_RELATED_CONTROL_VERTICAL));
603 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 609 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
604 layout->SkipColumns(1); 610 layout->SkipColumns(1);
605 before_always_translate_checkbox_ = new views::Checkbox( 611 before_always_translate_checkbox_ = new views::Checkbox(
606 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS_DO_THIS)); 612 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS_DO_THIS));
607 before_always_translate_checkbox_->set_id(BUTTON_ID_ALWAYS_TRANSLATE); 613 before_always_translate_checkbox_->set_id(BUTTON_ID_ALWAYS_TRANSLATE);
608 before_always_translate_checkbox_->set_listener(this); 614 before_always_translate_checkbox_->set_listener(this);
609 layout->AddView(before_always_translate_checkbox_); 615 layout->AddView(before_always_translate_checkbox_);
610 } 616 }
611 if (Use2016Q2UI()) { 617 if (Use2016Q2UI()) {
612 layout->AddPaddingRow(0, views::kPanelSubVerticalSpacing); 618 layout->AddPaddingRow(
619 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
613 } else { 620 } else {
614 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 621 layout->AddPaddingRow(
622 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
615 } 623 }
616 624
617 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 625 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
618 views::LabelButton* accept_button = 626 views::LabelButton* accept_button =
619 Use2016Q2UI() 627 Use2016Q2UI()
620 ? views::MdTextButton::CreateSecondaryUiBlueButton( 628 ? views::MdTextButton::CreateSecondaryUiBlueButton(
621 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT)) 629 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT))
622 : views::MdTextButton::CreateSecondaryUiButton( 630 : views::MdTextButton::CreateSecondaryUiButton(
623 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT)); 631 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT));
624 accept_button->set_id(BUTTON_ID_TRANSLATE); 632 accept_button->set_id(BUTTON_ID_TRANSLATE);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 views::GridLayout* layout = new views::GridLayout(view); 669 views::GridLayout* layout = new views::GridLayout(view);
662 view->SetLayoutManager(layout); 670 view->SetLayoutManager(layout);
663 671
664 using views::GridLayout; 672 using views::GridLayout;
665 673
666 enum { 674 enum {
667 COLUMN_SET_ID_MESSAGE, 675 COLUMN_SET_ID_MESSAGE,
668 COLUMN_SET_ID_CONTENT, 676 COLUMN_SET_ID_CONTENT,
669 }; 677 };
670 678
679 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
671 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 680 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
672 if (Use2016Q2UI()) { 681 if (Use2016Q2UI()) {
673 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 682 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
674 views::GridLayout::USE_PREF, 0, 0); 683 views::GridLayout::USE_PREF, 0, 0);
675 // Add padding between the icon and the text. 684 // Add padding between the icon and the text.
676 cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); 685 cs->AddPaddingColumn(
686 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
677 } 687 }
678 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 688 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
679 GridLayout::USE_PREF, 0, 0); 689 GridLayout::USE_PREF, 0, 0);
680 cs->AddPaddingColumn(1, 0); 690 cs->AddPaddingColumn(1, 0);
681 691
682 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 692 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
683 cs->AddPaddingColumn(1, 0); 693 cs->AddPaddingColumn(1, 0);
684 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 694 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
685 GridLayout::USE_PREF, 0, 0); 695 GridLayout::USE_PREF, 0, 0);
686 696
687 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 697 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
688 if (Use2016Q2UI()) 698 if (Use2016Q2UI())
689 AddIconToLayout(layout); 699 AddIconToLayout(layout);
690 layout->AddView(label); 700 layout->AddView(label);
691 701
692 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 702 layout->AddPaddingRow(
703 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
693 704
694 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 705 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
695 views::LabelButton* revert_button = 706 views::LabelButton* revert_button =
696 views::MdTextButton::CreateSecondaryUiButton( 707 views::MdTextButton::CreateSecondaryUiButton(
697 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT)); 708 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT));
698 revert_button->set_id(BUTTON_ID_SHOW_ORIGINAL); 709 revert_button->set_id(BUTTON_ID_SHOW_ORIGINAL);
699 revert_button->SetEnabled(false); 710 revert_button->SetEnabled(false);
700 layout->AddView(revert_button); 711 layout->AddView(revert_button);
701 712
702 return view; 713 return view;
703 } 714 }
704 715
705 views::View* TranslateBubbleView::CreateViewAfterTranslate() { 716 views::View* TranslateBubbleView::CreateViewAfterTranslate() {
706 views::Label* label = new views::Label( 717 views::Label* label = new views::Label(
707 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRANSLATED)); 718 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRANSLATED));
708 719
709 views::View* view = new views::View(); 720 views::View* view = new views::View();
710 views::GridLayout* layout = new views::GridLayout(view); 721 views::GridLayout* layout = new views::GridLayout(view);
711 view->SetLayoutManager(layout); 722 view->SetLayoutManager(layout);
712 723
713 using views::GridLayout; 724 using views::GridLayout;
714 725
715 enum { 726 enum {
716 COLUMN_SET_ID_MESSAGE, 727 COLUMN_SET_ID_MESSAGE,
717 COLUMN_SET_ID_CONTENT, 728 COLUMN_SET_ID_CONTENT,
718 }; 729 };
719 730
731 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
732
720 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 733 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
721 734
722 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351 735 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351
723 736
724 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 737 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
725 GridLayout::USE_PREF, 0, 0); 738 GridLayout::USE_PREF, 0, 0);
726 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 739 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
740 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
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(1, 0); 743 cs->AddPaddingColumn(1, 0);
730 744
731 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 745 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
732 cs->AddPaddingColumn(1, 0); 746 cs->AddPaddingColumn(1, 0);
733 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 747 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
734 GridLayout::USE_PREF, 0, 0); 748 GridLayout::USE_PREF, 0, 0);
735 749
736 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 750 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
737 layout->AddView(label); 751 layout->AddView(label);
738 layout->AddView( 752 layout->AddView(
739 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 753 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
740 754
741 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 755 layout->AddPaddingRow(
756 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
742 757
743 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 758 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
744 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 759 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
745 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT)); 760 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT));
746 button->set_id(BUTTON_ID_SHOW_ORIGINAL); 761 button->set_id(BUTTON_ID_SHOW_ORIGINAL);
747 layout->AddView(button); 762 layout->AddView(button);
748 763
749 return view; 764 return view;
750 } 765 }
751 766
752 views::View* TranslateBubbleView::CreateViewError() { 767 views::View* TranslateBubbleView::CreateViewError() {
753 views::Label* label = new views::Label( 768 views::Label* label = new views::Label(
754 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_COULD_NOT_TRANSLATE)); 769 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_COULD_NOT_TRANSLATE));
755 770
756 views::View* view = new views::View(); 771 views::View* view = new views::View();
757 views::GridLayout* layout = new views::GridLayout(view); 772 views::GridLayout* layout = new views::GridLayout(view);
758 view->SetLayoutManager(layout); 773 view->SetLayoutManager(layout);
759 774
760 using views::GridLayout; 775 using views::GridLayout;
761 776
762 enum { 777 enum {
763 COLUMN_SET_ID_MESSAGE, 778 COLUMN_SET_ID_MESSAGE,
764 COLUMN_SET_ID_CONTENT, 779 COLUMN_SET_ID_CONTENT,
765 }; 780 };
766 781
782 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
783
767 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 784 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
768 785
769 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351 786 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351
770 787
771 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 788 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
772 GridLayout::USE_PREF, 0, 0); 789 GridLayout::USE_PREF, 0, 0);
773 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 790 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
791 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
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(1, 0); 794 cs->AddPaddingColumn(1, 0);
777 795
778 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 796 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
779 cs->AddPaddingColumn(1, 0); 797 cs->AddPaddingColumn(1, 0);
780 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 798 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
781 GridLayout::USE_PREF, 0, 0); 799 GridLayout::USE_PREF, 0, 0);
782 800
783 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 801 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
784 layout->AddView(label); 802 layout->AddView(label);
785 layout->AddView( 803 layout->AddView(
786 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 804 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
787 805
788 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 806 layout->AddPaddingRow(
807 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
789 808
790 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 809 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
791 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 810 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
792 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRY_AGAIN)); 811 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRY_AGAIN));
793 button->set_id(BUTTON_ID_TRY_AGAIN); 812 button->set_id(BUTTON_ID_TRY_AGAIN);
794 layout->AddView(button); 813 layout->AddView(button);
795 814
796 return view; 815 return view;
797 } 816 }
798 817
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 views::GridLayout* layout = new views::GridLayout(view); 853 views::GridLayout* layout = new views::GridLayout(view);
835 view->SetLayoutManager(layout); 854 view->SetLayoutManager(layout);
836 855
837 using views::GridLayout; 856 using views::GridLayout;
838 857
839 enum { 858 enum {
840 COLUMN_SET_ID_LANGUAGES, 859 COLUMN_SET_ID_LANGUAGES,
841 COLUMN_SET_ID_BUTTONS, 860 COLUMN_SET_ID_BUTTONS,
842 }; 861 };
843 862
863 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
864
844 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_LANGUAGES); 865 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_LANGUAGES);
845 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 866 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
846 GridLayout::USE_PREF, 0, 0); 867 GridLayout::USE_PREF, 0, 0);
847 cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 868 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
869 views::DISTANCE_RELATED_CONTROL_HORIZONTAL));
848 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF, 870 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF,
849 0, 0); 871 0, 0);
850 cs->AddPaddingColumn(1, 0); 872 cs->AddPaddingColumn(1, 0);
851 873
852 cs = layout->AddColumnSet(COLUMN_SET_ID_BUTTONS); 874 cs = layout->AddColumnSet(COLUMN_SET_ID_BUTTONS);
853 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 875 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
854 GridLayout::USE_PREF, 0, 0); 876 GridLayout::USE_PREF, 0, 0);
855 cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing); 877 cs->AddPaddingColumn(
878 1, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
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(0, views::kRelatedButtonHSpacing); 881 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
882 views::DISTANCE_RELATED_BUTTON_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 885
862 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 886 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
863 layout->AddView(source_language_label); 887 layout->AddView(source_language_label);
864 layout->AddView(source_language_combobox_); 888 layout->AddView(source_language_combobox_);
865 889
866 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 890 const int vertical_spacing =
891 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
892 layout->AddPaddingRow(0, vertical_spacing);
867 893
868 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 894 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
869 layout->AddView(target_language_label); 895 layout->AddView(target_language_label);
870 layout->AddView(target_language_combobox_); 896 layout->AddView(target_language_combobox_);
871 897
872 if (!is_in_incognito_window_) { 898 if (!is_in_incognito_window_) {
873 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 899 layout->AddPaddingRow(0, vertical_spacing);
874 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 900 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
875 layout->SkipColumns(1); 901 layout->SkipColumns(1);
876 layout->AddView(advanced_always_translate_checkbox_); 902 layout->AddView(advanced_always_translate_checkbox_);
877 } 903 }
878 904
879 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 905 layout->AddPaddingRow(
906 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
880 907
881 layout->StartRow(0, COLUMN_SET_ID_BUTTONS); 908 layout->StartRow(0, COLUMN_SET_ID_BUTTONS);
882 // TODO(estade): this should use CreateExtraView(). 909 // TODO(estade): this should use CreateExtraView().
883 layout->AddView(CreateLink(this, IDS_TRANSLATE_BUBBLE_LANGUAGE_SETTINGS, 910 layout->AddView(CreateLink(this, IDS_TRANSLATE_BUBBLE_LANGUAGE_SETTINGS,
884 LINK_ID_LANGUAGE_SETTINGS)); 911 LINK_ID_LANGUAGE_SETTINGS));
885 advanced_done_button_ = 912 advanced_done_button_ =
886 Use2016Q2UI() ? views::MdTextButton::CreateSecondaryUiBlueButton( 913 Use2016Q2UI() ? views::MdTextButton::CreateSecondaryUiBlueButton(
887 this, l10n_util::GetStringUTF16(IDS_DONE)) 914 this, l10n_util::GetStringUTF16(IDS_DONE))
888 : views::MdTextButton::CreateSecondaryUiButton( 915 : views::MdTextButton::CreateSecondaryUiButton(
889 this, l10n_util::GetStringUTF16(IDS_DONE)); 916 this, l10n_util::GetStringUTF16(IDS_DONE));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 base::string16 label; 978 base::string16 label;
952 if (model_->IsPageTranslatedInCurrentLanguages()) 979 if (model_->IsPageTranslatedInCurrentLanguages())
953 label = l10n_util::GetStringUTF16(IDS_DONE); 980 label = l10n_util::GetStringUTF16(IDS_DONE);
954 else 981 else
955 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 982 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
956 advanced_done_button_->SetText(label); 983 advanced_done_button_->SetText(label);
957 advanced_done_button_->SizeToPreferredSize(); 984 advanced_done_button_->SizeToPreferredSize();
958 if (advanced_view_) 985 if (advanced_view_)
959 advanced_view_->Layout(); 986 advanced_view_->Layout();
960 } 987 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698