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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 #include "content/public/browser/render_widget_host_view.h" | 69 #include "content/public/browser/render_widget_host_view.h" |
70 #include "content/public/browser/web_contents.h" | 70 #include "content/public/browser/web_contents.h" |
71 #include "extensions/browser/extension_system.h" | 71 #include "extensions/browser/extension_system.h" |
72 #include "extensions/common/feature_switch.h" | 72 #include "extensions/common/feature_switch.h" |
73 #include "extensions/common/permissions/permissions_data.h" | 73 #include "extensions/common/permissions/permissions_data.h" |
74 #include "grit/generated_resources.h" | 74 #include "grit/generated_resources.h" |
75 #include "grit/theme_resources.h" | 75 #include "grit/theme_resources.h" |
76 #include "ui/accessibility/ax_view_state.h" | 76 #include "ui/accessibility/ax_view_state.h" |
77 #include "ui/base/dragdrop/drag_drop_types.h" | 77 #include "ui/base/dragdrop/drag_drop_types.h" |
78 #include "ui/base/l10n/l10n_util.h" | 78 #include "ui/base/l10n/l10n_util.h" |
79 #include "ui/base/layout.h" | |
80 #include "ui/base/resource/resource_bundle.h" | 79 #include "ui/base/resource/resource_bundle.h" |
81 #include "ui/base/theme_provider.h" | 80 #include "ui/base/theme_provider.h" |
82 #include "ui/events/event.h" | 81 #include "ui/events/event.h" |
83 #include "ui/gfx/animation/slide_animation.h" | 82 #include "ui/gfx/animation/slide_animation.h" |
84 #include "ui/gfx/canvas.h" | 83 #include "ui/gfx/canvas.h" |
85 #include "ui/gfx/color_utils.h" | 84 #include "ui/gfx/color_utils.h" |
86 #include "ui/gfx/image/image.h" | 85 #include "ui/gfx/image/image.h" |
87 #include "ui/gfx/image/image_skia_operations.h" | 86 #include "ui/gfx/image/image_skia_operations.h" |
88 #include "ui/gfx/skia_util.h" | 87 #include "ui/gfx/skia_util.h" |
89 #include "ui/gfx/text_utils.h" | 88 #include "ui/gfx/text_utils.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 }; | 181 }; |
183 | 182 |
184 } // namespace | 183 } // namespace |
185 | 184 |
186 | 185 |
187 // LocationBarView ----------------------------------------------------------- | 186 // LocationBarView ----------------------------------------------------------- |
188 | 187 |
189 // static | 188 // static |
190 const int LocationBarView::kNormalEdgeThickness = 2; | 189 const int LocationBarView::kNormalEdgeThickness = 2; |
191 const int LocationBarView::kPopupEdgeThickness = 1; | 190 const int LocationBarView::kPopupEdgeThickness = 1; |
191 const int LocationBarView::kItemPadding = 3; | |
192 const int LocationBarView::kIconInternalPadding = 2; | 192 const int LocationBarView::kIconInternalPadding = 2; |
193 const int LocationBarView::kBubblePadding = 1; | 193 const int LocationBarView::kBubblePadding = 1; |
194 const char LocationBarView::kViewClassName[] = "LocationBarView"; | 194 const char LocationBarView::kViewClassName[] = "LocationBarView"; |
195 | 195 |
196 LocationBarView::LocationBarView(Browser* browser, | 196 LocationBarView::LocationBarView(Browser* browser, |
197 Profile* profile, | 197 Profile* profile, |
198 CommandUpdater* command_updater, | 198 CommandUpdater* command_updater, |
199 Delegate* delegate, | 199 Delegate* delegate, |
200 bool is_popup_mode) | 200 bool is_popup_mode) |
201 : LocationBar(profile), | 201 : LocationBar(profile), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 LocationBarView::~LocationBarView() { | 237 LocationBarView::~LocationBarView() { |
238 if (template_url_service_) | 238 if (template_url_service_) |
239 template_url_service_->RemoveObserver(this); | 239 template_url_service_->RemoveObserver(this); |
240 if (browser_) | 240 if (browser_) |
241 browser_->search_model()->RemoveObserver(this); | 241 browser_->search_model()->RemoveObserver(this); |
242 } | 242 } |
243 | 243 |
244 //////////////////////////////////////////////////////////////////////////////// | 244 //////////////////////////////////////////////////////////////////////////////// |
245 // LocationBarView, public: | 245 // LocationBarView, public: |
246 | 246 |
247 // static | |
248 void LocationBarView::InitTouchableLocationBarChildView(views::View* view) { | |
249 int horizontal_padding = GetBuiltInHorizontalPaddingForChildViews(); | |
250 if (horizontal_padding != 0) { | |
251 view->SetBorder(views::Border::CreateEmptyBorder( | |
252 3, horizontal_padding, 3, horizontal_padding)); | |
253 } | |
254 } | |
255 | |
256 void LocationBarView::Init() { | 247 void LocationBarView::Init() { |
257 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're | 248 // We need to be in a Widget, otherwise GetNativeTheme() may change and we're |
258 // not prepared for that. | 249 // not prepared for that. |
259 DCHECK(GetWidget()); | 250 DCHECK(GetWidget()); |
260 | 251 |
261 const int kOmniboxPopupBorderImages[] = | 252 const int kOmniboxPopupBorderImages[] = |
262 IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER_AND_SHADOW); | 253 IMAGE_GRID(IDR_OMNIBOX_POPUP_BORDER_AND_SHADOW); |
263 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_TEXTFIELD); | 254 const int kOmniboxBorderImages[] = IMAGE_GRID(IDR_TEXTFIELD); |
264 border_painter_.reset(views::Painter::CreateImageGridPainter( | 255 border_painter_.reset(views::Painter::CreateImageGridPainter( |
265 is_popup_mode_ ? kOmniboxPopupBorderImages : kOmniboxBorderImages)); | 256 is_popup_mode_ ? kOmniboxPopupBorderImages : kOmniboxBorderImages)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 mic_search_view_->SetAccessibilityFocusable(true); | 348 mic_search_view_->SetAccessibilityFocusable(true); |
358 mic_search_view_->SetTooltipText( | 349 mic_search_view_->SetTooltipText( |
359 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); | 350 l10n_util::GetStringUTF16(IDS_TOOLTIP_MIC_SEARCH)); |
360 mic_search_view_->SetImage( | 351 mic_search_view_->SetImage( |
361 views::Button::STATE_NORMAL, | 352 views::Button::STATE_NORMAL, |
362 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 353 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
363 IDR_OMNIBOX_MIC_SEARCH)); | 354 IDR_OMNIBOX_MIC_SEARCH)); |
364 mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 355 mic_search_view_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
365 views::ImageButton::ALIGN_MIDDLE); | 356 views::ImageButton::ALIGN_MIDDLE); |
366 mic_search_view_->SetVisible(false); | 357 mic_search_view_->SetVisible(false); |
367 InitTouchableLocationBarChildView(mic_search_view_); | |
368 AddChildView(mic_search_view_); | 358 AddChildView(mic_search_view_); |
369 | 359 |
370 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 360 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
371 ContentSettingImageView* content_blocked_view = | 361 ContentSettingImageView* content_blocked_view = |
372 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, | 362 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, |
373 bubble_font_list, text_color, | 363 bubble_font_list, text_color, |
374 background_color); | 364 background_color); |
375 content_setting_views_.push_back(content_blocked_view); | 365 content_setting_views_.push_back(content_blocked_view); |
376 content_blocked_view->SetVisible(false); | 366 content_blocked_view->SetVisible(false); |
377 AddChildView(content_blocked_view); | 367 AddChildView(content_blocked_view); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 parent()->height() - views::NonClientFrameView::kClientEdgeThickness); | 649 parent()->height() - views::NonClientFrameView::kClientEdgeThickness); |
660 views::View::ConvertPointToScreen(parent(), top_left_screen_coord); | 650 views::View::ConvertPointToScreen(parent(), top_left_screen_coord); |
661 *popup_width = parent()->width(); | 651 *popup_width = parent()->width(); |
662 | 652 |
663 gfx::Rect location_bar_bounds(bounds()); | 653 gfx::Rect location_bar_bounds(bounds()); |
664 location_bar_bounds.Inset(kNormalEdgeThickness, 0); | 654 location_bar_bounds.Inset(kNormalEdgeThickness, 0); |
665 *left_margin = location_bar_bounds.x(); | 655 *left_margin = location_bar_bounds.x(); |
666 *right_margin = *popup_width - location_bar_bounds.right(); | 656 *right_margin = *popup_width - location_bar_bounds.right(); |
667 } | 657 } |
668 | 658 |
669 // static | |
670 int LocationBarView::GetItemPadding() { | |
671 const int kTouchItemPadding = 8; | |
672 if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) | |
673 return kTouchItemPadding; | |
674 | |
675 const int kDesktopItemPadding = 3; | |
676 return kDesktopItemPadding; | |
677 } | |
678 | |
679 //////////////////////////////////////////////////////////////////////////////// | 659 //////////////////////////////////////////////////////////////////////////////// |
680 // LocationBarView, public LocationBar implementation: | 660 // LocationBarView, public LocationBar implementation: |
681 | 661 |
682 void LocationBarView::FocusLocation(bool select_all) { | 662 void LocationBarView::FocusLocation(bool select_all) { |
683 omnibox_view_->SetFocus(); | 663 omnibox_view_->SetFocus(); |
684 if (select_all) | 664 if (select_all) |
685 omnibox_view_->SelectAll(true); | 665 omnibox_view_->SelectAll(true); |
686 } | 666 } |
687 | 667 |
688 void LocationBarView::Revert() { | 668 void LocationBarView::Revert() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 if (!IsInitialized()) | 722 if (!IsInitialized()) |
743 return; | 723 return; |
744 | 724 |
745 animated_host_label_->SetVisible(false); | 725 animated_host_label_->SetVisible(false); |
746 origin_chip_view_->SetVisible(origin_chip_view_->ShouldShow()); | 726 origin_chip_view_->SetVisible(origin_chip_view_->ShouldShow()); |
747 selected_keyword_view_->SetVisible(false); | 727 selected_keyword_view_->SetVisible(false); |
748 location_icon_view_->SetVisible(false); | 728 location_icon_view_->SetVisible(false); |
749 ev_bubble_view_->SetVisible(false); | 729 ev_bubble_view_->SetVisible(false); |
750 keyword_hint_view_->SetVisible(false); | 730 keyword_hint_view_->SetVisible(false); |
751 | 731 |
752 const int item_padding = GetItemPadding(); | |
753 | |
754 // The textfield has 1 px of whitespace before the text in the RTL case only. | 732 // The textfield has 1 px of whitespace before the text in the RTL case only. |
755 const int kEditLeadingInternalSpace = base::i18n::IsRTL() ? 1 : 0; | 733 const int kEditLeadingInternalSpace = base::i18n::IsRTL() ? 1 : 0; |
756 LocationBarLayout leading_decorations( | 734 LocationBarLayout leading_decorations( |
757 LocationBarLayout::LEFT_EDGE, item_padding - kEditLeadingInternalSpace); | 735 LocationBarLayout::LEFT_EDGE, kItemPadding - kEditLeadingInternalSpace); |
758 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, | 736 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, |
759 item_padding); | 737 kItemPadding); |
760 | 738 |
761 // Show and position the animated host label used in the show and hide URL | 739 // Show and position the animated host label used in the show and hide URL |
762 // animations. | 740 // animations. |
763 if (show_url_animation_->is_animating() || | 741 if (show_url_animation_->is_animating() || |
764 hide_url_animation_->is_animating()) { | 742 hide_url_animation_->is_animating()) { |
765 WebContents* web_contents = GetWebContents(); | 743 WebContents* web_contents = GetWebContents(); |
766 const GURL url = web_contents ? web_contents->GetURL() : GURL(); | 744 const GURL url = web_contents ? web_contents->GetURL() : GURL(); |
767 const base::string16 host = | 745 const base::string16 host = |
768 OriginChip::LabelFromURLForProfile(url, profile()); | 746 OriginChip::LabelFromURLForProfile(url, profile()); |
769 animated_host_label_->SetText(host); | 747 animated_host_label_->SetText(host); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 const bool is_keyword_hint(omnibox_view_->model()->is_keyword_hint()); | 785 const bool is_keyword_hint(omnibox_view_->model()->is_keyword_hint()); |
808 const int bubble_location_y = vertical_edge_thickness() + kBubblePadding; | 786 const int bubble_location_y = vertical_edge_thickness() + kBubblePadding; |
809 // 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 |
810 // 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 |
811 // 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 |
812 // hits ctrl-d). | 790 // hits ctrl-d). |
813 const int location_height = GetInternalHeight(false); | 791 const int location_height = GetInternalHeight(false); |
814 const int bubble_height = std::max(location_height - (kBubblePadding * 2), 0); | 792 const int bubble_height = std::max(location_height - (kBubblePadding * 2), 0); |
815 if (!keyword.empty() && !is_keyword_hint) { | 793 if (!keyword.empty() && !is_keyword_hint) { |
816 leading_decorations.AddDecoration(bubble_location_y, bubble_height, true, 0, | 794 leading_decorations.AddDecoration(bubble_location_y, bubble_height, true, 0, |
817 kBubblePadding, item_padding, 0, | 795 kBubblePadding, kItemPadding, 0, |
818 selected_keyword_view_); | 796 selected_keyword_view_); |
819 if (selected_keyword_view_->keyword() != keyword) { | 797 if (selected_keyword_view_->keyword() != keyword) { |
820 selected_keyword_view_->SetKeyword(keyword); | 798 selected_keyword_view_->SetKeyword(keyword); |
821 const TemplateURL* template_url = | 799 const TemplateURL* template_url = |
822 TemplateURLServiceFactory::GetForProfile(profile())-> | 800 TemplateURLServiceFactory::GetForProfile(profile())-> |
823 GetTemplateURLForKeyword(keyword); | 801 GetTemplateURLForKeyword(keyword); |
824 if (template_url && | 802 if (template_url && |
825 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 803 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
826 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> | 804 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> |
827 GetOmniboxIcon(template_url->GetExtensionId()); | 805 GetOmniboxIcon(template_url->GetExtensionId()); |
828 selected_keyword_view_->SetImage(image.AsImageSkia()); | 806 selected_keyword_view_->SetImage(image.AsImageSkia()); |
829 selected_keyword_view_->set_is_extension_icon(true); | 807 selected_keyword_view_->set_is_extension_icon(true); |
830 } else { | 808 } else { |
831 selected_keyword_view_->SetImage( | 809 selected_keyword_view_->SetImage( |
832 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); | 810 *(GetThemeProvider()->GetImageSkiaNamed(IDR_OMNIBOX_SEARCH))); |
833 selected_keyword_view_->set_is_extension_icon(false); | 811 selected_keyword_view_->set_is_extension_icon(false); |
834 } | 812 } |
835 } | 813 } |
836 } else if (!toolbar_origin_chip_view_ && | 814 } else if (!toolbar_origin_chip_view_ && |
837 !chrome::ShouldDisplayOriginChipV2() && | 815 !chrome::ShouldDisplayOriginChipV2() && |
838 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { | 816 (GetToolbarModel()->GetSecurityLevel(false) == ToolbarModel::EV_SECURE)) { |
839 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); | 817 ev_bubble_view_->SetLabel(GetToolbarModel()->GetEVCertName()); |
840 // 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. |
841 const double kMaxBubbleFraction = 0.5; | 819 const double kMaxBubbleFraction = 0.5; |
842 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, | 820 leading_decorations.AddDecoration(bubble_location_y, bubble_height, false, |
843 kMaxBubbleFraction, kBubblePadding, | 821 kMaxBubbleFraction, kBubblePadding, |
844 item_padding, 0, ev_bubble_view_); | 822 kItemPadding, 0, ev_bubble_view_); |
845 } else if (!origin_chip_view_->visible()) { | 823 } else if (!origin_chip_view_->visible()) { |
846 leading_decorations.AddDecoration( | 824 leading_decorations.AddDecoration( |
847 vertical_edge_thickness(), location_height, | 825 vertical_edge_thickness(), location_height, |
848 GetBuiltInHorizontalPaddingForChildViews(), | 826 0, |
oshima
2014/04/25 14:16:26
I made separate CL to remove this parameter. Let m
| |
849 location_icon_view_); | 827 location_icon_view_); |
850 } | 828 } |
851 | 829 |
852 if (star_view_->visible()) { | 830 if (star_view_->visible()) { |
853 trailing_decorations.AddDecoration( | 831 trailing_decorations.AddDecoration( |
854 vertical_edge_thickness(), location_height, | 832 vertical_edge_thickness(), location_height, |
855 GetBuiltInHorizontalPaddingForChildViews(), star_view_); | 833 0, star_view_); |
856 } | 834 } |
857 if (translate_icon_view_->visible()) { | 835 if (translate_icon_view_->visible()) { |
858 trailing_decorations.AddDecoration( | 836 trailing_decorations.AddDecoration( |
859 vertical_edge_thickness(), location_height, | 837 vertical_edge_thickness(), location_height, |
860 GetBuiltInHorizontalPaddingForChildViews(), | 838 0, |
861 translate_icon_view_); | 839 translate_icon_view_); |
862 } | 840 } |
863 if (open_pdf_in_reader_view_->visible()) { | 841 if (open_pdf_in_reader_view_->visible()) { |
864 trailing_decorations.AddDecoration( | 842 trailing_decorations.AddDecoration( |
865 vertical_edge_thickness(), location_height, | 843 vertical_edge_thickness(), location_height, |
866 GetBuiltInHorizontalPaddingForChildViews(), | 844 0, |
867 open_pdf_in_reader_view_); | 845 open_pdf_in_reader_view_); |
868 } | 846 } |
869 if (manage_passwords_icon_view_->visible()) { | 847 if (manage_passwords_icon_view_->visible()) { |
870 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 848 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
871 location_height, 0, | 849 location_height, 0, |
872 manage_passwords_icon_view_); | 850 manage_passwords_icon_view_); |
873 } | 851 } |
874 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 852 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
875 i != page_action_views_.end(); ++i) { | 853 i != page_action_views_.end(); ++i) { |
876 if ((*i)->visible()) { | 854 if ((*i)->visible()) { |
877 trailing_decorations.AddDecoration( | 855 trailing_decorations.AddDecoration( |
878 vertical_edge_thickness(), location_height, | 856 vertical_edge_thickness(), location_height, |
879 GetBuiltInHorizontalPaddingForChildViews(), (*i)); | 857 0, (*i)); |
880 } | 858 } |
881 } | 859 } |
882 if (zoom_view_->visible()) { | 860 if (zoom_view_->visible()) { |
883 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 861 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
884 location_height, 0, zoom_view_); | 862 location_height, 0, zoom_view_); |
885 } | 863 } |
886 for (ContentSettingViews::const_reverse_iterator i( | 864 for (ContentSettingViews::const_reverse_iterator i( |
887 content_setting_views_.rbegin()); i != content_setting_views_.rend(); | 865 content_setting_views_.rbegin()); i != content_setting_views_.rend(); |
888 ++i) { | 866 ++i) { |
889 if ((*i)->visible()) { | 867 if ((*i)->visible()) { |
890 trailing_decorations.AddDecoration( | 868 trailing_decorations.AddDecoration( |
891 bubble_location_y, bubble_height, false, 0, item_padding, | 869 bubble_location_y, bubble_height, false, 0, kItemPadding, |
892 item_padding, GetBuiltInHorizontalPaddingForChildViews(), (*i)); | 870 kItemPadding, 0, (*i)); |
893 } | 871 } |
894 } | 872 } |
895 if (generated_credit_card_view_->visible()) { | 873 if (generated_credit_card_view_->visible()) { |
896 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 874 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
897 location_height, 0, | 875 location_height, 0, |
898 generated_credit_card_view_); | 876 generated_credit_card_view_); |
899 } | 877 } |
900 if (mic_search_view_->visible()) { | 878 if (mic_search_view_->visible()) { |
901 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 879 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
902 location_height, 0, mic_search_view_); | 880 location_height, 0, mic_search_view_); |
903 } | 881 } |
904 // Because IMEs may eat the tab key, we don't show "press tab to search" while | 882 // Because IMEs may eat the tab key, we don't show "press tab to search" while |
905 // IME composition is in progress. | 883 // IME composition is in progress. |
906 if (!keyword.empty() && is_keyword_hint && !omnibox_view_->IsImeComposing()) { | 884 if (!keyword.empty() && is_keyword_hint && !omnibox_view_->IsImeComposing()) { |
907 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 885 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
908 location_height, true, 0, item_padding, | 886 location_height, true, 0, kItemPadding, |
909 item_padding, 0, keyword_hint_view_); | 887 kItemPadding, 0, keyword_hint_view_); |
910 if (keyword_hint_view_->keyword() != keyword) | 888 if (keyword_hint_view_->keyword() != keyword) |
911 keyword_hint_view_->SetKeyword(keyword); | 889 keyword_hint_view_->SetKeyword(keyword); |
912 } | 890 } |
913 | 891 |
914 // Perform layout. | 892 // Perform layout. |
915 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); | 893 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
916 int full_width = width() - horizontal_edge_thickness - origin_chip_width; | 894 int full_width = width() - horizontal_edge_thickness - origin_chip_width; |
917 | 895 |
918 // The search button images are made to look as if they overlay the normal | 896 // The search button images are made to look as if they overlay the normal |
919 // edge images, but to align things, the search button needs to be inset | 897 // edge images, but to align things, the search button needs to be inset |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 return delegate_->GetToolbarModel(); | 1049 return delegate_->GetToolbarModel(); |
1072 } | 1050 } |
1073 | 1051 |
1074 WebContents* LocationBarView::GetWebContents() { | 1052 WebContents* LocationBarView::GetWebContents() { |
1075 return delegate_->GetWebContents(); | 1053 return delegate_->GetWebContents(); |
1076 } | 1054 } |
1077 | 1055 |
1078 //////////////////////////////////////////////////////////////////////////////// | 1056 //////////////////////////////////////////////////////////////////////////////// |
1079 // LocationBarView, private: | 1057 // LocationBarView, private: |
1080 | 1058 |
1081 // static | |
1082 int LocationBarView::GetBuiltInHorizontalPaddingForChildViews() { | |
1083 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? | |
1084 GetItemPadding() / 2 : 0; | |
1085 } | |
1086 | |
1087 int LocationBarView::GetHorizontalEdgeThickness() const { | 1059 int LocationBarView::GetHorizontalEdgeThickness() const { |
1088 // In maximized popup mode, there isn't any edge. | 1060 // In maximized popup mode, there isn't any edge. |
1089 return (is_popup_mode_ && browser_ && browser_->window() && | 1061 return (is_popup_mode_ && browser_ && browser_->window() && |
1090 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); | 1062 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); |
1091 } | 1063 } |
1092 | 1064 |
1093 bool LocationBarView::RefreshContentSettingViews() { | 1065 bool LocationBarView::RefreshContentSettingViews() { |
1094 bool visibility_changed = false; | 1066 bool visibility_changed = false; |
1095 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 1067 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
1096 i != content_setting_views_.end(); ++i) { | 1068 i != content_setting_views_.end(); ++i) { |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1703 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1675 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1704 const SearchModel::State& new_state) { | 1676 const SearchModel::State& new_state) { |
1705 const bool visible = !GetToolbarModel()->input_in_progress() && | 1677 const bool visible = !GetToolbarModel()->input_in_progress() && |
1706 new_state.voice_search_supported; | 1678 new_state.voice_search_supported; |
1707 if (mic_search_view_->visible() != visible) { | 1679 if (mic_search_view_->visible() != visible) { |
1708 mic_search_view_->SetVisible(visible); | 1680 mic_search_view_->SetVisible(visible); |
1709 Layout(); | 1681 Layout(); |
1710 } | 1682 } |
1711 } | 1683 } |
1712 | 1684 |
OLD | NEW |