| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/avatar_menu.h" | 10 #include "chrome/browser/profiles/avatar_menu.h" |
| 11 #include "chrome/browser/profiles/avatar_menu_observer.h" | 11 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 14 #include "chrome/browser/profiles/profile_info_cache.h" | 14 #include "chrome/browser/profiles/profile_info_cache.h" |
| 15 #include "chrome/browser/profiles/profile_info_interface.h" | 15 #include "chrome/browser/profiles/profile_info_interface.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/profiles/profile_metrics.h" | 17 #include "chrome/browser/profiles/profile_metrics.h" |
| 18 #include "chrome/browser/profiles/profile_window.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "chrome/browser/ui/browser_list_observer.h" | 21 #include "chrome/browser/ui/browser_list_observer.h" |
| 21 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 22 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
| 22 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 23 #include "components/signin/core/common/profile_management_switches.h" | 24 #include "components/signin/core/common/profile_management_switches.h" |
| 24 #include "ui/base/l10n/l10n_util_mac.h" | 25 #include "ui/base/l10n/l10n_util_mac.h" |
| 25 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 26 | 27 |
| 27 @interface ProfileMenuController (Private) | 28 @interface ProfileMenuController (Private) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 [NSApp activateIgnoringOtherApps:YES]; | 92 [NSApp activateIgnoringOtherApps:YES]; |
| 92 avatarMenu_->SwitchToProfile([sender tag], false, | 93 avatarMenu_->SwitchToProfile([sender tag], false, |
| 93 ProfileMetrics::SWITCH_PROFILE_DOCK); | 94 ProfileMetrics::SWITCH_PROFILE_DOCK); |
| 94 } | 95 } |
| 95 | 96 |
| 96 - (IBAction)editProfile:(id)sender { | 97 - (IBAction)editProfile:(id)sender { |
| 97 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); | 98 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
| 98 } | 99 } |
| 99 | 100 |
| 100 - (IBAction)newProfile:(id)sender { | 101 - (IBAction)newProfile:(id)sender { |
| 101 avatarMenu_->AddNewProfile(ProfileMetrics::ADD_NEW_USER_MENU); | 102 profiles::CreateAndSwitchToNewProfile(chrome::HOST_DESKTOP_TYPE_NATIVE, |
| 103 ProfileManager::CreateCallback(), |
| 104 ProfileMetrics::ADD_NEW_USER_MENU); |
| 102 } | 105 } |
| 103 | 106 |
| 104 - (BOOL)insertItemsIntoMenu:(NSMenu*)menu | 107 - (BOOL)insertItemsIntoMenu:(NSMenu*)menu |
| 105 atOffset:(NSInteger)offset | 108 atOffset:(NSInteger)offset |
| 106 fromDock:(BOOL)dock { | 109 fromDock:(BOOL)dock { |
| 107 if (!avatarMenu_ || !avatarMenu_->ShouldShowAvatarMenu()) | 110 if (!avatarMenu_ || !avatarMenu_->ShouldShowAvatarMenu()) |
| 108 return NO; | 111 return NO; |
| 109 | 112 |
| 110 // Don't show the list of profiles in the dock if only one profile exists. | 113 // Don't show the list of profiles in the dock if only one profile exists. |
| 111 if (dock && avatarMenu_->GetNumberOfItems() <= 1) | 114 if (dock && avatarMenu_->GetNumberOfItems() <= 1) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 257 } |
| 255 | 258 |
| 256 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { | 259 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { |
| 257 base::scoped_nsobject<NSMenuItem> item( | 260 base::scoped_nsobject<NSMenuItem> item( |
| 258 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); | 261 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); |
| 259 [item setTarget:self]; | 262 [item setTarget:self]; |
| 260 return [item.release() autorelease]; | 263 return [item.release() autorelease]; |
| 261 } | 264 } |
| 262 | 265 |
| 263 @end | 266 @end |
| OLD | NEW |