| 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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 65 | 65 |
| 66 @implementation ProfileMenuController | 66 @implementation ProfileMenuController |
| 67 | 67 |
| 68 - (id)initWithMainMenuItem:(NSMenuItem*)item { | 68 - (id)initWithMainMenuItem:(NSMenuItem*)item { |
| 69 if ((self = [super init])) { | 69 if ((self = [super init])) { |
| 70 mainMenuItem_ = item; | 70 mainMenuItem_ = item; |
| 71 | 71 |
| 72 base::scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle: | 72 base::scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle: |
| 73 l10n_util::GetNSStringWithFixup(IDS_NEW_PROFILES_OPTIONS_GROUP_NAME)]); | 73 l10n_util::GetNSStringWithFixup(IDS_PROFILES_OPTIONS_GROUP_NAME)]); |
| 74 [mainMenuItem_ setSubmenu:menu]; | 74 [mainMenuItem_ setSubmenu:menu]; |
| 75 | 75 |
| 76 // This object will be constructed as part of nib loading, which happens | 76 // This object will be constructed as part of nib loading, which happens |
| 77 // before the message loop starts and g_browser_process is available. | 77 // before the message loop starts and g_browser_process is available. |
| 78 // Schedule this on the loop to do work when the browser is ready. | 78 // Schedule this on the loop to do work when the browser is ready. |
| 79 [self performSelector:@selector(initializeMenu) | 79 [self performSelector:@selector(initializeMenu) |
| 80 withObject:nil | 80 withObject:nil |
| 81 afterDelay:0]; | 81 afterDelay:0]; |
| 82 } | 82 } |
| 83 return self; | 83 return self; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 } | 104 } |
| 105 | 105 |
| 106 - (BOOL)insertItemsIntoMenu:(NSMenu*)menu | 106 - (BOOL)insertItemsIntoMenu:(NSMenu*)menu |
| 107 atOffset:(NSInteger)offset | 107 atOffset:(NSInteger)offset |
| 108 fromDock:(BOOL)dock { | 108 fromDock:(BOOL)dock { |
| 109 if (!menu_ || !menu_->ShouldShowAvatarMenu()) | 109 if (!menu_ || !menu_->ShouldShowAvatarMenu()) |
| 110 return NO; | 110 return NO; |
| 111 | 111 |
| 112 if (dock) { | 112 if (dock) { |
| 113 NSString* headerName = | 113 NSString* headerName = |
| 114 l10n_util::GetNSStringWithFixup(IDS_NEW_PROFILES_OPTIONS_GROUP_NAME); | 114 l10n_util::GetNSStringWithFixup(IDS_PROFILES_OPTIONS_GROUP_NAME); |
| 115 base::scoped_nsobject<NSMenuItem> header( | 115 base::scoped_nsobject<NSMenuItem> header( |
| 116 [[NSMenuItem alloc] initWithTitle:headerName | 116 [[NSMenuItem alloc] initWithTitle:headerName |
| 117 action:NULL | 117 action:NULL |
| 118 keyEquivalent:@""]); | 118 keyEquivalent:@""]); |
| 119 [header setEnabled:NO]; | 119 [header setEnabled:NO]; |
| 120 [menu insertItem:header atIndex:offset++]; | 120 [menu insertItem:header atIndex:offset++]; |
| 121 } | 121 } |
| 122 | 122 |
| 123 for (size_t i = 0; i < menu_->GetNumberOfItems(); ++i) { | 123 for (size_t i = 0; i < menu_->GetNumberOfItems(); ++i) { |
| 124 const AvatarMenu::Item& itemData = menu_->GetItemAt(i); | 124 const AvatarMenu::Item& itemData = menu_->GetItemAt(i); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 [[self menu] addItem:[NSMenuItem separatorItem]]; | 191 [[self menu] addItem:[NSMenuItem separatorItem]]; |
| 192 | 192 |
| 193 NSMenuItem* item = [self createItemWithTitle: | 193 NSMenuItem* item = [self createItemWithTitle: |
| 194 l10n_util::GetNSStringWithFixup(IDS_PROFILES_MANAGE_BUTTON_LABEL) | 194 l10n_util::GetNSStringWithFixup(IDS_PROFILES_MANAGE_BUTTON_LABEL) |
| 195 action:@selector(editProfile:)]; | 195 action:@selector(editProfile:)]; |
| 196 [[self menu] addItem:item]; | 196 [[self menu] addItem:item]; |
| 197 | 197 |
| 198 [[self menu] addItem:[NSMenuItem separatorItem]]; | 198 [[self menu] addItem:[NSMenuItem separatorItem]]; |
| 199 item = [self createItemWithTitle:l10n_util::GetNSStringWithFixup( | 199 item = [self createItemWithTitle:l10n_util::GetNSStringWithFixup( |
| 200 IDS_NEW_PROFILES_CREATE_NEW_PROFILE_OPTION) | 200 IDS_PROFILES_CREATE_NEW_PROFILE_OPTION) |
| 201 action:@selector(newProfile:)]; | 201 action:@selector(newProfile:)]; |
| 202 [[self menu] addItem:item]; | 202 [[self menu] addItem:item]; |
| 203 | 203 |
| 204 [self rebuildMenu]; | 204 [self rebuildMenu]; |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Notifies the controller that the active browser has changed and that the | 207 // Notifies the controller that the active browser has changed and that the |
| 208 // menu item and menu need to be updated to reflect that. | 208 // menu item and menu need to be updated to reflect that. |
| 209 - (void)activeBrowserChangedTo:(Browser*)browser { | 209 - (void)activeBrowserChangedTo:(Browser*)browser { |
| 210 // Tell the menu that the browser has changed. | 210 // Tell the menu that the browser has changed. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { | 252 - (NSMenuItem*)createItemWithTitle:(NSString*)title action:(SEL)sel { |
| 253 base::scoped_nsobject<NSMenuItem> item( | 253 base::scoped_nsobject<NSMenuItem> item( |
| 254 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); | 254 [[NSMenuItem alloc] initWithTitle:title action:sel keyEquivalent:@""]); |
| 255 [item setTarget:self]; | 255 [item setTarget:self]; |
| 256 return [item.release() autorelease]; | 256 return [item.release() autorelease]; |
| 257 } | 257 } |
| 258 | 258 |
| 259 @end | 259 @end |
| OLD | NEW |