| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 #if !defined(OS_CHROMEOS) | 99 #if !defined(OS_CHROMEOS) |
| 100 #include "chrome/browser/ui/views/first_run_bubble.h" | 100 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 using content::WebContents; | 103 using content::WebContents; |
| 104 using views::View; | 104 using views::View; |
| 105 | 105 |
| 106 namespace { | 106 namespace { |
| 107 | 107 |
| 108 #if !defined(OS_CHROMEOS) | 108 // The search button images are made to look as if they overlay the normal edge |
| 109 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { | 109 // images, but to align things, the search button needs to be inset horizontally |
| 110 WebContents* web_contents = delegate->GetWebContents(); | 110 // by 1 px. |
| 111 return web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; | 111 const int kSearchButtonInset = 1; |
| 112 } | |
| 113 #endif | |
| 114 | 112 |
| 115 // Given a containing |height| and a |base_font_list|, shrinks the font size | 113 // Given a containing |height| and a |base_font_list|, shrinks the font size |
| 116 // until the font list will fit within |height| while having its cap height | 114 // until the font list will fit within |height| while having its cap height |
| 117 // vertically centered. Returns the correctly-sized font list. | 115 // vertically centered. Returns the correctly-sized font list. |
| 118 // | 116 // |
| 119 // The expected layout: | 117 // The expected layout: |
| 120 // +--------+-----------------------------------------------+------------+ | 118 // +--------+-----------------------------------------------+------------+ |
| 121 // | | y offset | space | | 119 // | | y offset | space | |
| 122 // | +--------+-------------------+------------------+ above | | 120 // | +--------+-------------------+------------------+ above | |
| 123 // | | | | internal leading | cap height | | 121 // | | | | internal leading | cap height | |
| (...skipping 27 matching lines...) Expand all Loading... |
| 151 font_list.GetCapHeight() : font_list.GetHeight()); | 149 font_list.GetCapHeight() : font_list.GetHeight()); |
| 152 const int y_offset = space / 2 - internal_leading; | 150 const int y_offset = space / 2 - internal_leading; |
| 153 const int space_at_bottom = height - (y_offset + font_list.GetHeight()); | 151 const int space_at_bottom = height - (y_offset + font_list.GetHeight()); |
| 154 if ((y_offset >= 0) && (space_at_bottom >= 0)) | 152 if ((y_offset >= 0) && (space_at_bottom >= 0)) |
| 155 break; | 153 break; |
| 156 font_list = font_list.DeriveWithSizeDelta(-1); | 154 font_list = font_list.DeriveWithSizeDelta(-1); |
| 157 } | 155 } |
| 158 return font_list; | 156 return font_list; |
| 159 } | 157 } |
| 160 | 158 |
| 159 int GetEditLeadingInternalSpace() { |
| 160 // The textfield has 1 px of whitespace before the text in the RTL case only. |
| 161 return base::i18n::IsRTL() ? 1 : 0; |
| 162 } |
| 163 |
| 161 // Functor for moving BookmarkManagerPrivate page actions to the right via | 164 // Functor for moving BookmarkManagerPrivate page actions to the right via |
| 162 // stable_partition. | 165 // stable_partition. |
| 163 class IsPageActionViewRightAligned { | 166 class IsPageActionViewRightAligned { |
| 164 public: | 167 public: |
| 165 explicit IsPageActionViewRightAligned(ExtensionService* extension_service) | 168 explicit IsPageActionViewRightAligned(ExtensionService* extension_service) |
| 166 : extension_service_(extension_service) {} | 169 : extension_service_(extension_service) {} |
| 167 | 170 |
| 168 bool operator()(PageActionWithBadgeView* page_action_view) { | 171 bool operator()(PageActionWithBadgeView* page_action_view) { |
| 169 return extensions::PermissionsData::HasAPIPermission( | 172 return extensions::PermissionsData::HasAPIPermission( |
| 170 extension_service_->GetExtensionById( | 173 extension_service_->GetExtensionById( |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 if (is_popup_mode_) { | 694 if (is_popup_mode_) { |
| 692 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 695 state->AddStateFlag(ui::AX_STATE_READ_ONLY); |
| 693 } else { | 696 } else { |
| 694 state->set_value_callback = | 697 state->set_value_callback = |
| 695 base::Bind(&LocationBarView::AccessibilitySetValue, | 698 base::Bind(&LocationBarView::AccessibilitySetValue, |
| 696 weak_ptr_factory_.GetWeakPtr()); | 699 weak_ptr_factory_.GetWeakPtr()); |
| 697 } | 700 } |
| 698 } | 701 } |
| 699 | 702 |
| 700 gfx::Size LocationBarView::GetPreferredSize() { | 703 gfx::Size LocationBarView::GetPreferredSize() { |
| 701 gfx::Size background_min_size(border_painter_->GetMinimumSize()); | 704 // Compute minimum height. |
| 705 gfx::Size min_size(border_painter_->GetMinimumSize()); |
| 702 if (!IsInitialized()) | 706 if (!IsInitialized()) |
| 703 return background_min_size; | 707 return min_size; |
| 708 gfx::Size search_button_min_size(search_button_->GetMinimumSize()); |
| 709 min_size.SetToMax(search_button_min_size); |
| 704 | 710 |
| 705 gfx::Size origin_chip_view_min_size(origin_chip_view_->GetMinimumSize()); | 711 // Compute width of omnibox-leading content. |
| 706 gfx::Size search_button_min_size(search_button_->GetMinimumSize()); | 712 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
| 707 gfx::Size min_size(background_min_size); | 713 int leading_width = horizontal_edge_thickness; |
| 708 min_size.SetToMax(search_button_min_size); | 714 // TODO(pkasting): Make the origin chip min width sane, and make the chip |
| 709 min_size.set_width(origin_chip_view_min_size.width() + | 715 // handle being shrunken down more gracefully; then uncomment this. |
| 710 background_min_size.width() + | 716 /*if (GetToolbarModel()->ShouldShowOriginChip()) |
| 711 search_button_min_size.width()); | 717 leading_width += origin_chip_view_->GetMinimumSize().width();*/ |
| 718 if (ShouldShowKeywordBubble()) { |
| 719 // The selected keyword view can collapse completely. |
| 720 } else if (ShouldShowEVBubble()) { |
| 721 leading_width += kBubblePadding + |
| 722 ev_bubble_view_->GetMinimumSizeForLabelText( |
| 723 GetToolbarModel()->GetEVCertName()).width(); |
| 724 } else if (!origin_chip_view_->visible()) { |
| 725 leading_width += |
| 726 kItemPadding + location_icon_view_->GetMinimumSize().width(); |
| 727 } |
| 728 leading_width += kItemPadding - GetEditLeadingInternalSpace(); |
| 729 |
| 730 // Compute width of omnibox-trailing content. |
| 731 int trailing_width = search_button_->visible() ? |
| 732 (search_button_->GetMinimumSize().width() + kSearchButtonInset) : |
| 733 horizontal_edge_thickness; |
| 734 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 735 IncrementalMinimumWidth(translate_icon_view_) + |
| 736 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| 737 IncrementalMinimumWidth(manage_passwords_icon_view_) + |
| 738 IncrementalMinimumWidth(zoom_view_) + |
| 739 IncrementalMinimumWidth(generated_credit_card_view_) + |
| 740 IncrementalMinimumWidth(mic_search_view_) + kItemPadding; |
| 741 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 742 i != page_action_views_.end(); ++i) |
| 743 trailing_width += IncrementalMinimumWidth((*i)); |
| 744 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 745 i != content_setting_views_.end(); ++i) |
| 746 trailing_width += IncrementalMinimumWidth((*i)); |
| 747 |
| 748 min_size.set_width( |
| 749 leading_width + omnibox_view_->GetMinimumSize().width() + trailing_width); |
| 712 return min_size; | 750 return min_size; |
| 713 } | 751 } |
| 714 | 752 |
| 715 void LocationBarView::Layout() { | 753 void LocationBarView::Layout() { |
| 716 if (!IsInitialized()) | 754 if (!IsInitialized()) |
| 717 return; | 755 return; |
| 718 | 756 |
| 719 animated_host_label_->SetVisible(false); | 757 animated_host_label_->SetVisible(false); |
| 720 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); | 758 origin_chip_view_->SetVisible(GetToolbarModel()->ShouldShowOriginChip()); |
| 721 selected_keyword_view_->SetVisible(false); | 759 selected_keyword_view_->SetVisible(false); |
| 722 location_icon_view_->SetVisible(false); | 760 location_icon_view_->SetVisible(false); |
| 723 ev_bubble_view_->SetVisible(false); | 761 ev_bubble_view_->SetVisible(false); |
| 724 keyword_hint_view_->SetVisible(false); | 762 keyword_hint_view_->SetVisible(false); |
| 725 | 763 |
| 726 // The textfield has 1 px of whitespace before the text in the RTL case only. | |
| 727 const int kEditLeadingInternalSpace = base::i18n::IsRTL() ? 1 : 0; | |
| 728 LocationBarLayout leading_decorations( | 764 LocationBarLayout leading_decorations( |
| 729 LocationBarLayout::LEFT_EDGE, kItemPadding - kEditLeadingInternalSpace); | 765 LocationBarLayout::LEFT_EDGE, |
| 766 kItemPadding - GetEditLeadingInternalSpace()); |
| 730 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, | 767 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, |
| 731 kItemPadding); | 768 kItemPadding); |
| 732 | 769 |
| 733 // Show and position the animated host label used in the show and hide URL | 770 // Show and position the animated host label used in the show and hide URL |
| 734 // animations. | 771 // animations. |
| 735 if (show_url_animation_->is_animating() || | 772 if (show_url_animation_->is_animating() || |
| 736 hide_url_animation_->is_animating()) { | 773 hide_url_animation_->is_animating()) { |
| 737 WebContents* web_contents = GetWebContents(); | 774 WebContents* web_contents = GetWebContents(); |
| 738 const GURL url = web_contents ? web_contents->GetURL() : GURL(); | 775 const GURL url = web_contents ? web_contents->GetURL() : GURL(); |
| 739 const base::string16 host = | 776 const base::string16 host = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 768 animated_host_label_->SetBounds( | 805 animated_host_label_->SetBounds( |
| 769 host_label_x, 0, | 806 host_label_x, 0, |
| 770 animated_host_label_->GetPreferredSize().width(), height()); | 807 animated_host_label_->GetPreferredSize().width(), height()); |
| 771 animated_host_label_->SetVisible(true); | 808 animated_host_label_->SetVisible(true); |
| 772 } | 809 } |
| 773 | 810 |
| 774 const int origin_chip_width = origin_chip_view_->visible() ? | 811 const int origin_chip_width = origin_chip_view_->visible() ? |
| 775 origin_chip_view_->GetPreferredSize().width() : 0; | 812 origin_chip_view_->GetPreferredSize().width() : 0; |
| 776 origin_chip_view_->SetBounds(0, 0, origin_chip_width, height()); | 813 origin_chip_view_->SetBounds(0, 0, origin_chip_width, height()); |
| 777 | 814 |
| 815 const int bubble_location_y = vertical_edge_thickness() + kBubblePadding; |
| 778 const base::string16 keyword(omnibox_view_->model()->keyword()); | 816 const base::string16 keyword(omnibox_view_->model()->keyword()); |
| 779 const bool is_keyword_hint(omnibox_view_->model()->is_keyword_hint()); | |
| 780 const int bubble_location_y = vertical_edge_thickness() + kBubblePadding; | |
| 781 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want | 817 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want |
| 782 // to position our child views in this case, because other things may be | 818 // to position our child views in this case, because other things may be |
| 783 // positioned relative to them (e.g. the "bookmark added" bubble if the user | 819 // positioned relative to them (e.g. the "bookmark added" bubble if the user |
| 784 // hits ctrl-d). | 820 // hits ctrl-d). |
| 785 const int location_height = GetInternalHeight(false); | 821 const int location_height = GetInternalHeight(false); |
| 786 const int bubble_height = std::max(location_height - (kBubblePadding * 2), 0); | 822 const int bubble_height = std::max(location_height - (kBubblePadding * 2), 0); |
| 787 if (!keyword.empty() && !is_keyword_hint) { | 823 if (ShouldShowKeywordBubble()) { |
| 788 leading_decorations.AddDecoration(bubble_location_y, bubble_height, true, 0, | 824 leading_decorations.AddDecoration(bubble_location_y, bubble_height, true, 0, |
| 789 kBubblePadding, kItemPadding, | 825 kBubblePadding, kItemPadding, |
| 790 selected_keyword_view_); | 826 selected_keyword_view_); |
| 791 if (selected_keyword_view_->keyword() != keyword) { | 827 if (selected_keyword_view_->keyword() != keyword) { |
| 792 selected_keyword_view_->SetKeyword(keyword); | 828 selected_keyword_view_->SetKeyword(keyword); |
| 793 const TemplateURL* template_url = | 829 const TemplateURL* template_url = |
| 794 TemplateURLServiceFactory::GetForProfile(profile())-> | 830 TemplateURLServiceFactory::GetForProfile(profile())-> |
| 795 GetTemplateURLForKeyword(keyword); | 831 GetTemplateURLForKeyword(keyword); |
| 796 if (template_url && | 832 if (template_url && |
| 797 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 833 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 798 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> | 834 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> |
| 799 GetOmniboxIcon(template_url->GetExtensionId()); | 835 GetOmniboxIcon(template_url->GetExtensionId()); |
| 800 selected_keyword_view_->SetImage(image.AsImageSkia()); | 836 selected_keyword_view_->SetImage(image.AsImageSkia()); |
| 801 selected_keyword_view_->set_is_extension_icon(true); | 837 selected_keyword_view_->set_is_extension_icon(true); |
| 802 } else { | 838 } else { |
| 803 selected_keyword_view_->SetImage( | 839 selected_keyword_view_->SetImage( |
| 804 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); | 840 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); |
| 805 selected_keyword_view_->set_is_extension_icon(false); | 841 selected_keyword_view_->set_is_extension_icon(false); |
| 806 } | 842 } |
| 807 } | 843 } |
| 808 } else if (!toolbar_origin_chip_view_ && | 844 } else if (ShouldShowEVBubble()) { |
| 809 !chrome::ShouldDisplayOriginChipV2() && | |
| 810 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { | |
| 811 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); | 845 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); |
| 812 // The largest fraction of the omnibox that can be taken by the EV bubble. | 846 // The largest fraction of the omnibox that can be taken by the EV bubble. |
| 813 const double kMaxBubbleFraction = 0.5; | 847 const double kMaxBubbleFraction = 0.5; |
| 814 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, | 848 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, |
| 815 kMaxBubbleFraction, kBubblePadding, | 849 kMaxBubbleFraction, kBubblePadding, |
| 816 kItemPadding, ev_bubble_view_); | 850 kItemPadding, ev_bubble_view_); |
| 817 } else if (!origin_chip_view_->visible()) { | 851 } else if (!origin_chip_view_->visible()) { |
| 818 leading_decorations.AddDecoration( | 852 leading_decorations.AddDecoration( |
| 819 vertical_edge_thickness(), location_height, | 853 vertical_edge_thickness(), location_height, |
| 820 location_icon_view_); | 854 location_icon_view_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 895 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
| 862 location_height, | 896 location_height, |
| 863 generated_credit_card_view_); | 897 generated_credit_card_view_); |
| 864 } | 898 } |
| 865 if (mic_search_view_->visible()) { | 899 if (mic_search_view_->visible()) { |
| 866 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 900 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
| 867 location_height, mic_search_view_); | 901 location_height, mic_search_view_); |
| 868 } | 902 } |
| 869 // Because IMEs may eat the tab key, we don't show "press tab to search" while | 903 // Because IMEs may eat the tab key, we don't show "press tab to search" while |
| 870 // IME composition is in progress. | 904 // IME composition is in progress. |
| 871 if (!keyword.empty() && is_keyword_hint && !omnibox_view_->IsImeComposing()) { | 905 if (!keyword.empty() && omnibox_view_->model()->is_keyword_hint() && |
| 906 !omnibox_view_->IsImeComposing()) { |
| 872 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 907 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
| 873 location_height, true, 0, kItemPadding, | 908 location_height, true, 0, kItemPadding, |
| 874 kItemPadding, keyword_hint_view_); | 909 kItemPadding, keyword_hint_view_); |
| 875 if (keyword_hint_view_->keyword() != keyword) | 910 if (keyword_hint_view_->keyword() != keyword) |
| 876 keyword_hint_view_->SetKeyword(keyword); | 911 keyword_hint_view_->SetKeyword(keyword); |
| 877 } | 912 } |
| 878 | 913 |
| 879 // Perform layout. | 914 // Perform layout. |
| 880 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); | 915 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
| 881 int full_width = width() - horizontal_edge_thickness - origin_chip_width; | 916 int full_width = width() - horizontal_edge_thickness - origin_chip_width; |
| 882 | 917 |
| 883 // The search button images are made to look as if they overlay the normal | |
| 884 // edge images, but to align things, the search button needs to be inset | |
| 885 // horizontally by 1 px. | |
| 886 const int kSearchButtonInset = 1; | |
| 887 const gfx::Size search_button_size(search_button_->GetPreferredSize()); | 918 const gfx::Size search_button_size(search_button_->GetPreferredSize()); |
| 888 const int search_button_reserved_width = | 919 const int search_button_reserved_width = |
| 889 search_button_size.width() + kSearchButtonInset; | 920 search_button_size.width() + kSearchButtonInset; |
| 890 full_width -= search_button_->visible() ? | 921 full_width -= search_button_->visible() ? |
| 891 search_button_reserved_width : horizontal_edge_thickness; | 922 search_button_reserved_width : horizontal_edge_thickness; |
| 892 int entry_width = full_width; | 923 int entry_width = full_width; |
| 893 leading_decorations.LayoutPass1(&entry_width); | 924 leading_decorations.LayoutPass1(&entry_width); |
| 894 trailing_decorations.LayoutPass1(&entry_width); | 925 trailing_decorations.LayoutPass1(&entry_width); |
| 895 leading_decorations.LayoutPass2(&entry_width); | 926 leading_decorations.LayoutPass2(&entry_width); |
| 896 trailing_decorations.LayoutPass2(&entry_width); | 927 trailing_decorations.LayoutPass2(&entry_width); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 return delegate_->GetToolbarModel(); | 1067 return delegate_->GetToolbarModel(); |
| 1037 } | 1068 } |
| 1038 | 1069 |
| 1039 WebContents* LocationBarView::GetWebContents() { | 1070 WebContents* LocationBarView::GetWebContents() { |
| 1040 return delegate_->GetWebContents(); | 1071 return delegate_->GetWebContents(); |
| 1041 } | 1072 } |
| 1042 | 1073 |
| 1043 //////////////////////////////////////////////////////////////////////////////// | 1074 //////////////////////////////////////////////////////////////////////////////// |
| 1044 // LocationBarView, private: | 1075 // LocationBarView, private: |
| 1045 | 1076 |
| 1077 // static |
| 1078 int LocationBarView::IncrementalMinimumWidth(views::View* view) { |
| 1079 return view->visible() ? (kItemPadding + view->GetMinimumSize().width()) : 0; |
| 1080 } |
| 1081 |
| 1046 int LocationBarView::GetHorizontalEdgeThickness() const { | 1082 int LocationBarView::GetHorizontalEdgeThickness() const { |
| 1047 // In maximized popup mode, there isn't any edge. | 1083 // In maximized popup mode, there isn't any edge. |
| 1048 return (is_popup_mode_ && browser_ && browser_->window() && | 1084 return (is_popup_mode_ && browser_ && browser_->window() && |
| 1049 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); | 1085 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); |
| 1050 } | 1086 } |
| 1051 | 1087 |
| 1052 bool LocationBarView::RefreshContentSettingViews() { | 1088 bool LocationBarView::RefreshContentSettingViews() { |
| 1053 bool visibility_changed = false; | 1089 bool visibility_changed = false; |
| 1054 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 1090 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 1055 i != content_setting_views_.end(); ++i) { | 1091 i != content_setting_views_.end(); ++i) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 WebContents* web_contents = GetWebContents(); | 1221 WebContents* web_contents = GetWebContents(); |
| 1186 if (!web_contents) | 1222 if (!web_contents) |
| 1187 return false; | 1223 return false; |
| 1188 const bool was_visible = manage_passwords_icon_view_->visible(); | 1224 const bool was_visible = manage_passwords_icon_view_->visible(); |
| 1189 ManagePasswordsUIController::FromWebContents( | 1225 ManagePasswordsUIController::FromWebContents( |
| 1190 web_contents)->UpdateIconAndBubbleState(manage_passwords_icon_view_); | 1226 web_contents)->UpdateIconAndBubbleState(manage_passwords_icon_view_); |
| 1191 return was_visible != manage_passwords_icon_view_->visible(); | 1227 return was_visible != manage_passwords_icon_view_->visible(); |
| 1192 } | 1228 } |
| 1193 | 1229 |
| 1194 void LocationBarView::ShowFirstRunBubbleInternal() { | 1230 void LocationBarView::ShowFirstRunBubbleInternal() { |
| 1231 // First run bubble doesn't make sense for Chrome OS. |
| 1195 #if !defined(OS_CHROMEOS) | 1232 #if !defined(OS_CHROMEOS) |
| 1196 // First run bubble doesn't make sense for Chrome OS. | 1233 WebContents* web_contents = delegate_->GetWebContents(); |
| 1197 Browser* browser = GetBrowserFromDelegate(delegate_); | 1234 if (!web_contents) |
| 1198 if (!browser) | 1235 return; |
| 1199 return; // Possible when browser is shutting down. | 1236 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 1200 | 1237 if (browser) |
| 1201 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); | 1238 FirstRunBubble::ShowBubble(browser, GetLocationBarAnchor()); |
| 1202 #endif | 1239 #endif |
| 1203 } | 1240 } |
| 1204 | 1241 |
| 1205 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { | 1242 void LocationBarView::AccessibilitySetValue(const base::string16& new_value) { |
| 1206 omnibox_view_->SetUserText(new_value, new_value, true); | 1243 omnibox_view_->SetUserText(new_value, new_value, true); |
| 1207 } | 1244 } |
| 1208 | 1245 |
| 1209 bool LocationBarView::HasValidSuggestText() const { | 1246 bool LocationBarView::HasValidSuggestText() const { |
| 1210 return suggested_text_view_->visible() && | 1247 return suggested_text_view_->visible() && |
| 1211 !suggested_text_view_->size().IsEmpty(); | 1248 !suggested_text_view_->size().IsEmpty(); |
| 1212 } | 1249 } |
| 1213 | 1250 |
| 1251 bool LocationBarView::ShouldShowKeywordBubble() const { |
| 1252 return !omnibox_view_->model()->keyword().empty() && |
| 1253 !omnibox_view_->model()->is_keyword_hint(); |
| 1254 } |
| 1255 |
| 1256 bool LocationBarView::ShouldShowEVBubble() const { |
| 1257 return !toolbar_origin_chip_view_ && !chrome::ShouldDisplayOriginChipV2() && |
| 1258 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE); |
| 1259 } |
| 1260 |
| 1214 void LocationBarView::OnShowURLAnimationEnded() { | 1261 void LocationBarView::OnShowURLAnimationEnded() { |
| 1215 animated_host_label_->SetVisible(false); | 1262 animated_host_label_->SetVisible(false); |
| 1216 omnibox_view_->SetVisible(true); | 1263 omnibox_view_->SetVisible(true); |
| 1217 omnibox_view_->FadeIn(); | 1264 omnibox_view_->FadeIn(); |
| 1218 omnibox_view_->SetFocus(); | 1265 omnibox_view_->SetFocus(); |
| 1219 | 1266 |
| 1220 // Sometimes the selection established by OmniboxView::ShowURL() is lost at | 1267 // Sometimes the selection established by OmniboxView::ShowURL() is lost at |
| 1221 // the call to SetFocus() above. Select all again to be sure. | 1268 // the call to SetFocus() above. Select all again to be sure. |
| 1222 // TODO(jdonnelly): Figure out why the selection is sometimes lost and | 1269 // TODO(jdonnelly): Figure out why the selection is sometimes lost and |
| 1223 // implement a more principled fix. | 1270 // implement a more principled fix. |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1689 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1643 const SearchModel::State& new_state) { | 1690 const SearchModel::State& new_state) { |
| 1644 const bool visible = !GetToolbarModel()->input_in_progress() && | 1691 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1645 new_state.voice_search_supported; | 1692 new_state.voice_search_supported; |
| 1646 if (mic_search_view_->visible() != visible) { | 1693 if (mic_search_view_->visible() != visible) { |
| 1647 mic_search_view_->SetVisible(visible); | 1694 mic_search_view_->SetVisible(visible); |
| 1648 Layout(); | 1695 Layout(); |
| 1649 } | 1696 } |
| 1650 } | 1697 } |
| 1651 | 1698 |
| OLD | NEW |