| Index: chrome/browser/ui/views/location_bar/location_bar_view.cc
|
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
| index 2e833c094f21400b3fb153de8ca27b09363b1ed2..a42d45fbe5a2ff611a1b65f409afb3e2a072f97f 100644
|
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
| @@ -25,7 +25,6 @@
|
| #include "chrome/browser/search/instant_service_factory.h"
|
| #include "chrome/browser/search/search.h"
|
| #include "chrome/browser/search_engines/template_url_service_factory.h"
|
| -#include "chrome/browser/themes/theme_properties.h"
|
| #include "chrome/browser/translate/chrome_translate_client.h"
|
| #include "chrome/browser/translate/translate_service.h"
|
| #include "chrome/browser/ui/browser.h"
|
| @@ -38,6 +37,7 @@
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/browser/ui/view_ids.h"
|
| #include "chrome/browser/ui/views/browser_dialogs.h"
|
| +#include "chrome/browser/ui/views/layout_constants.h"
|
| #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
|
| #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
|
| #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
|
| @@ -215,10 +215,9 @@ void LocationBarView::Init() {
|
| // Determine the font for use inside the bubbles. The bubble background
|
| // images have 1 px thick edges, which we don't want to overlap.
|
| const int kBubbleInteriorVerticalPadding = 1;
|
| - const int bubble_padding = GetThemeProvider()->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_VERTICAL_PADDING);
|
| const int bubble_vertical_padding =
|
| - (bubble_padding + kBubbleInteriorVerticalPadding) * 2;
|
| + (GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING) +
|
| + kBubbleInteriorVerticalPadding) * 2;
|
| const gfx::FontList bubble_font_list(font_list.DeriveWithHeightUpperBound(
|
| location_height - bubble_vertical_padding));
|
|
|
| @@ -468,10 +467,9 @@ void LocationBarView::SelectAll() {
|
|
|
| gfx::Point LocationBarView::GetLocationBarAnchorPoint() const {
|
| // The +1 in the next line creates a 1-px gap between icon and arrow tip.
|
| - const int icon_internal_padding = GetThemeProvider()->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING);
|
| - gfx::Point icon_bottom(0, location_icon_view_->GetImageBounds().bottom() -
|
| - icon_internal_padding + 1);
|
| + const int icon_padding = GetLayoutConstant(ICON_LABEL_VIEW_TRAILING_PADDING);
|
| + gfx::Point icon_bottom(
|
| + 0, location_icon_view_->GetImageBounds().bottom() - icon_padding + 1);
|
| gfx::Point icon_center(location_icon_view_->GetImageBounds().CenterPoint());
|
| gfx::Point point(icon_center.x(), icon_bottom.y());
|
| ConvertPointToTarget(location_icon_view_, this, &point);
|
| @@ -532,23 +530,16 @@ gfx::Size LocationBarView::GetPreferredSize() const {
|
| // Compute minimum height.
|
| gfx::Size min_size(border_painter_->GetMinimumSize());
|
| // For non-material the size of the asset determines the size of the
|
| - // LocationBarView. For Material Design the height is encoded as a constant in
|
| - // ThemeProperties.
|
| - ui::ThemeProvider* theme_provider = GetThemeProvider();
|
| - if (ui::MaterialDesignController::IsModeMaterial()) {
|
| - min_size.set_height(theme_provider->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_HEIGHT));
|
| - }
|
| + // LocationBarView.
|
| + if (ui::MaterialDesignController::IsModeMaterial())
|
| + min_size.set_height(GetLayoutConstant(LOCATION_BAR_HEIGHT));
|
|
|
| if (!IsInitialized())
|
| return min_size;
|
|
|
| min_size.set_height(min_size.height() * size_animation_.GetCurrentValue());
|
|
|
| - const int horizontal_item_padding = theme_provider->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING);
|
| - const int bubble_horizontal_padding = theme_provider->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING);
|
| + const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
|
|
|
| // Compute width of omnibox-leading content.
|
| const int horizontal_edge_thickness = GetHorizontalEdgeThickness();
|
| @@ -556,13 +547,11 @@ gfx::Size LocationBarView::GetPreferredSize() const {
|
| if (ShouldShowKeywordBubble()) {
|
| // The selected keyword view can collapse completely.
|
| } else if (ShouldShowEVBubble()) {
|
| - leading_width += bubble_horizontal_padding +
|
| - ev_bubble_view_->GetMinimumSizeForLabelText(
|
| - GetToolbarModel()->GetEVCertName())
|
| - .width();
|
| + leading_width += GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) +
|
| + ev_bubble_view_->GetMinimumSizeForLabelText(
|
| + GetToolbarModel()->GetEVCertName()).width();
|
| } else {
|
| - leading_width +=
|
| - horizontal_item_padding + location_icon_view_->GetMinimumSize().width();
|
| + leading_width += padding + location_icon_view_->GetMinimumSize().width();
|
| }
|
|
|
| // Compute width of omnibox-trailing content.
|
| @@ -581,8 +570,8 @@ gfx::Size LocationBarView::GetPreferredSize() const {
|
| trailing_width += IncrementalMinimumWidth((*i));
|
|
|
| min_size.set_width(leading_width + omnibox_view_->GetMinimumSize().width() +
|
| - 2 * horizontal_item_padding -
|
| - omnibox_view_->GetInsets().width() + trailing_width);
|
| + 2 * padding - omnibox_view_->GetInsets().width() +
|
| + trailing_width);
|
| return min_size;
|
| }
|
|
|
| @@ -595,23 +584,19 @@ void LocationBarView::Layout() {
|
| ev_bubble_view_->SetVisible(false);
|
| keyword_hint_view_->SetVisible(false);
|
|
|
| - ui::ThemeProvider* theme_provider = GetThemeProvider();
|
| - const int horizontal_item_padding = theme_provider->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING);
|
| + const int item_padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING);
|
| int trailing_edge_item_padding = 0;
|
| if (!ui::MaterialDesignController::IsModeMaterial()) {
|
| - trailing_edge_item_padding = horizontal_item_padding -
|
| - GetHorizontalEdgeThickness() -
|
| - omnibox_view_->GetInsets().right();
|
| + trailing_edge_item_padding = item_padding - GetHorizontalEdgeThickness() -
|
| + omnibox_view_->GetInsets().right();
|
| }
|
|
|
| LocationBarLayout leading_decorations(
|
| - LocationBarLayout::LEFT_EDGE, horizontal_item_padding,
|
| - horizontal_item_padding - omnibox_view_->GetInsets().left() -
|
| + LocationBarLayout::LEFT_EDGE, item_padding,
|
| + item_padding - omnibox_view_->GetInsets().left() -
|
| GetEditLeadingInternalSpace());
|
| - LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE,
|
| - horizontal_item_padding,
|
| - trailing_edge_item_padding);
|
| + LocationBarLayout trailing_decorations(
|
| + LocationBarLayout::RIGHT_EDGE, item_padding, trailing_edge_item_padding);
|
|
|
| const base::string16 keyword(omnibox_view_->model()->keyword());
|
| // In some cases (e.g. fullscreen mode) we may have 0 height. We still want
|
| @@ -620,19 +605,17 @@ void LocationBarView::Layout() {
|
| // hits ctrl-d).
|
| const int bubble_vertical_padding =
|
| GetVerticalEdgeThickness() +
|
| - theme_provider->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_VERTICAL_PADDING);
|
| + GetLayoutConstant(LOCATION_BAR_BUBBLE_VERTICAL_PADDING);
|
| const int bubble_height =
|
| std::max(height() - (bubble_vertical_padding * 2), 0);
|
| - const int bubble_horizontal_padding = theme_provider->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING);
|
| + const int bubble_horizontal_padding =
|
| + GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING);
|
| const int location_height = GetInternalHeight(false);
|
| const int vertical_padding = VerticalPadding();
|
| if (ShouldShowKeywordBubble()) {
|
| leading_decorations.AddDecoration(bubble_vertical_padding, bubble_height,
|
| true, 0, bubble_horizontal_padding,
|
| - horizontal_item_padding,
|
| - selected_keyword_view_);
|
| + item_padding, selected_keyword_view_);
|
| if (selected_keyword_view_->keyword() != keyword) {
|
| selected_keyword_view_->SetKeyword(keyword);
|
| const TemplateURL* template_url =
|
| @@ -656,7 +639,7 @@ void LocationBarView::Layout() {
|
| const double kMaxBubbleFraction = 0.5;
|
| leading_decorations.AddDecoration(
|
| bubble_vertical_padding, bubble_height, false, kMaxBubbleFraction,
|
| - bubble_horizontal_padding, horizontal_item_padding, ev_bubble_view_);
|
| + bubble_horizontal_padding, item_padding, ev_bubble_view_);
|
| } else {
|
| leading_decorations.AddDecoration(vertical_padding, location_height,
|
| location_icon_view_);
|
| @@ -694,8 +677,8 @@ void LocationBarView::Layout() {
|
| ++i) {
|
| if ((*i)->visible()) {
|
| trailing_decorations.AddDecoration(bubble_vertical_padding, bubble_height,
|
| - false, 0, horizontal_item_padding,
|
| - horizontal_item_padding, (*i));
|
| + false, 0, item_padding, item_padding,
|
| + *i);
|
| }
|
| }
|
| if (mic_search_view_->visible()) {
|
| @@ -706,9 +689,9 @@ void LocationBarView::Layout() {
|
| // IME composition is in progress.
|
| if (!keyword.empty() && omnibox_view_->model()->is_keyword_hint() &&
|
| !omnibox_view_->IsImeComposing()) {
|
| - trailing_decorations.AddDecoration(
|
| - vertical_padding, location_height, true, 0, horizontal_item_padding,
|
| - horizontal_item_padding, keyword_hint_view_);
|
| + trailing_decorations.AddDecoration(vertical_padding, location_height, true,
|
| + 0, item_padding, item_padding,
|
| + keyword_hint_view_);
|
| if (keyword_hint_view_->keyword() != keyword)
|
| keyword_hint_view_->SetKeyword(keyword);
|
| }
|
| @@ -862,19 +845,16 @@ WebContents* LocationBarView::GetWebContents() {
|
| // LocationBarView, private:
|
|
|
| int LocationBarView::IncrementalMinimumWidth(views::View* view) const {
|
| - const int horizontal_item_padding = GetThemeProvider()->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING);
|
| - return view->visible()
|
| - ? (horizontal_item_padding + view->GetMinimumSize().width())
|
| - : 0;
|
| + return view->visible() ?
|
| + (GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING) +
|
| + view->GetMinimumSize().width()) : 0;
|
| }
|
|
|
| int LocationBarView::GetHorizontalEdgeThickness() const {
|
| // In maximized popup mode, there isn't any edge.
|
| return (is_popup_mode_ && browser_ && browser_->window() &&
|
| - browser_->window()->IsMaximized())
|
| - ? 0
|
| - : GetVerticalEdgeThickness();
|
| + browser_->window()->IsMaximized()) ?
|
| + 0 : GetVerticalEdgeThickness();
|
| }
|
|
|
| int LocationBarView::GetVerticalEdgeThickness() const {
|
| @@ -882,10 +862,8 @@ int LocationBarView::GetVerticalEdgeThickness() const {
|
| }
|
|
|
| int LocationBarView::VerticalPadding() const {
|
| - return is_popup_mode_
|
| - ? kPopupEdgeThickness
|
| - : GetThemeProvider()->GetDisplayProperty(
|
| - ThemeProperties::PROPERTY_LOCATION_BAR_VERTICAL_PADDING);
|
| + return is_popup_mode_ ?
|
| + kPopupEdgeThickness : GetLayoutConstant(LOCATION_BAR_VERTICAL_PADDING);
|
| }
|
|
|
| bool LocationBarView::RefreshContentSettingViews() {
|
|
|