diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 15:30:23 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-24 15:30:23 +0000 |
commit | 87f7d199b2f59494ad997fdc4a6ec97126e06de4 (patch) | |
tree | 9eb8127174a3ddb37ff0cf9d249fbbf14ed41a8f /ui/base/models | |
parent | 567688be11547ff5822d04b4d45ae52b5fb98b8d (diff) | |
download | chromium_src-87f7d199b2f59494ad997fdc4a6ec97126e06de4.zip chromium_src-87f7d199b2f59494ad997fdc4a6ec97126e06de4.tar.gz chromium_src-87f7d199b2f59494ad997fdc4a6ec97126e06de4.tar.bz2 |
Introduce ItemVector to clean up the iteration through the items in SimpleMenuModel.
R=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9456016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123483 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/models')
-rw-r--r-- | ui/base/models/simple_menu_model.cc | 14 | ||||
-rw-r--r-- | ui/base/models/simple_menu_model.h | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index efdd8cf..be84356 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -187,10 +187,9 @@ void SimpleMenuModel::Clear() { } 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))); + for (ItemVector::iterator i = items_.begin(); i != items_.end(); ++i) { + if ((*i).command_id == command_id) { + return FlipIndex(static_cast<int>(std::distance(items_.begin(), i))); } } return -1; @@ -200,9 +199,8 @@ int SimpleMenuModel::GetIndexOfCommandId(int command_id) { // SimpleMenuModel, MenuModel implementation: bool SimpleMenuModel::HasIcons() const { - for (std::vector<Item>::const_iterator iter = items_.begin(); - iter != items_.end(); ++iter) { - if (!iter->icon.isNull()) + for (ItemVector::const_iterator i = items_.begin(); i != items_.end(); ++i) { + if (!i->icon.isNull()) return true; } diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index 2915d81..c8da021 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -148,6 +148,8 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { private: struct Item; + typedef std::vector<Item> ItemVector; + // Functions for inserting items into |items_|. void AppendItem(const Item& item); void InsertItemAtIndex(const Item& item, int index); @@ -156,7 +158,7 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { // Notify the delegate that the menu is closed. void OnMenuClosed(); - std::vector<Item> items_; + ItemVector items_; Delegate* delegate_; |