| 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/history_overlay_controller.h" | 5 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 self.view.frame = frame; | 130 self.view.frame = frame; |
| 131 [contentView_ setShieldAlpha:shieldAlpha]; | 131 [contentView_ setShieldAlpha:shieldAlpha]; |
| 132 [contentView_ setNeedsDisplay:YES]; | 132 [contentView_ setNeedsDisplay:YES]; |
| 133 } | 133 } |
| 134 | 134 |
| 135 - (void)showPanelForView:(NSView*)view { | 135 - (void)showPanelForView:(NSView*)view { |
| 136 parent_.reset([view retain]); | 136 parent_.reset([view retain]); |
| 137 [self setProgress:0 finished:NO]; // Set initial view position. | 137 [self setProgress:0 finished:NO]; // Set initial view position. |
| 138 [parent_ addSubview:self.view]; | 138 [parent_ addSubview:self.view]; |
| 139 [[BrowserWindowController | |
| 140 browserWindowControllerForView:[self view]] onOverlappedViewShown]; | |
| 141 } | 139 } |
| 142 | 140 |
| 143 - (void)dismiss { | 141 - (void)dismiss { |
| 144 const CGFloat kFadeOutDurationSeconds = 0.4; | 142 const CGFloat kFadeOutDurationSeconds = 0.4; |
| 145 | 143 |
| 146 [NSAnimationContext beginGrouping]; | 144 [NSAnimationContext beginGrouping]; |
| 147 [NSAnimationContext currentContext].duration = kFadeOutDurationSeconds; | 145 [NSAnimationContext currentContext].duration = kFadeOutDurationSeconds; |
| 148 NSView* overlay = self.view; | 146 NSView* overlay = self.view; |
| 149 | 147 |
| 150 base::scoped_nsobject<CAAnimation> animation( | 148 base::scoped_nsobject<CAAnimation> animation( |
| 151 [[overlay animationForKey:@"alphaValue"] copy]); | 149 [[overlay animationForKey:@"alphaValue"] copy]); |
| 152 [animation setDelegate:self]; | 150 [animation setDelegate:self]; |
| 153 [animation setDuration:kFadeOutDurationSeconds]; | 151 [animation setDuration:kFadeOutDurationSeconds]; |
| 154 NSMutableDictionary* dictionary = | 152 NSMutableDictionary* dictionary = |
| 155 [NSMutableDictionary dictionaryWithCapacity:1]; | 153 [NSMutableDictionary dictionaryWithCapacity:1]; |
| 156 [dictionary setObject:animation forKey:@"alphaValue"]; | 154 [dictionary setObject:animation forKey:@"alphaValue"]; |
| 157 [overlay setAnimations:dictionary]; | 155 [overlay setAnimations:dictionary]; |
| 158 [[overlay animator] setAlphaValue:0.0]; | 156 [[overlay animator] setAlphaValue:0.0]; |
| 159 [NSAnimationContext endGrouping]; | 157 [NSAnimationContext endGrouping]; |
| 160 } | 158 } |
| 161 | 159 |
| 162 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { | 160 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { |
| 163 [[BrowserWindowController | |
| 164 browserWindowControllerForView:[self view]] onOverlappedViewHidden]; | |
| 165 [self.view removeFromSuperview]; | 161 [self.view removeFromSuperview]; |
| 166 // Destroy the CAAnimation and its strong reference to its delegate (this | 162 // Destroy the CAAnimation and its strong reference to its delegate (this |
| 167 // class). | 163 // class). |
| 168 [self.view setAnimations:nil]; | 164 [self.view setAnimations:nil]; |
| 169 } | 165 } |
| 170 | 166 |
| 171 @end | 167 @end |
| OLD | NEW |