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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 250793004: Remove builtin_padding from LocationBarLayout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_layout.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 (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/command_line.h" 10 #include "base/command_line.h"
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 const bool is_keyword_hint(omnibox_view_->model()->is_keyword_hint()); 785 const bool is_keyword_hint(omnibox_view_->model()->is_keyword_hint());
786 const int bubble_location_y = vertical_edge_thickness() + kBubblePadding; 786 const int bubble_location_y = vertical_edge_thickness() + kBubblePadding;
787 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want 787 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want
788 // to position our child views in this case, because other things may be 788 // to position our child views in this case, because other things may be
789 // positioned relative to them (e.g. the "bookmark added" bubble if the user 789 // positioned relative to them (e.g. the "bookmark added" bubble if the user
790 // hits ctrl-d). 790 // hits ctrl-d).
791 const int location_height = GetInternalHeight(false); 791 const int location_height = GetInternalHeight(false);
792 const int bubble_height = std::max(location_height - (kBubblePadding * 2), 0); 792 const int bubble_height = std::max(location_height - (kBubblePadding * 2), 0);
793 if (!keyword.empty() && !is_keyword_hint) { 793 if (!keyword.empty() && !is_keyword_hint) {
794 leading_decorations.AddDecoration(bubble_location_y, bubble_height, true, 0, 794 leading_decorations.AddDecoration(bubble_location_y, bubble_height, true, 0,
795 kBubblePadding, kItemPadding, 0, 795 kBubblePadding, kItemPadding,
796 selected_keyword_view_); 796 selected_keyword_view_);
797 if (selected_keyword_view_->keyword() != keyword) { 797 if (selected_keyword_view_->keyword() != keyword) {
798 selected_keyword_view_->SetKeyword(keyword); 798 selected_keyword_view_->SetKeyword(keyword);
799 const TemplateURL* template_url = 799 const TemplateURL* template_url =
800 TemplateURLServiceFactory::GetForProfile(profile())-> 800 TemplateURLServiceFactory::GetForProfile(profile())->
801 GetTemplateURLForKeyword(keyword); 801 GetTemplateURLForKeyword(keyword);
802 if (template_url && 802 if (template_url &&
803 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { 803 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) {
804 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> 804 gfx::Image image = extensions::OmniboxAPI::Get(profile())->
805 GetOmniboxIcon(template_url->GetExtensionId()); 805 GetOmniboxIcon(template_url->GetExtensionId());
806 selected_keyword_view_->SetImage(image.AsImageSkia()); 806 selected_keyword_view_->SetImage(image.AsImageSkia());
807 selected_keyword_view_->set_is_extension_icon(true); 807 selected_keyword_view_->set_is_extension_icon(true);
808 } else { 808 } else {
809 selected_keyword_view_->SetImage( 809 selected_keyword_view_->SetImage(
810 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); 810 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH)));
811 selected_keyword_view_->set_is_extension_icon(false); 811 selected_keyword_view_->set_is_extension_icon(false);
812 } 812 }
813 } 813 }
814 } else if (!toolbar_origin_chip_view_ && 814 } else if (!toolbar_origin_chip_view_ &&
815 !chrome::ShouldDisplayOriginChipV2() && 815 !chrome::ShouldDisplayOriginChipV2() &&
816 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { 816 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) {
817 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); 817 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName());
818 // The largest fraction of the omnibox that can be taken by the EV bubble. 818 // The largest fraction of the omnibox that can be taken by the EV bubble.
819 const double kMaxBubbleFraction = 0.5; 819 const double kMaxBubbleFraction = 0.5;
820 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, 820 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false,
821 kMaxBubbleFraction, kBubblePadding, 821 kMaxBubbleFraction, kBubblePadding,
822 kItemPadding, 0, ev_bubble_view_); 822 kItemPadding, ev_bubble_view_);
823 } else if (!origin_chip_view_->visible()) { 823 } else if (!origin_chip_view_->visible()) {
824 leading_decorations.AddDecoration( 824 leading_decorations.AddDecoration(
825 vertical_edge_thickness(), location_height, 825 vertical_edge_thickness(), location_height,
826 0,
827 location_icon_view_); 826 location_icon_view_);
828 } 827 }
829 828
830 if (star_view_->visible()) { 829 if (star_view_->visible()) {
831 trailing_decorations.AddDecoration( 830 trailing_decorations.AddDecoration(
832 vertical_edge_thickness(), location_height, 831 vertical_edge_thickness(), location_height, star_view_);
833 0, star_view_);
834 } 832 }
835 if (translate_icon_view_->visible()) { 833 if (translate_icon_view_->visible()) {
836 trailing_decorations.AddDecoration( 834 trailing_decorations.AddDecoration(
837 vertical_edge_thickness(), location_height, 835 vertical_edge_thickness(), location_height, translate_icon_view_);
838 0,
839 translate_icon_view_);
840 } 836 }
841 if (open_pdf_in_reader_view_->visible()) { 837 if (open_pdf_in_reader_view_->visible()) {
842 trailing_decorations.AddDecoration( 838 trailing_decorations.AddDecoration(
843 vertical_edge_thickness(), location_height, 839 vertical_edge_thickness(), location_height, open_pdf_in_reader_view_);
844 0,
845 open_pdf_in_reader_view_);
846 } 840 }
847 if (manage_passwords_icon_view_->visible()) { 841 if (manage_passwords_icon_view_->visible()) {
848 trailing_decorations.AddDecoration(vertical_edge_thickness(), 842 trailing_decorations.AddDecoration(vertical_edge_thickness(),
849 location_height, 0, 843 location_height,
850 manage_passwords_icon_view_); 844 manage_passwords_icon_view_);
851 } 845 }
852 for (PageActionViews::const_iterator i(page_action_views_.begin()); 846 for (PageActionViews::const_iterator i(page_action_views_.begin());
853 i != page_action_views_.end(); ++i) { 847 i != page_action_views_.end(); ++i) {
854 if ((*i)->visible()) { 848 if ((*i)->visible()) {
855 trailing_decorations.AddDecoration( 849 trailing_decorations.AddDecoration(
856 vertical_edge_thickness(), location_height, 850 vertical_edge_thickness(), location_height, (*i));
857 0, (*i));
858 } 851 }
859 } 852 }
860 if (zoom_view_->visible()) { 853 if (zoom_view_->visible()) {
861 trailing_decorations.AddDecoration(vertical_edge_thickness(), 854 trailing_decorations.AddDecoration(vertical_edge_thickness(),
862 location_height, 0, zoom_view_); 855 location_height, zoom_view_);
863 } 856 }
864 for (ContentSettingViews::const_reverse_iterator i( 857 for (ContentSettingViews::const_reverse_iterator i(
865 content_setting_views_.rbegin()); i != content_setting_views_.rend(); 858 content_setting_views_.rbegin()); i != content_setting_views_.rend();
866 ++i) { 859 ++i) {
867 if ((*i)->visible()) { 860 if ((*i)->visible()) {
868 trailing_decorations.AddDecoration( 861 trailing_decorations.AddDecoration(
869 bubble_location_y, bubble_height, false, 0, kItemPadding, 862 bubble_location_y, bubble_height, false, 0, kItemPadding,
870 kItemPadding, 0, (*i)); 863 kItemPadding, (*i));
871 } 864 }
872 } 865 }
873 if (generated_credit_card_view_->visible()) { 866 if (generated_credit_card_view_->visible()) {
874 trailing_decorations.AddDecoration(vertical_edge_thickness(), 867 trailing_decorations.AddDecoration(vertical_edge_thickness(),
875 location_height, 0, 868 location_height,
876 generated_credit_card_view_); 869 generated_credit_card_view_);
877 } 870 }
878 if (mic_search_view_->visible()) { 871 if (mic_search_view_->visible()) {
879 trailing_decorations.AddDecoration(vertical_edge_thickness(), 872 trailing_decorations.AddDecoration(vertical_edge_thickness(),
880 location_height, 0, mic_search_view_); 873 location_height, mic_search_view_);
881 } 874 }
882 // Because IMEs may eat the tab key, we don't show "press tab to search" while 875 // Because IMEs may eat the tab key, we don't show "press tab to search" while
883 // IME composition is in progress. 876 // IME composition is in progress.
884 if (!keyword.empty() && is_keyword_hint && !omnibox_view_->IsImeComposing()) { 877 if (!keyword.empty() && is_keyword_hint && !omnibox_view_->IsImeComposing()) {
885 trailing_decorations.AddDecoration(vertical_edge_thickness(), 878 trailing_decorations.AddDecoration(vertical_edge_thickness(),
886 location_height, true, 0, kItemPadding, 879 location_height, true, 0, kItemPadding,
887 kItemPadding, 0, keyword_hint_view_); 880 kItemPadding, keyword_hint_view_);
888 if (keyword_hint_view_->keyword() != keyword) 881 if (keyword_hint_view_->keyword() != keyword)
889 keyword_hint_view_->SetKeyword(keyword); 882 keyword_hint_view_->SetKeyword(keyword);
890 } 883 }
891 884
892 // Perform layout. 885 // Perform layout.
893 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); 886 const int horizontal_edge_thickness = GetHorizontalEdgeThickness();
894 int full_width = width() - horizontal_edge_thickness - origin_chip_width; 887 int full_width = width() - horizontal_edge_thickness - origin_chip_width;
895 888
896 // The search button images are made to look as if they overlay the normal 889 // The search button images are made to look as if they overlay the normal
897 // edge images, but to align things, the search button needs to be inset 890 // edge images, but to align things, the search button needs to be inset
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1668 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1676 const SearchModel::State& new_state) { 1669 const SearchModel::State& new_state) {
1677 const bool visible = !GetToolbarModel()->input_in_progress() && 1670 const bool visible = !GetToolbarModel()->input_in_progress() &&
1678 new_state.voice_search_supported; 1671 new_state.voice_search_supported;
1679 if (mic_search_view_->visible() != visible) { 1672 if (mic_search_view_->visible() != visible) {
1680 mic_search_view_->SetVisible(visible); 1673 mic_search_view_->SetVisible(visible);
1681 Layout(); 1674 Layout();
1682 } 1675 }
1683 } 1676 }
1684 1677
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_layout.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698