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..69af96ecebeb898fafc6f05dd064809d77924f7f 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,18 @@ |
| #include "ui/base/l10n/l10n_util_mac.h" |
| #include "ui/gfx/image/image.h" |
| +namespace { |
| +// Used in UMA histogram macros, shouldn't be reordered or renumbered |
| +enum ValidateMenuItemSelector { |
| + UNKNOWN_SELECTOR = 0, |
| + NEW_PROFILE, |
| + EDIT_PROFILE, |
| + SWITCH_PROFILE_MENU, |
| + SWITCH_PROFILE_DOCK, |
| + MAX_VALIDATE_MENU_SELECTOR, |
| +}; |
| +} |
|
Alexei Svitkine (slow)
2015/04/23 15:02:54
Nit: // namespace
Also, put empty lines around th
anthonyvd
2015/04/23 19:04:57
Done.
|
| + |
| @interface ProfileMenuController (Private) |
| - (void)initializeMenu; |
| @end |
| @@ -169,8 +182,31 @@ 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; |
|
Alexei Svitkine (slow)
2015/04/23 15:02:54
Use camelCase.
anthonyvd
2015/04/23 19:04:57
Done.
|
| + 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_BOOLEAN("Profile.ValidateMenuItemInvalidIndex.IsGuest", |
| + activeProfile->IsGuestSession()); |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Profile.ValidateMenuItemInvalidIndex.ProfileCount", |
| + avatarMenu_->GetNumberOfItems(), |
| + 1, 20, 20); |
| + UMA_HISTOGRAM_ENUMERATION("Profile.ValidateMenuItemInvalidIndex.Selector", |
| + current_selector, |
| + MAX_VALIDATE_MENU_SELECTOR); |
| + |
| + return NO; |
| + } |
| + |
| + const AvatarMenu::Item& itemData = avatarMenu_->GetItemAt(index); |
| if ([menuItem action] == @selector(switchToProfileFromDock:) || |
| [menuItem action] == @selector(switchToProfileFromMenu:)) { |
| if (!itemData.legacy_supervised) |