Merge pull request #6169 from electron/map-roles-by-command-id
Map roles by command id instead of index
This commit is contained in:
commit
4e811fc377
2 changed files with 6 additions and 4 deletions
|
@ -17,12 +17,14 @@ AtomMenuModel::~AtomMenuModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomMenuModel::SetRole(int index, const base::string16& role) {
|
void AtomMenuModel::SetRole(int index, const base::string16& role) {
|
||||||
roles_[index] = role;
|
int command_id = GetCommandIdAt(index);
|
||||||
|
roles_[command_id] = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string16 AtomMenuModel::GetRoleAt(int index) {
|
base::string16 AtomMenuModel::GetRoleAt(int index) {
|
||||||
if (ContainsKey(roles_, index))
|
int command_id = GetCommandIdAt(index);
|
||||||
return roles_[index];
|
if (ContainsKey(roles_, command_id))
|
||||||
|
return roles_[command_id];
|
||||||
else
|
else
|
||||||
return base::string16();
|
return base::string16();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class AtomMenuModel : public ui::SimpleMenuModel {
|
||||||
private:
|
private:
|
||||||
Delegate* delegate_; // weak ref.
|
Delegate* delegate_; // weak ref.
|
||||||
|
|
||||||
std::map<int, base::string16> roles_;
|
std::map<int, base::string16> roles_; // command id -> role
|
||||||
base::ObserverList<Observer> observers_;
|
base::ObserverList<Observer> observers_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomMenuModel);
|
DISALLOW_COPY_AND_ASSIGN(AtomMenuModel);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue