diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 00:43:13 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 00:43:13 +0000 |
commit | 57b1c158efd33f129117eb8bef3ff23dde6841d2 (patch) | |
tree | 411f6e70c4ff5591befe9a82c711eaeb6571e3d2 /ui | |
parent | 50340dbd5d86afef1cbf27a334c8a205cab0a315 (diff) | |
download | chromium_src-57b1c158efd33f129117eb8bef3ff23dde6841d2.zip chromium_src-57b1c158efd33f129117eb8bef3ff23dde6841d2.tar.gz chromium_src-57b1c158efd33f129117eb8bef3ff23dde6841d2.tar.bz2 |
Remove separator from top of Apps v2 context menus.
- Adds AddSeparatorIfNecessary to SimpleMenuModel.
- Adds DCHECK for duplicate separators in SimpleMenuModel::AddSeparator.
- Updates app-list and launcher to use AddSeparatorIfNecessary.
BUG=158195
Review URL: https://chromiumcodereview.appspot.com/11558008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/models/simple_menu_model.cc | 7 | ||||
-rw-r--r-- | ui/base/models/simple_menu_model.h | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index dc3884d..18acd40 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -87,6 +87,7 @@ void SimpleMenuModel::AddSeparator(MenuSeparatorType separator_type) { NOTIMPLEMENTED(); } #endif + DCHECK(items_.empty() || items_.back().type != TYPE_SEPARATOR); Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR, -1, NULL, NULL , separator_type }; AppendItem(item); @@ -114,6 +115,12 @@ void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id, AddRadioItem(command_id, l10n_util::GetStringUTF16(string_id), group_id); } +void SimpleMenuModel::AddSeparatorIfNecessary(MenuSeparatorType separator_type) +{ + if (!items_.empty() && items_.back().type != TYPE_SEPARATOR) + AddSeparator(separator_type); +} + void SimpleMenuModel::AddButtonItem(int command_id, ButtonMenuItemModel* model) { Item item = { command_id, string16(), gfx::Image(), TYPE_BUTTON_ITEM, -1, diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index 5ce571a..309b528 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -80,6 +80,9 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { void AddRadioItem(int command_id, const string16& label, int group_id); void AddRadioItemWithStringId(int command_id, int string_id, int group_id); + // Adds a separator if the menu is empty, or the last item is not a separator. + void AddSeparatorIfNecessary(MenuSeparatorType separator_type); + // 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); |