From 3e2195bc6883c84b970ce48252aa915816bcefce Mon Sep 17 00:00:00 2001 From: edwardjung Date: Tue, 14 Apr 2015 11:28:00 -0700 Subject: [PATCH] Remove 'RemoveTrailingSeparators' function from SimpleMenuModel Remove this function following recent wrench menu reorganisation. Wrench menu does not need this function anymore. Refactored code in LauncherApplicationMenuItemModel BUG=none Review URL: https://codereview.chromium.org/1078743003 Cr-Commit-Position: refs/heads/master@{#325089} --- .../ui/ash/launcher/launcher_application_menu_item_model.cc | 11 ++++------- ui/base/models/simple_menu_model.cc | 6 ------ ui/base/models/simple_menu_model.h | 4 ---- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc b/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc index 46824f437cfc..bd20720de929 100644 --- a/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc +++ b/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc @@ -46,6 +46,9 @@ void LauncherApplicationMenuItemModel::ExecuteCommand(int command_id, } void LauncherApplicationMenuItemModel::Build() { + if (launcher_items_.empty()) + return; + AddSeparator(ui::SPACING_SEPARATOR); for (size_t i = 0; i < launcher_items_.size(); i++) { ChromeLauncherAppMenuItem* item = launcher_items_[i]; @@ -60,11 +63,5 @@ void LauncherApplicationMenuItemModel::Build() { if (!item->icon().IsEmpty()) SetIcon(GetIndexOfCommandId(i), item->icon()); } - RemoveTrailingSeparators(); - - // Adding final spacing (if the menu is not empty) to conform the menu to our - // style. - if (launcher_items_.size()) - AddSeparator(ui::SPACING_SEPARATOR); + AddSeparator(ui::SPACING_SEPARATOR); } - diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index 336fd4139a85..cbbdd0de6870 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -140,12 +140,6 @@ void SimpleMenuModel::AddSeparator(MenuSeparatorType separator_type) { AppendItem(item); } -void SimpleMenuModel::RemoveTrailingSeparators() { - while (!items_.empty() && items_.back().type == TYPE_SEPARATOR) - items_.pop_back(); - MenuItemsChanged(); -} - void SimpleMenuModel::AddButtonItem(int command_id, ButtonMenuItemModel* model) { Item item = { command_id, base::string16(), base::string16(), diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index 49403aabeeba..9691d3baab60 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -87,10 +87,6 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel { // or SPACING. NORMAL separators are silently ignored if the model is empty. void AddSeparator(MenuSeparatorType separator_type); - // Removes separators until the model's last entry is not a separator, or the - // model is empty. - void RemoveTrailingSeparators(); - // These three methods take pointers to various sub-models. These models // should be owned by the same owner of this SimpleMenuModel. void AddButtonItem(int command_id, ButtonMenuItemModel* model); -- 2.11.4.GIT