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 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
9 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/image/image.h" | 11 #include "ui/gfx/image/image.h" |
11 | 12 |
12 #import <QuartzCore/QuartzCore.h> | 13 #import <QuartzCore/QuartzCore.h> |
13 | 14 |
14 #include <cmath> | 15 #include <cmath> |
15 | 16 |
16 // Constants /////////////////////////////////////////////////////////////////// | 17 // Constants /////////////////////////////////////////////////////////////////// |
17 | 18 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 - (id)initForMode:(HistoryOverlayMode)mode { | 87 - (id)initForMode:(HistoryOverlayMode)mode { |
87 if ((self = [super init])) { | 88 if ((self = [super init])) { |
88 mode_ = mode; | 89 mode_ = mode; |
89 DCHECK(mode == kHistoryOverlayModeBack || | 90 DCHECK(mode == kHistoryOverlayModeBack || |
90 mode == kHistoryOverlayModeForward); | 91 mode == kHistoryOverlayModeForward); |
91 } | 92 } |
92 return self; | 93 return self; |
93 } | 94 } |
94 | 95 |
95 - (void)dealloc { | 96 - (void)dealloc { |
| 97 [[BrowserWindowController |
| 98 browserWindowControllerForView:[self view]] onHistoryOverlayHidden]; |
96 [self.view removeFromSuperview]; | 99 [self.view removeFromSuperview]; |
97 [super dealloc]; | 100 [super dealloc]; |
98 } | 101 } |
99 | 102 |
100 - (void)loadView { | 103 - (void)loadView { |
101 const gfx::Image& image = | 104 const gfx::Image& image = |
102 ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 105 ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
103 mode_ == kHistoryOverlayModeBack ? IDR_SWIPE_BACK | 106 mode_ == kHistoryOverlayModeBack ? IDR_SWIPE_BACK |
104 : IDR_SWIPE_FORWARD); | 107 : IDR_SWIPE_FORWARD); |
105 contentView_.reset( | 108 contentView_.reset( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 [contentView_ setShieldAlpha:shieldAlpha]; | 146 [contentView_ setShieldAlpha:shieldAlpha]; |
144 [contentView_ setNeedsDisplay:YES]; | 147 [contentView_ setNeedsDisplay:YES]; |
145 } | 148 } |
146 | 149 |
147 - (void)showPanelForView:(NSView*)view { | 150 - (void)showPanelForView:(NSView*)view { |
148 parent_.reset([view retain]); | 151 parent_.reset([view retain]); |
149 [self setProgress:0]; // Set initial view position. | 152 [self setProgress:0]; // Set initial view position. |
150 [[parent_ superview] addSubview:self.view | 153 [[parent_ superview] addSubview:self.view |
151 positioned:NSWindowAbove | 154 positioned:NSWindowAbove |
152 relativeTo:parent_]; | 155 relativeTo:parent_]; |
| 156 [[BrowserWindowController |
| 157 browserWindowControllerForView:[self view]] onHistoryOverlayShown]; |
153 } | 158 } |
154 | 159 |
155 - (void)dismiss { | 160 - (void)dismiss { |
156 const CGFloat kFadeOutDurationSeconds = 0.4; | 161 const CGFloat kFadeOutDurationSeconds = 0.4; |
157 | 162 |
158 NSView* overlay = self.view; | 163 NSView* overlay = self.view; |
159 | 164 |
160 scoped_nsobject<CAAnimation> animation( | 165 scoped_nsobject<CAAnimation> animation( |
161 [[overlay animationForKey:@"alphaValue"] copy]); | 166 [[overlay animationForKey:@"alphaValue"] copy]); |
162 [animation setDelegate:self]; | 167 [animation setDelegate:self]; |
163 [animation setDuration:kFadeOutDurationSeconds]; | 168 [animation setDuration:kFadeOutDurationSeconds]; |
164 NSMutableDictionary* dictionary = | 169 NSMutableDictionary* dictionary = |
165 [NSMutableDictionary dictionaryWithCapacity:1]; | 170 [NSMutableDictionary dictionaryWithCapacity:1]; |
166 [dictionary setObject:animation forKey:@"alphaValue"]; | 171 [dictionary setObject:animation forKey:@"alphaValue"]; |
167 [overlay setAnimations:dictionary]; | 172 [overlay setAnimations:dictionary]; |
168 [[overlay animator] setAlphaValue:0.0]; | 173 [[overlay animator] setAlphaValue:0.0]; |
169 } | 174 } |
170 | 175 |
171 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { | 176 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { |
172 // Destroy the CAAnimation and its strong reference to its delegate (this | 177 // Destroy the CAAnimation and its strong reference to its delegate (this |
173 // class). | 178 // class). |
174 [self.view setAnimations:nil]; | 179 [self.view setAnimations:nil]; |
175 } | 180 } |
176 | 181 |
177 @end | 182 @end |
OLD | NEW |