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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/logging.h" // for NOTREACHED() | 7 #include "base/logging.h" // for NOTREACHED() |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 // The mouselock code expects that mouse events reach the main window | 84 // The mouselock code expects that mouse events reach the main window |
85 // immediately, but the cursor is still over the bubble, which eats the | 85 // immediately, but the cursor is still over the bubble, which eats the |
86 // mouse events. Make the bubble transparent for mouse events. | 86 // mouse events. Make the bubble transparent for mouse events. |
87 if (bubbleType_ == FEB_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS || | 87 if (bubbleType_ == FEB_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS || |
88 bubbleType_ == FEB_TYPE_MOUSELOCK_BUTTONS) | 88 bubbleType_ == FEB_TYPE_MOUSELOCK_BUTTONS) |
89 [[self window] setIgnoresMouseEvents:YES]; | 89 [[self window] setIgnoresMouseEvents:YES]; |
90 | 90 |
91 DCHECK(fullscreen_bubble::ShowButtonsForType(bubbleType_)); | 91 DCHECK(fullscreen_bubble::ShowButtonsForType(bubbleType_)); |
92 browser_->OnAcceptFullscreenPermission( | 92 browser_->OnAcceptFullscreenPermission( |
93 url_, bubbleType_); | 93 url_, bubbleType_); |
94 [self showButtons:NO]; | |
95 [self hideSoon]; | |
Nico
2012/06/20 15:52:11
Why is this no longer necessary? (This is the bubb
scheib
2012/06/20 16:20:34
OnAcceptFullscreenPermission destroys this object.
Nico
2012/06/20 16:23:36
Right, but it could reuse the view. That way it's
scheib
2012/06/20 16:29:12
The previous behavior:
- Bubble appears with butto
| |
96 } | 94 } |
97 | 95 |
98 - (void)deny:(id)sender { | 96 - (void)deny:(id)sender { |
99 DCHECK(fullscreen_bubble::ShowButtonsForType(bubbleType_)); | 97 DCHECK(fullscreen_bubble::ShowButtonsForType(bubbleType_)); |
100 browser_->OnDenyFullscreenPermission(bubbleType_); | 98 browser_->OnDenyFullscreenPermission(bubbleType_); |
101 } | 99 } |
102 | 100 |
103 - (void)showButtons:(BOOL)show { | 101 - (void)showButtons:(BOOL)show { |
104 [allowButton_ setHidden:!show]; | 102 [allowButton_ setHidden:!show]; |
105 [denyButton_ setHidden:!show]; | 103 [denyButton_ setHidden:!show]; |
(...skipping 30 matching lines...) Expand all Loading... | |
136 - (void)positionInWindowAtTop:(CGFloat)maxY width:(CGFloat)maxWidth { | 134 - (void)positionInWindowAtTop:(CGFloat)maxY width:(CGFloat)maxWidth { |
137 NSRect windowFrame = [self window].frame; | 135 NSRect windowFrame = [self window].frame; |
138 NSRect ownerWindowFrame = [owner_ window].frame; | 136 NSRect ownerWindowFrame = [owner_ window].frame; |
139 NSPoint origin; | 137 NSPoint origin; |
140 origin.x = ownerWindowFrame.origin.x + | 138 origin.x = ownerWindowFrame.origin.x + |
141 (int)(NSWidth(ownerWindowFrame)/2 - NSWidth(windowFrame)/2); | 139 (int)(NSWidth(ownerWindowFrame)/2 - NSWidth(windowFrame)/2); |
142 origin.y = ownerWindowFrame.origin.y + maxY - NSHeight(windowFrame); | 140 origin.y = ownerWindowFrame.origin.y + maxY - NSHeight(windowFrame); |
143 [[self window] setFrameOrigin:origin]; | 141 [[self window] setFrameOrigin:origin]; |
144 } | 142 } |
145 | 143 |
146 - (void)updateURL:(const GURL&)url | |
147 bubbleType:(FullscreenExitBubbleType)bubbleType { | |
148 bubbleType_ = bubbleType; | |
149 | |
150 [messageLabel_ setStringValue:[self getLabelText]]; | |
151 | |
152 // Make sure the bubble is visible. | |
153 [hideAnimation_.get() stopAnimation]; | |
154 [hideTimer_ invalidate]; | |
155 [[[self window] animator] setAlphaValue:1.0]; | |
156 | |
157 if (fullscreen_bubble::ShowButtonsForType(bubbleType)) { | |
158 [denyButton_ setTitle:SysUTF16ToNSString( | |
159 fullscreen_bubble::GetDenyButtonTextForType(bubbleType))]; | |
160 [self showButtons:YES]; | |
161 | |
162 // Reenable mouse events if they were disabled previously. | |
163 [[self window] setIgnoresMouseEvents:NO]; | |
164 } else { | |
165 [self showButtons:NO]; | |
166 // Only button-less bubbles auto-hide. | |
167 [self hideSoon]; | |
168 } | |
169 // TODO(jeremya): show "Press Esc to exit" instead of a link on mouselock. | |
170 | |
171 // Relayout. A bit jumpy, but functional. | |
172 [tweaker_ tweakUI:[self window]]; | |
173 [owner_ layoutSubviews]; | |
174 } | |
175 | |
176 // Called when someone clicks on the embedded link. | 144 // Called when someone clicks on the embedded link. |
177 - (BOOL) textView:(NSTextView*)textView | 145 - (BOOL) textView:(NSTextView*)textView |
178 clickedOnLink:(id)link | 146 clickedOnLink:(id)link |
179 atIndex:(NSUInteger)charIndex { | 147 atIndex:(NSUInteger)charIndex { |
180 browser_->ExecuteCommand(IDC_FULLSCREEN); | 148 browser_->ExecuteCommand(IDC_FULLSCREEN); |
181 return YES; | 149 return YES; |
182 } | 150 } |
183 | 151 |
184 - (void)hideTimerFired:(NSTimer*)timer { | 152 - (void)hideTimerFired:(NSTimer*)timer { |
185 // This might fire racily for buttoned bubbles, even though the timer is | 153 // This might fire racily for buttoned bubbles, even though the timer is |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 - (void)hideSoon { | 295 - (void)hideSoon { |
328 hideTimer_.reset( | 296 hideTimer_.reset( |
329 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay | 297 [[NSTimer scheduledTimerWithTimeInterval:kInitialDelay |
330 target:self | 298 target:self |
331 selector:@selector(hideTimerFired:) | 299 selector:@selector(hideTimerFired:) |
332 userInfo:nil | 300 userInfo:nil |
333 repeats:NO] retain]); | 301 repeats:NO] retain]); |
334 } | 302 } |
335 | 303 |
336 @end | 304 @end |
OLD | NEW |