OLD | NEW |
---|---|
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 "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 if (ShouldShowKeywordBubble()) { | 640 if (ShouldShowKeywordBubble()) { |
641 // The selected keyword view can collapse completely. | 641 // The selected keyword view can collapse completely. |
642 } else if (ShouldShowEVBubble()) { | 642 } else if (ShouldShowEVBubble()) { |
643 leading_width += kBubblePadding + | 643 leading_width += kBubblePadding + |
644 ev_bubble_view_->GetMinimumSizeForLabelText( | 644 ev_bubble_view_->GetMinimumSizeForLabelText( |
645 GetToolbarModel()->GetEVCertName()).width(); | 645 GetToolbarModel()->GetEVCertName()).width(); |
646 } else if (!origin_chip_view_->visible()) { | 646 } else if (!origin_chip_view_->visible()) { |
647 leading_width += | 647 leading_width += |
648 kItemPadding + location_icon_view_->GetMinimumSize().width(); | 648 kItemPadding + location_icon_view_->GetMinimumSize().width(); |
649 } | 649 } |
650 leading_width += kItemPadding - GetEditLeadingInternalSpace(); | 650 leading_width += kItemPadding - views::Textfield::kTextPadding - |
651 GetEditLeadingInternalSpace(); | |
651 | 652 |
652 // Compute width of omnibox-trailing content. | 653 // Compute width of omnibox-trailing content. |
653 int trailing_width = search_button_->visible() ? | 654 int trailing_width = search_button_->visible() ? |
654 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : | 655 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : |
655 horizontal_edge_thickness; | 656 horizontal_edge_thickness; |
656 trailing_width += IncrementalMinimumWidth(star_view_) + | 657 trailing_width += IncrementalMinimumWidth(star_view_) + |
657 IncrementalMinimumWidth(translate_icon_view_) + | 658 IncrementalMinimumWidth(translate_icon_view_) + |
658 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | 659 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
659 IncrementalMinimumWidth(manage_passwords_icon_view_) + | 660 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
660 IncrementalMinimumWidth(zoom_view_) + | 661 IncrementalMinimumWidth(zoom_view_) + |
661 IncrementalMinimumWidth(generated_credit_card_view_) + | 662 IncrementalMinimumWidth(generated_credit_card_view_) + |
662 IncrementalMinimumWidth(mic_search_view_) + kItemPadding; | 663 IncrementalMinimumWidth(mic_search_view_) + |
664 kItemPadding - views::Textfield::kTextPadding; | |
663 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 665 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
664 i != page_action_views_.end(); ++i) | 666 i != page_action_views_.end(); ++i) |
665 trailing_width += IncrementalMinimumWidth((*i)); | 667 trailing_width += IncrementalMinimumWidth((*i)); |
666 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 668 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
667 i != content_setting_views_.end(); ++i) | 669 i != content_setting_views_.end(); ++i) |
668 trailing_width += IncrementalMinimumWidth((*i)); | 670 trailing_width += IncrementalMinimumWidth((*i)); |
669 | 671 |
670 min_size.set_width( | 672 min_size.set_width( |
671 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); | 673 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); |
672 return min_size; | 674 return min_size; |
673 } | 675 } |
674 | 676 |
675 void LocationBarView::Layout() { | 677 void LocationBarView::Layout() { |
676 if (!IsInitialized()) | 678 if (!IsInitialized()) |
677 return; | 679 return; |
678 | 680 |
679 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); | 681 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); |
680 selected_keyword_view_->SetVisible(false); | 682 selected_keyword_view_->SetVisible(false); |
681 location_icon_view_->SetVisible(false); | 683 location_icon_view_->SetVisible(false); |
682 ev_bubble_view_->SetVisible(false); | 684 ev_bubble_view_->SetVisible(false); |
683 keyword_hint_view_->SetVisible(false); | 685 keyword_hint_view_->SetVisible(false); |
684 | 686 |
687 const int edge_padding = kItemPadding - views::Textfield::kTextPadding; | |
Peter Kasting
2014/08/30 00:46:43
Nit: Good idea on the constant, why not do it in G
msw
2014/09/04 01:25:51
Done.
| |
685 LocationBarLayout leading_decorations( | 688 LocationBarLayout leading_decorations( |
686 LocationBarLayout::LEFT_EDGE, | 689 LocationBarLayout::LEFT_EDGE, |
687 kItemPadding - GetEditLeadingInternalSpace()); | 690 edge_padding - GetEditLeadingInternalSpace()); |
688 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, | 691 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, |
689 kItemPadding); | 692 edge_padding); |
690 | 693 |
691 const int origin_chip_preferred_width = | 694 const int origin_chip_preferred_width = |
692 origin_chip_view_->GetPreferredSize().width(); | 695 origin_chip_view_->GetPreferredSize().width(); |
693 const int origin_chip_width = | 696 const int origin_chip_width = |
694 origin_chip_view_->visible() ? origin_chip_preferred_width : 0; | 697 origin_chip_view_->visible() ? origin_chip_preferred_width : 0; |
695 // Always give the origin chip view its desired size and lay it out, even when | 698 // Always give the origin chip view its desired size and lay it out, even when |
696 // it's not visible, so we can calculate the correct animation values below | 699 // it's not visible, so we can calculate the correct animation values below |
697 // when switching to tabs that have the origin chip hidden. | 700 // when switching to tabs that have the origin chip hidden. |
698 origin_chip_view_->SetBounds(0, 0, origin_chip_preferred_width, height()); | 701 origin_chip_view_->SetBounds(0, 0, origin_chip_preferred_width, height()); |
699 origin_chip_view_->Layout(); | 702 origin_chip_view_->Layout(); |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1699 | 1702 |
1700 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1703 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1701 const SearchModel::State& new_state) { | 1704 const SearchModel::State& new_state) { |
1702 const bool visible = !GetToolbarModel()->input_in_progress() && | 1705 const bool visible = !GetToolbarModel()->input_in_progress() && |
1703 new_state.voice_search_supported; | 1706 new_state.voice_search_supported; |
1704 if (mic_search_view_->visible() != visible) { | 1707 if (mic_search_view_->visible() != visible) { |
1705 mic_search_view_->SetVisible(visible); | 1708 mic_search_view_->SetVisible(visible); |
1706 Layout(); | 1709 Layout(); |
1707 } | 1710 } |
1708 } | 1711 } |
OLD | NEW |