Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: ui/app_list/cocoa/apps_search_box_controller.mm

Issue 22268009: Move signin status and current user information into AppListModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 - (void)addItemToMenu:(NSMenu*)menu 366 - (void)addItemToMenu:(NSMenu*)menu
367 atIndex:(NSInteger)index 367 atIndex:(NSInteger)index
368 fromModel:(ui::MenuModel*)model { 368 fromModel:(ui::MenuModel*)model {
369 [super addItemToMenu:menu 369 [super addItemToMenu:menu
370 atIndex:index 370 atIndex:index
371 fromModel:model]; 371 fromModel:model];
372 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) 372 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER)
373 return; 373 return;
374 374
375 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] 375 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc]
376 initWithDelegate:[[searchBoxController_ delegate] appListDelegate]]); 376 initWithCurrentUser:[[searchBoxController_ delegate] currentUserName]
377 userEmail:[[searchBoxController_ delegate] currentUserEmail]]);
377 [[menu itemAtIndex:index] setView:customItemView]; 378 [[menu itemAtIndex:index] setView:customItemView];
378 } 379 }
379 380
380 - (NSRect)confinementRectForMenu:(NSMenu*)menu 381 - (NSRect)confinementRectForMenu:(NSMenu*)menu
381 onScreen:(NSScreen*)screen { 382 onScreen:(NSScreen*)screen {
382 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; 383 NSPopUpButton* menuButton = [searchBoxController_ menuControl];
383 // Ensure the menu comes up below the menu button by trimming the window frame 384 // Ensure the menu comes up below the menu button by trimming the window frame
384 // to a point anchored below the bottom right of the button. 385 // to a point anchored below the bottom right of the button.
385 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] 386 NSRect anchorRect = [menuButton convertRect:[menuButton bounds]
386 toView:nil]; 387 toView:nil];
387 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( 388 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint(
388 NSMaxX(anchorRect), 389 NSMaxX(anchorRect),
389 NSMinY(anchorRect) - kMenuOffsetFromButton)]; 390 NSMinY(anchorRect) - kMenuOffsetFromButton)];
390 NSRect confinementRect = [[menuButton window] frame]; 391 NSRect confinementRect = [[menuButton window] frame];
391 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), 392 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect),
392 anchorPoint.y - NSMinY(confinementRect)); 393 anchorPoint.y - NSMinY(confinementRect));
393 return confinementRect; 394 return confinementRect;
394 } 395 }
395 396
396 @end 397 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698