| 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/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" | 10 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 - (id)initWithSearchBoxController:(AppsSearchBoxController*)parent; | 132 - (id)initWithSearchBoxController:(AppsSearchBoxController*)parent; |
| 133 | 133 |
| 134 @end | 134 @end |
| 135 | 135 |
| 136 @implementation AppsSearchBoxController | 136 @implementation AppsSearchBoxController |
| 137 | 137 |
| 138 @synthesize delegate = delegate_; | 138 @synthesize delegate = delegate_; |
| 139 | 139 |
| 140 - (id)initWithFrame:(NSRect)frame { | 140 - (id)initWithFrame:(NSRect)frame { |
| 141 if ((self = [super init])) { | 141 if ((self = [super init])) { |
| 142 scoped_nsobject<NSView> containerView([[NSView alloc] initWithFrame:frame]); | 142 base::scoped_nsobject<NSView> containerView( |
| 143 [[NSView alloc] initWithFrame:frame]); |
| 143 [self setView:containerView]; | 144 [self setView:containerView]; |
| 144 [self addSubviews]; | 145 [self addSubviews]; |
| 145 } | 146 } |
| 146 return self; | 147 return self; |
| 147 } | 148 } |
| 148 | 149 |
| 149 - (void)clearSearch { | 150 - (void)clearSearch { |
| 150 [searchTextField_ setStringValue:@""]; | 151 [searchTextField_ setStringValue:@""]; |
| 151 [self controlTextDidChange:nil]; | 152 [self controlTextDidChange:nil]; |
| 152 } | 153 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 364 |
| 364 - (void)addItemToMenu:(NSMenu*)menu | 365 - (void)addItemToMenu:(NSMenu*)menu |
| 365 atIndex:(NSInteger)index | 366 atIndex:(NSInteger)index |
| 366 fromModel:(ui::MenuModel*)model { | 367 fromModel:(ui::MenuModel*)model { |
| 367 [super addItemToMenu:menu | 368 [super addItemToMenu:menu |
| 368 atIndex:index | 369 atIndex:index |
| 369 fromModel:model]; | 370 fromModel:model]; |
| 370 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) | 371 if (model->GetCommandIdAt(index) != app_list::AppListMenu::CURRENT_USER) |
| 371 return; | 372 return; |
| 372 | 373 |
| 373 scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] | 374 base::scoped_nsobject<NSView> customItemView([[CurrentUserMenuItemView alloc] |
| 374 initWithDelegate:[[searchBoxController_ delegate] appListDelegate]]); | 375 initWithDelegate:[[searchBoxController_ delegate] appListDelegate]]); |
| 375 [[menu itemAtIndex:index] setView:customItemView]; | 376 [[menu itemAtIndex:index] setView:customItemView]; |
| 376 } | 377 } |
| 377 | 378 |
| 378 - (NSRect)confinementRectForMenu:(NSMenu*)menu | 379 - (NSRect)confinementRectForMenu:(NSMenu*)menu |
| 379 onScreen:(NSScreen*)screen { | 380 onScreen:(NSScreen*)screen { |
| 380 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; | 381 NSPopUpButton* menuButton = [searchBoxController_ menuControl]; |
| 381 // Ensure the menu comes up below the menu button by trimming the window frame | 382 // Ensure the menu comes up below the menu button by trimming the window frame |
| 382 // to a point anchored below the bottom right of the button. | 383 // to a point anchored below the bottom right of the button. |
| 383 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] | 384 NSRect anchorRect = [menuButton convertRect:[menuButton bounds] |
| 384 toView:nil]; | 385 toView:nil]; |
| 385 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( | 386 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( |
| 386 NSMaxX(anchorRect), | 387 NSMaxX(anchorRect), |
| 387 NSMinY(anchorRect) - kMenuOffsetFromButton)]; | 388 NSMinY(anchorRect) - kMenuOffsetFromButton)]; |
| 388 NSRect confinementRect = [[menuButton window] frame]; | 389 NSRect confinementRect = [[menuButton window] frame]; |
| 389 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), | 390 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), |
| 390 anchorPoint.y - NSMinY(confinementRect)); | 391 anchorPoint.y - NSMinY(confinementRect)); |
| 391 return confinementRect; | 392 return confinementRect; |
| 392 } | 393 } |
| 393 | 394 |
| 394 @end | 395 @end |
| OLD | NEW |