OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/extensions/browser_actions_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 object:containerView_]; | 387 object:containerView_]; |
388 } | 388 } |
389 | 389 |
390 focusedViewIndex_ = -1; | 390 focusedViewIndex_ = -1; |
391 } | 391 } |
392 | 392 |
393 return self; | 393 return self; |
394 } | 394 } |
395 | 395 |
396 - (void)dealloc { | 396 - (void)dealloc { |
| 397 [self browserWillBeDestroyed]; |
| 398 [super dealloc]; |
| 399 } |
| 400 |
| 401 - (void)browserWillBeDestroyed { |
| 402 [overflowMenu_ setDelegate:nil]; |
397 // Explicitly destroy the ToolbarActionsBar so all buttons get removed with a | 403 // Explicitly destroy the ToolbarActionsBar so all buttons get removed with a |
398 // valid BrowserActionsController, and so we can verify state before | 404 // valid BrowserActionsController, and so we can verify state before |
399 // destruction. | 405 // destruction. |
400 toolbarActionsBar_->DeleteActions(); | 406 if (toolbarActionsBar_.get()) { |
401 toolbarActionsBar_.reset(); | 407 toolbarActionsBar_->DeleteActions(); |
| 408 toolbarActionsBar_.reset(); |
| 409 } |
402 DCHECK_EQ(0u, [buttons_ count]); | 410 DCHECK_EQ(0u, [buttons_ count]); |
403 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 411 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
404 [super dealloc]; | 412 browser_ = nullptr; |
405 } | 413 } |
406 | 414 |
407 - (void)update { | 415 - (void)update { |
408 toolbarActionsBar_->Update(); | 416 toolbarActionsBar_->Update(); |
409 } | 417 } |
410 | 418 |
411 - (NSUInteger)buttonCount { | 419 - (NSUInteger)buttonCount { |
412 return [buttons_ count]; | 420 return [buttons_ count]; |
413 } | 421 } |
414 | 422 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 } | 1035 } |
1028 | 1036 |
1029 #pragma mark - | 1037 #pragma mark - |
1030 #pragma mark Testing Methods | 1038 #pragma mark Testing Methods |
1031 | 1039 |
1032 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { | 1040 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { |
1033 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; | 1041 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; |
1034 } | 1042 } |
1035 | 1043 |
1036 @end | 1044 @end |
OLD | NEW |