Enforce the maximum length of the folder name in UI.

BUG=355797
R=xiyuan@chromium.org

Review URL: https://codereview.chromium.org/203863005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260156 0039d316-1c4b-4281-b951-d872f2087c98
void FolderHeaderView::Layout() {
  gfx::Rect rect(GetContentsBounds());
  if (rect.IsEmpty())
    return;

  gfx::Rect back_bounds(rect);
  back_bounds.set_width(kIconDimension + 2 * kPadding);
  back_button_->SetBoundsRect(back_bounds);

  gfx::Rect text_bounds(rect);
  int text_char_num = folder_item_->name().size()
                          ? folder_item_->name().size()
                          : folder_name_placeholder_text_.size();
  int text_width = folder_name_view_->GetFontList().GetExpectedTextWidth(
      text_char_num + kFolderNameLeftRightPaddingChars);
  text_width = std::min(text_width, kMaxFolderNameWidth);
  text_bounds.set_x(back_bounds.x() + (rect.width() - text_width) / 2);
  text_bounds.set_width(text_width);
  text_bounds.ClampToCenteredSize(gfx::Size(text_bounds.width(),
      folder_name_view_->GetPreferredSize().height()));
  folder_name_view_->SetBoundsRect(text_bounds);
}

void FolderHeaderView::Layout() {
  gfx::Rect rect(GetContentsBounds());
  if (rect.IsEmpty())
    return;

  gfx::Rect back_bounds(rect);
  back_bounds.set_width(kIconDimension + 2 * kPadding);
  back_button_->SetBoundsRect(back_bounds);

  gfx::Rect text_bounds(rect);
  int text_char_num = folder_item_->name().size()
                          ? folder_item_->name().size()
                          : folder_name_placeholder_text_.size();
  int text_width = folder_name_view_->GetFontList().GetExpectedTextWidth(
      text_char_num + kFolderNameLeftRightPaddingChars);
  text_width = std::min(text_width, kMaxFolderNameWidth);
  text_bounds.set_x(back_bounds.x() + (rect.width() - text_width) / 2);
  text_bounds.set_width(text_width);
  text_bounds.ClampToCenteredSize(gfx::Size(text_bounds.width(),
      folder_name_view_->GetPreferredSize().height()));
  folder_name_view_->SetBoundsRect(text_bounds);
}
