OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/cocoa/bookmark_bubble_controller.h" | 5 #import "chrome/browser/cocoa/bookmark_bubble_controller.h" |
6 #include "app/l10n_util_mac.h" | 6 #include "app/l10n_util_mac.h" |
7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #import "chrome/browser/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/cocoa/browser_window_controller.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"), | 186 UserMetrics::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"), |
187 model_->profile()); | 187 model_->profile()); |
188 node_ = NULL; // no longer valid | 188 node_ = NULL; // no longer valid |
189 [self ok:sender]; | 189 [self ok:sender]; |
190 } | 190 } |
191 | 191 |
192 // The controller is the target of the pop up button box action so it can | 192 // The controller is the target of the pop up button box action so it can |
193 // handle when "choose another folder" was picked. | 193 // handle when "choose another folder" was picked. |
194 - (IBAction)folderChanged:(id)sender { | 194 - (IBAction)folderChanged:(id)sender { |
195 DCHECK([sender isEqual:folderPopUpButton_]); | 195 DCHECK([sender isEqual:folderPopUpButton_]); |
| 196 // It is possible that due to model change our parent window has been closed |
| 197 // but the popup is still showing and able to notify the controller of a |
| 198 // folder change. We ignore the sender in this case. |
| 199 if (!parentWindow_) |
| 200 return; |
196 NSMenuItem* selected = [folderPopUpButton_ selectedItem]; | 201 NSMenuItem* selected = [folderPopUpButton_ selectedItem]; |
197 ChooseAnotherFolder* chooseItem = [[self class] chooseAnotherFolderObject]; | 202 ChooseAnotherFolder* chooseItem = [[self class] chooseAnotherFolderObject]; |
198 if ([[selected representedObject] isEqual:chooseItem]) { | 203 if ([[selected representedObject] isEqual:chooseItem]) { |
199 UserMetrics::RecordAction( | 204 UserMetrics::RecordAction( |
200 UserMetricsAction("BookmarkBubble_EditFromCombobox"), | 205 UserMetricsAction("BookmarkBubble_EditFromCombobox"), |
201 model_->profile()); | 206 model_->profile()); |
202 [self showEditor]; | 207 [self showEditor]; |
203 } | 208 } |
204 } | 209 } |
205 | 210 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; | 323 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; |
319 DCHECK(idx != -1); | 324 DCHECK(idx != -1); |
320 [folderPopUpButton_ selectItemAtIndex:idx]; | 325 [folderPopUpButton_ selectItemAtIndex:idx]; |
321 } | 326 } |
322 | 327 |
323 - (NSPopUpButton*)folderPopUpButton { | 328 - (NSPopUpButton*)folderPopUpButton { |
324 return folderPopUpButton_; | 329 return folderPopUpButton_; |
325 } | 330 } |
326 | 331 |
327 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) | 332 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) |
OLD | NEW |