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

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: add setModel:NULL - destroying the C++ object is guaranteed, but not the menuController_ 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
« no previous file with comments | « ui/app_list/app_list_menu.cc ('k') | ui/app_list/cocoa/apps_search_box_controller_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 [menuController_ setModel:NULL];
163 appListMenu_.reset(
164 new app_list::AppListMenu([delegate_ appListDelegate],
165 [delegate_ appListModel]->users()));
162 menuController_.reset([[AppListMenuController alloc] 166 menuController_.reset([[AppListMenuController alloc]
163 initWithSearchBoxController:self]); 167 initWithSearchBoxController:self]);
164 [menuButton_ setMenu:[menuController_ menu]]; // Menu will populate here. 168 [menuButton_ setMenu:[menuController_ menu]]; // Menu will populate here.
165 } 169 }
166 170
167 - (void)setDelegate:(id<AppsSearchBoxDelegate>)delegate { 171 - (void)setDelegate:(id<AppsSearchBoxDelegate>)delegate {
168 [[menuButton_ menu] removeAllItems]; 172 [[menuButton_ menu] removeAllItems];
169 menuController_.reset(); 173 menuController_.reset();
170 appListMenu_.reset(); 174 appListMenu_.reset();
171 bridge_.reset(); // Ensure observers are cleared before updating |delegate_|. 175 bridge_.reset(); // Ensure observers are cleared before updating |delegate_|.
172 delegate_ = delegate; 176 delegate_ = delegate;
173 if (!delegate_) 177 if (!delegate_)
174 return; 178 return;
175 179
176 bridge_.reset(new app_list::SearchBoxModelObserverBridge(self)); 180 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]; 181 [self rebuildMenu];
184 } 182 }
185 183
186 - (NSTextField*)searchTextField { 184 - (NSTextField*)searchTextField {
187 return searchTextField_; 185 return searchTextField_;
188 } 186 }
189 187
190 - (NSPopUpButton*)menuControl { 188 - (NSPopUpButton*)menuControl {
191 return menuButton_; 189 return menuButton_;
192 } 190 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint( 382 NSPoint anchorPoint = [[menuButton window] convertBaseToScreen:NSMakePoint(
385 NSMaxX(anchorRect) + kMenuXOffsetFromButton, 383 NSMaxX(anchorRect) + kMenuXOffsetFromButton,
386 NSMinY(anchorRect) - kMenuYOffsetFromButton)]; 384 NSMinY(anchorRect) - kMenuYOffsetFromButton)];
387 NSRect confinementRect = [[menuButton window] frame]; 385 NSRect confinementRect = [[menuButton window] frame];
388 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect), 386 confinementRect.size = NSMakeSize(anchorPoint.x - NSMinX(confinementRect),
389 anchorPoint.y - NSMinY(confinementRect)); 387 anchorPoint.y - NSMinY(confinementRect));
390 return confinementRect; 388 return confinementRect;
391 } 389 }
392 390
393 @end 391 @end
OLDNEW
« no previous file with comments | « ui/app_list/app_list_menu.cc ('k') | ui/app_list/cocoa/apps_search_box_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698