Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profiles/profile_menu_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/profiles/profile_menu_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_menu_controller.mm |
| index 437bed15fe87fef70434fae95bd5058c3048dc8a..f5930d5493c506b937ba80ad714c4c7b2dcc53cf 100644 |
| --- a/chrome/browser/ui/cocoa/profiles/profile_menu_controller.mm |
| +++ b/chrome/browser/ui/cocoa/profiles/profile_menu_controller.mm |
| @@ -5,6 +5,7 @@ |
| #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
| #include "base/mac/scoped_nsobject.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "base/strings/sys_string_conversions.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/profiles/avatar_menu.h" |
| @@ -25,6 +26,17 @@ |
| #include "ui/base/l10n/l10n_util_mac.h" |
| #include "ui/gfx/image/image.h" |
| +namespace { |
| + enum ValidateMenuItemSelector { |
|
Alexei Svitkine (slow)
2015/04/22 16:55:25
Don't indent within namespace. Add a comment that
anthonyvd
2015/04/23 14:49:01
Done.
|
| + UNKNOWN_SELECTOR, |
| + NEW_PROFILE, |
| + EDIT_PROFILE, |
| + SWITCH_PROFILE_MENU, |
| + SWITCH_PROFILE_DOCK, |
| + MAX_VALIDATE_MENU_SELECTOR, |
| + }; |
| +} |
| + |
| @interface ProfileMenuController (Private) |
| - (void)initializeMenu; |
| @end |
| @@ -169,8 +181,30 @@ class Observer : public chrome::BrowserListObserver, |
| [menuItem action] != @selector(editProfile:); |
| } |
| - const AvatarMenu::Item& itemData = avatarMenu_->GetItemAt( |
| - avatarMenu_->GetActiveProfileIndex()); |
| + size_t index = avatarMenu_->GetActiveProfileIndex(); |
| + if (avatarMenu_->GetNumberOfItems() <= index) { |
| + ValidateMenuItemSelector current_selector = UNKNOWN_SELECTOR; |
| + if ([menuItem action] == @selector(newProfile:)) |
| + current_selector = NEW_PROFILE; |
| + else if ([menuItem action] == @selector(editProfile:)) |
| + current_selector = EDIT_PROFILE; |
| + else if ([menuItem action] == @selector(switchToProfileFromMenu:)) |
| + current_selector = SWITCH_PROFILE_MENU; |
| + else if ([menuItem action] == @selector(switchToProfileFromDock:)) |
| + current_selector = SWITCH_PROFILE_DOCK; |
| + UMA_HISTOGRAM_ENUMERATION("ValidateMenuItemInvalidIndexSelector", |
|
Alexei Svitkine (slow)
2015/04/22 16:55:25
Histograms use a dotted naming notation - e.g. Foo
anthonyvd
2015/04/23 14:49:01
Done.
|
| + current_selector, |
| + MAX_VALIDATE_MENU_SELECTOR); |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("ValidateMenuItemInvalidIndexProfileCount", |
| + avatarMenu_->GetNumberOfItems(), |
| + 1, 20, 20); |
| + UMA_HISTOGRAM_BOOLEAN("ValidateMenuItemInvalidIndexIsGuest", |
| + activeProfile->IsGuestSession()); |
| + |
| + return NO; |
| + } |
| + |
| + const AvatarMenu::Item& itemData = avatarMenu_->GetItemAt(index); |
| if ([menuItem action] == @selector(switchToProfileFromDock:) || |
| [menuItem action] == @selector(switchToProfileFromMenu:)) { |
| if (!itemData.legacy_supervised) |