OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/cocoa/apps_search_box_controller.h" | 5 #import "ui/app_list/cocoa/apps_search_box_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 - (void)addItemToMenu:(NSMenu*)menu | 374 - (void)addItemToMenu:(NSMenu*)menu |
375 atIndex:(NSInteger)index | 375 atIndex:(NSInteger)index |
376 fromModel:(ui::MenuModel*)model { | 376 fromModel:(ui::MenuModel*)model { |
377 [super addItemToMenu:menu | 377 [super addItemToMenu:menu |
378 atIndex:index | 378 atIndex:index |
379 fromModel:model]; | 379 fromModel:model]; |
380 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) | 380 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) |
381 return; | 381 return; |
382 | 382 |
383 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] | 383 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] |
384 initWithDelegate:[[searchBoxController_ delegate] appListDelegate]]); | 384 initWithCurrentUser:[[searchBoxController_ delegate] currentUserName] |
| 385 userEmail:[[searchBoxController_ delegate] currentUserEmail]]); |
385 [[menu itemAtIndex:index] setView:customItemView]; | 386 [[menu itemAtIndex:index] setView:customItemView]; |
386 } | 387 } |
387 | 388 |
388 - (NSRect)confinementRectForMenu:(NSMenu*)menu | 389 - (NSRect)confinementRectForMenu:(NSMenu*)menu |
389 onScreen:(NSScreen*)screen { | 390 onScreen:(NSScreen*)screen { |
390 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; | 391 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; |
391 // Ensure the menu comes up below the menu button by trimming the window frame | 392 // Ensure the menu comes up below the menu button by trimming the window frame |
392 // to a point anchored below the bottom right of the button. | 393 // to a point anchored below the bottom right of the button. |
393 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] | 394 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] |
394 toView:nil]; | 395 toView:nil]; |
395 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( | 396 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( |
396 NSMaxX(anchorRect) + kMenuXOffsetFromButton, | 397 NSMaxX(anchorRect) + kMenuXOffsetFromButton, |
397 NSMinY(anchorRect) - kMenuYOffsetFromButton)]; | 398 NSMinY(anchorRect) - kMenuYOffsetFromButton)]; |
398 NSRect confinementRect = [[menuButton window] frame]; | 399 NSRect confinementRect = [[menuButton window] frame]; |
399 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), | 400 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), |
400 anchorPoint.y - NSMinY(confinementRect)); | 401 anchorPoint.y - NSMinY(confinementRect)); |
401 return confinementRect; | 402 return confinementRect; |
402 } | 403 } |
403 | 404 |
404 @end | 405 @end |
OLD | NEW |