| 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_action_button.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 404 |
| 405 [self setNeedsDisplay:YES]; | 405 [self setNeedsDisplay:YES]; |
| 406 } | 406 } |
| 407 | 407 |
| 408 - (void)onRemoved { | 408 - (void)onRemoved { |
| 409 // The button is being removed from the toolbar, and the backing controller | 409 // The button is being removed from the toolbar, and the backing controller |
| 410 // will also be removed. Destroy the delegate. | 410 // will also be removed. Destroy the delegate. |
| 411 // We only need to do this because in Cocoa's memory management, removing the | 411 // We only need to do this because in Cocoa's memory management, removing the |
| 412 // button from the toolbar doesn't synchronously dealloc it. | 412 // button from the toolbar doesn't synchronously dealloc it. |
| 413 viewControllerDelegate_.reset(); | 413 viewControllerDelegate_.reset(); |
| 414 // Also reset the context menu, since it has a dependency on the backing |
| 415 // controller (which owns its model). |
| 416 contextMenuController_.reset(); |
| 414 } | 417 } |
| 415 | 418 |
| 416 - (BOOL)isAnimating { | 419 - (BOOL)isAnimating { |
| 417 return [moveAnimation_ isAnimating]; | 420 return [moveAnimation_ isAnimating]; |
| 418 } | 421 } |
| 419 | 422 |
| 420 - (NSRect)frameAfterAnimation { | 423 - (NSRect)frameAfterAnimation { |
| 421 if ([moveAnimation_ isAnimating]) { | 424 if ([moveAnimation_ isAnimating]) { |
| 422 NSRect endFrame = [[[[moveAnimation_ viewAnimations] objectAtIndex:0] | 425 NSRect endFrame = [[[[moveAnimation_ viewAnimations] objectAtIndex:0] |
| 423 valueForKey:NSViewAnimationEndFrameKey] rectValue]; | 426 valueForKey:NSViewAnimationEndFrameKey] rectValue]; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 [browserActionsController_ currentWebContents]]; | 461 [browserActionsController_ currentWebContents]]; |
| 459 | 462 |
| 460 [image unlockFocus]; | 463 [image unlockFocus]; |
| 461 return image; | 464 return image; |
| 462 } | 465 } |
| 463 | 466 |
| 464 - (NSMenu*)menu { | 467 - (NSMenu*)menu { |
| 465 if (testContextMenu_) | 468 if (testContextMenu_) |
| 466 return testContextMenu_; | 469 return testContextMenu_; |
| 467 | 470 |
| 471 // Make sure we delete any references to an old menu. |
| 472 contextMenuController_.reset(); |
| 473 |
| 468 ui::MenuModel* contextMenu = viewController_->GetContextMenu(); | 474 ui::MenuModel* contextMenu = viewController_->GetContextMenu(); |
| 469 if (!contextMenu) | 475 if (!contextMenu) |
| 470 return nil; | 476 return nil; |
| 471 contextMenuController_.reset( | 477 contextMenuController_.reset( |
| 472 [[MenuController alloc] initWithModel:contextMenu | 478 [[MenuController alloc] initWithModel:contextMenu |
| 473 useWithPopUpButtonCell:NO]); | 479 useWithPopUpButtonCell:NO]); |
| 474 return [contextMenuController_ menu]; | 480 return [contextMenuController_ menu]; |
| 475 } | 481 } |
| 476 | 482 |
| 477 #pragma mark - | 483 #pragma mark - |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 - (ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { | 528 - (ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { |
| 523 ui::ThemeProvider* themeProvider = [window themeProvider]; | 529 ui::ThemeProvider* themeProvider = [window themeProvider]; |
| 524 if (!themeProvider) | 530 if (!themeProvider) |
| 525 themeProvider = | 531 themeProvider = |
| 526 [[browserActionsController_ browser]->window()->GetNativeWindow() | 532 [[browserActionsController_ browser]->window()->GetNativeWindow() |
| 527 themeProvider]; | 533 themeProvider]; |
| 528 return themeProvider; | 534 return themeProvider; |
| 529 } | 535 } |
| 530 | 536 |
| 531 @end | 537 @end |
| OLD | NEW |