| 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 352f878c47eef91827d43f9ea6587e199e6c43d6..45d3816c7da795c081ed95482dd8970205e5592b 100644
|
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
| @@ -94,6 +94,10 @@
|
| #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
|
| #endif
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +#include "grit/app_locale_settings.h"
|
| +#endif
|
| +
|
| #if !defined(OS_CHROMEOS)
|
| #include "chrome/browser/ui/views/first_run_bubble.h"
|
| #endif
|
| @@ -114,11 +118,11 @@ Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) {
|
| return contents ? chrome::FindBrowserWithWebContents(contents) : NULL;
|
| }
|
|
|
| -// Given a containing |height| and a base |font|, shrinks the font until it will
|
| -// fit within |height| while having its cap height vertically centered. Returns
|
| -// the |font_y_offset| needed to produce this centering.
|
| +// Given a containing |height| and a base |font_list|, shrinks the fonts until
|
| +// it will fit within |height| while having its cap height vertically centered.
|
| +// Returns the |font_y_offset| needed to produce this centering.
|
| void CalculateFontAndOffsetForHeight(int height,
|
| - gfx::Font* font,
|
| + gfx::FontList* font_list,
|
| int* font_y_offset) {
|
| #if defined(OS_WIN)
|
| base::win::ScopedGetDC screen_dc(NULL);
|
| @@ -128,21 +132,23 @@ void CalculateFontAndOffsetForHeight(int height,
|
| // TODO(pkasting): Expand the gfx::Font metrics (and underlying Skia
|
| // metrics) enough to expose the cap height directly.
|
| #if defined(OS_WIN)
|
| - base::win::ScopedSelectObject font_in_dc(screen_dc, font->GetNativeFont());
|
| + const gfx::Font& font = font_list->GetPrimaryFont();
|
| + base::win::ScopedSelectObject font_in_dc(screen_dc, font.GetNativeFont());
|
| TEXTMETRIC tm = {0};
|
| GetTextMetrics(screen_dc, &tm);
|
| - int cap_height = font->GetBaseline() - tm.tmInternalLeading;
|
| + int cap_height = font.GetBaseline() - tm.tmInternalLeading;
|
| *font_y_offset = ((height - cap_height) / 2) - tm.tmInternalLeading;
|
| #else
|
| // Without cap height available, we fall back to centering the full height.
|
| - *font_y_offset = (height - font->GetHeight()) / 2;
|
| + *font_y_offset = (height - font_list->GetHeight()) / 2;
|
| #endif
|
|
|
| if (((*font_y_offset >= 0) &&
|
| - ((*font_y_offset + font->GetHeight()) <= height)) ||
|
| - (font->GetFontSize() <= 1))
|
| + ((*font_y_offset + font_list->GetHeight()) <= height)) ||
|
| + (font_list->GetPrimaryFont().GetFontSize() <= 1))
|
| return;
|
| - *font = font->DeriveFont(-1);
|
| + *font_list = font_list->DeriveFontListWithSize(
|
| + font_list->GetPrimaryFont().GetFontSize() - 1);
|
| }
|
| }
|
|
|
| @@ -234,46 +240,51 @@ void LocationBarView::Init() {
|
| AddChildView(location_icon_view_);
|
|
|
| // Determine the main font.
|
| - gfx::Font font(ui::ResourceBundle::GetSharedInstance().GetFont(
|
| +#if defined(OS_CHROMEOS)
|
| + gfx::FontList font_list(l10n_util::GetStringUTF8(IDS_UI_FONT_FAMILY_CROS));
|
| +#else
|
| + gfx::FontList font_list(ui::ResourceBundle::GetSharedInstance().GetFont(
|
| ui::ResourceBundle::BaseFont));
|
| - const int current_font_size = font.GetFontSize();
|
| +#endif
|
| + const int current_font_size = font_list.GetPrimaryFont().GetFontSize();
|
| const int desired_font_size = browser_defaults::kOmniboxFontPixelSize;
|
| if (current_font_size < desired_font_size)
|
| - font = font.DeriveFont(desired_font_size - current_font_size);
|
| + font_list = font_list.DeriveFontListWithSize(desired_font_size);
|
| // Shrink large fonts to make them fit.
|
| // TODO(pkasting): Stretch the location bar instead in this case.
|
| int location_height = GetInternalHeight(true);
|
| int font_y_offset;
|
| - CalculateFontAndOffsetForHeight(location_height, &font, &font_y_offset);
|
| + CalculateFontAndOffsetForHeight(location_height, &font_list, &font_y_offset);
|
|
|
| // Determine the font for use inside the bubbles.
|
| - gfx::Font bubble_font(font);
|
| + gfx::FontList bubble_font_list(font_list);
|
| int bubble_font_y_offset;
|
| // The bubble background images have 1 px thick edges, which we don't want to
|
| // overlap.
|
| const int kBubbleInteriorVerticalPadding = 1;
|
| CalculateFontAndOffsetForHeight(
|
| location_height - ((kBubblePadding + kBubbleInteriorVerticalPadding) * 2),
|
| - &bubble_font, &bubble_font_y_offset);
|
| + &bubble_font_list, &bubble_font_y_offset);
|
| bubble_font_y_offset += kBubbleInteriorVerticalPadding;
|
|
|
| const SkColor background_color =
|
| GetColor(ToolbarModel::NONE, LocationBarView::BACKGROUND);
|
| ev_bubble_view_ = new EVBubbleView(
|
| - bubble_font, bubble_font_y_offset,
|
| + bubble_font_list.GetPrimaryFont(), bubble_font_y_offset,
|
| GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), background_color, this);
|
| ev_bubble_view_->set_drag_controller(this);
|
| AddChildView(ev_bubble_view_);
|
|
|
| // Initialize the Omnibox view.
|
| location_entry_.reset(CreateOmniboxView(this, model_, profile_,
|
| - command_updater_, is_popup_mode_, this, font, font_y_offset));
|
| + command_updater_, is_popup_mode_, this, font_list, font_y_offset));
|
| SetLocationEntryFocusable(true);
|
| location_entry_view_ = location_entry_->AddToView(this);
|
|
|
| // Initialize the inline autocomplete view which is visible only when IME is
|
| // turned on. Use the same font with the omnibox and highlighted background.
|
| - ime_inline_autocomplete_view_ = new views::Label(string16(), font);
|
| + ime_inline_autocomplete_view_ = new views::Label(string16(),
|
| + font_list.GetPrimaryFont());
|
| ime_inline_autocomplete_view_->set_border(
|
| views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0));
|
| ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| @@ -289,11 +300,12 @@ void LocationBarView::Init() {
|
|
|
| const SkColor text_color = GetColor(ToolbarModel::NONE, TEXT);
|
| selected_keyword_view_ = new SelectedKeywordView(
|
| - bubble_font, bubble_font_y_offset, text_color, background_color,
|
| - profile_);
|
| + bubble_font_list.GetPrimaryFont(), bubble_font_y_offset, text_color,
|
| + background_color, profile_);
|
| AddChildView(selected_keyword_view_);
|
|
|
| - suggested_text_view_ = new views::Label(string16(), font);
|
| + suggested_text_view_ = new views::Label(string16(),
|
| + font_list.GetPrimaryFont());
|
| suggested_text_view_->set_border(
|
| views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0));
|
| suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| @@ -304,7 +316,7 @@ void LocationBarView::Init() {
|
| AddChildView(suggested_text_view_);
|
|
|
| keyword_hint_view_ = new KeywordHintView(
|
| - profile_, font, font_y_offset,
|
| + profile_, font_list.GetPrimaryFont(), font_y_offset,
|
| GetColor(ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT),
|
| background_color);
|
| AddChildView(keyword_hint_view_);
|
| @@ -316,8 +328,9 @@ void LocationBarView::Init() {
|
| for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
|
| ContentSettingImageView* content_blocked_view =
|
| new ContentSettingImageView(static_cast<ContentSettingsType>(i), this,
|
| - bubble_font, bubble_font_y_offset,
|
| - text_color, background_color);
|
| + bubble_font_list.GetPrimaryFont(),
|
| + bubble_font_y_offset, text_color,
|
| + background_color);
|
| content_setting_views_.push_back(content_blocked_view);
|
| content_blocked_view->SetVisible(false);
|
| AddChildView(content_blocked_view);
|
|
|