Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: ui/views/controls/menu/menu_item_view.cc

Issue 423833002: Check if the delegate changed the visibility of child MenuItemViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added MenuModelAdapter::IsCommandVisible Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/menu_delegate.cc ('k') | ui/views/controls/menu/menu_model_adapter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/menu/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (label.empty() && GetDelegate()) 247 if (label.empty() && GetDelegate())
248 item->SetTitle(GetDelegate()->GetLabel(item_id)); 248 item->SetTitle(GetDelegate()->GetLabel(item_id));
249 else 249 else
250 item->SetTitle(label); 250 item->SetTitle(label);
251 item->SetSubtitle(sublabel); 251 item->SetSubtitle(sublabel);
252 item->SetMinorText(minor_text); 252 item->SetMinorText(minor_text);
253 if (!icon.isNull()) 253 if (!icon.isNull())
254 item->SetIcon(icon); 254 item->SetIcon(icon);
255 if (type == SUBMENU) 255 if (type == SUBMENU)
256 item->CreateSubmenu(); 256 item->CreateSubmenu();
257 if (GetDelegate() && !GetDelegate()->IsCommandVisible(item_id))
258 item->SetVisible(false);
257 submenu_->AddChildViewAt(item, index); 259 submenu_->AddChildViewAt(item, index);
258 return item; 260 return item;
259 } 261 }
260 262
261 void MenuItemView::RemoveMenuItemAt(int index) { 263 void MenuItemView::RemoveMenuItemAt(int index) {
262 DCHECK(submenu_); 264 DCHECK(submenu_);
263 DCHECK_LE(0, index); 265 DCHECK_LE(0, index);
264 DCHECK_GT(submenu_->child_count(), index); 266 DCHECK_GT(submenu_->child_count(), index);
265 267
266 View* item = submenu_->child_at(index); 268 View* item = submenu_->child_at(index);
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 } else { 1065 } else {
1064 const Type& type = menu_item->GetType(); 1066 const Type& type = menu_item->GetType();
1065 if (type == CHECKBOX || type == RADIO) 1067 if (type == CHECKBOX || type == RADIO)
1066 return true; 1068 return true;
1067 } 1069 }
1068 } 1070 }
1069 return false; 1071 return false;
1070 } 1072 }
1071 1073
1072 } // namespace views 1074 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_delegate.cc ('k') | ui/views/controls/menu/menu_model_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698