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

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

Issue 25535006: Fix rebuilding the profile selector on the OSX App Launcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 - (void)clearSearch { 153 - (void)clearSearch {
154 [searchTextField_ setStringValue:@""]; 154 [searchTextField_ setStringValue:@""];
155 [self controlTextDidChange:nil]; 155 [self controlTextDidChange:nil];
156 } 156 }
157 157
158 - (void)rebuildMenu { 158 - (void)rebuildMenu {
159 if (![delegate_ appListDelegate]) 159 if (![delegate_ appListDelegate])
160 return; 160 return;
161 161
162 appListMenu_.reset(
163 new app_list::AppListMenu([delegate_ appListDelegate],
164 [delegate_ appListModel]->users()));
162 menuController_.reset([[AppListMenuController alloc] 165 menuController_.reset([[AppListMenuController alloc]
163 initWithSearchBoxController:self]); 166 initWithSearchBoxController:self]);
164 [menuButton_ setMenu:[menuController_ menu]]; // Menu will populate here. 167 [menuButton_ setMenu:[menuController_ menu]]; // Menu will populate here.
165 } 168 }
166 169
167 - (void)setDelegate:(id<AppsSearchBoxDelegate>)delegate { 170 - (void)setDelegate:(id<AppsSearchBoxDelegate>)delegate {
168 [[menuButton_ menu] removeAllItems]; 171 [[menuButton_ menu] removeAllItems];
169 menuController_.reset(); 172 menuController_.reset();
170 appListMenu_.reset(); 173 appListMenu_.reset();
171 bridge_.reset(); // Ensure observers are cleared before updating |delegate_|. 174 bridge_.reset(); // Ensure observers are cleared before updating |delegate_|.
172 delegate_ = delegate; 175 delegate_ = delegate;
173 if (!delegate_) 176 if (!delegate_)
174 return; 177 return;
175 178
176 bridge_.reset(new app_list::SearchBoxModelObserverBridge(self)); 179 bridge_.reset(new app_list::SearchBoxModelObserverBridge(self));
177 if (![delegate_ appListDelegate])
178 return;
179
180 appListMenu_.reset(
181 new app_list::AppListMenu([delegate_ appListDelegate],
182 [delegate_ appListModel]->users()));
183 [self rebuildMenu]; 180 [self rebuildMenu];
184 } 181 }
185 182
186 - (NSTextField*)searchTextField { 183 - (NSTextField*)searchTextField {
187 return searchTextField_; 184 return searchTextField_;
188 } 185 }
189 186
190 - (NSPopUpButton*)menuControl { 187 - (NSPopUpButton*)menuControl {
191 return menuButton_; 188 return menuButton_;
192 } 189 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( 381 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint(
385 NSMaxX(anchorRect) + kMenuXOffsetFromButton, 382 NSMaxX(anchorRect) + kMenuXOffsetFromButton,
386 NSMinY(anchorRect) - kMenuYOffsetFromButton)]; 383 NSMinY(anchorRect) - kMenuYOffsetFromButton)];
387 NSRect confinementRect = [[menuButton window] frame]; 384 NSRect confinementRect = [[menuButton window] frame];
388 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), 385 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect),
389 anchorPoint.y - NSMinY(confinementRect)); 386 anchorPoint.y - NSMinY(confinementRect));
390 return confinementRect; 387 return confinementRect;
391 } 388 }
392 389
393 @end 390 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698