diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-27 22:36:45 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-27 22:36:45 +0000 |
commit | 97b6011428a296880615974eb66b8cb709f80e03 (patch) | |
tree | 50d4549d5c475569b33ef56c619a07a8c9883816 /app/menus/simple_menu_model.cc | |
parent | 1a20707f019b5c7e4f42b6b0a4310be2f1691395 (diff) | |
download | chromium_src-97b6011428a296880615974eb66b8cb709f80e03.zip chromium_src-97b6011428a296880615974eb66b8cb709f80e03.tar.gz chromium_src-97b6011428a296880615974eb66b8cb709f80e03.tar.bz2 |
Insert methods for SimpleMenuModel
Don't recreate AppMenuModel in ToolbarView as it now supports updating label dynamically.
BUG=none
TEST=manual: enabling/disabling bookmark sync will update the bookmark sync label correcty.
Review URL: http://codereview.chromium.org/551171
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37333 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/menus/simple_menu_model.cc')
-rw-r--r-- | app/menus/simple_menu_model.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/app/menus/simple_menu_model.cc b/app/menus/simple_menu_model.cc index 66ef4c4..53fe4c1 100644 --- a/app/menus/simple_menu_model.cc +++ b/app/menus/simple_menu_model.cc @@ -60,6 +60,67 @@ void SimpleMenuModel::AddSubMenuWithStringId(int string_id, MenuModel* model) { AddSubMenu(l10n_util::GetStringUTF16(string_id), model); } +void SimpleMenuModel::InsertItemAt( + int index, int command_id, const string16& label) { + Item item = { command_id, label, TYPE_COMMAND, -1, NULL }; + items_.insert(items_.begin() + FlipIndex(index), item); +} + +void SimpleMenuModel::InsertItemWithStringIdAt( + int index, int command_id, int string_id) { + InsertItemAt(index, command_id, l10n_util::GetStringUTF16(string_id)); +} + +void SimpleMenuModel::InsertSeparatorAt(int index) { + Item item = { -1, string16(), TYPE_SEPARATOR, -1, NULL }; + items_.insert(items_.begin() + FlipIndex(index), item); +} + +void SimpleMenuModel::InsertCheckItemAt( + int index, int command_id, const string16& label) { + Item item = { command_id, label, TYPE_CHECK, -1, NULL }; + items_.insert(items_.begin() + FlipIndex(index), item); +} + +void SimpleMenuModel::InsertCheckItemWithStringIdAt( + int index, int command_id, int string_id) { + InsertCheckItemAt( + FlipIndex(index), command_id, l10n_util::GetStringUTF16(string_id)); +} + +void SimpleMenuModel::InsertRadioItemAt( + int index, int command_id, const string16& label, int group_id) { + Item item = { command_id, label, TYPE_RADIO, group_id, NULL }; + items_.insert(items_.begin() + FlipIndex(index), item); +} + +void SimpleMenuModel::InsertRadioItemWithStringIdAt( + int index, int command_id, int string_id, int group_id) { + InsertRadioItemAt( + index, command_id, l10n_util::GetStringUTF16(string_id), group_id); +} + +void SimpleMenuModel::InsertSubMenuAt( + int index, const string16& label, MenuModel* model) { + Item item = { -1, label, TYPE_SUBMENU, -1, model }; + items_.insert(items_.begin() + FlipIndex(index), item); +} + +void SimpleMenuModel::InsertSubMenuWithStringIdAt( + int index, int string_id, MenuModel* model) { + InsertSubMenuAt(index, l10n_util::GetStringUTF16(string_id), model); +} + +int SimpleMenuModel::GetIndexOfCommandId(int command_id) { + std::vector<Item>::iterator itr; + for (itr = items_.begin(); itr != items_.end(); itr++) { + if ((*itr).command_id == command_id) { + return FlipIndex(static_cast<int>(std::distance(items_.begin(), itr))); + } + } + return -1; +} + //////////////////////////////////////////////////////////////////////////////// // SimpleMenuModel, MenuModel implementation: |