Code: void FolderHeaderView::ContentsChanged(views::Textfield* sender,
                                       const base::string16& new_contents) {
   if (!folder_item_)
     return;
 
   folder_item_->RemoveObserver(this);
  std::string name = base::UTF16ToUTF8(folder_name_view_->text());
  delegate_->SetItemName(folder_item_, name);
   folder_item_->AddObserver(this);
 
   Layout();
}

Commit Message: 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
CWE ID: CWE-399
void FolderHeaderView::ContentsChanged(views::Textfield* sender,
                                       const base::string16& new_contents) {
   if (!folder_item_)
     return;
 
  folder_name_view_->Update();
   folder_item_->RemoveObserver(this);
  // Enforce the maximum folder name length in UI.
  std::string name = base::UTF16ToUTF8(
      folder_name_view_->text().substr(0, kMaxFolderNameChars));
  if (name != folder_item_->name())
    delegate_->SetItemName(folder_item_, name);
   folder_item_->AddObserver(this);
 
   Layout();
}
