Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/ui/cocoa/base_bubble_controller.mm

Issue 320393005: Close the bubble when entering full screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add include header base_export.h Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/mac/sdk_forward_declarations.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
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/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/mac/sdk_forward_declarations.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
14 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 15 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 18
18 @interface BaseBubbleController (Private) 19 @interface BaseBubbleController (Private)
19 - (void)registerForNotifications; 20 - (void)registerForNotifications;
20 - (void)updateOriginFromAnchor; 21 - (void)updateOriginFromAnchor;
21 - (void)activateTabWithContents:(content::WebContents*)newContents 22 - (void)activateTabWithContents:(content::WebContents*)newContents
22 previousContents:(content::WebContents*)oldContents 23 previousContents:(content::WebContents*)oldContents
23 atIndex:(NSInteger)index 24 atIndex:(NSInteger)index
24 reason:(int)reason; 25 reason:(int)reason;
25 - (void)recordAnchorOffset; 26 - (void)recordAnchorOffset;
26 - (void)parentWindowDidResize:(NSNotification*)notification; 27 - (void)parentWindowDidResize:(NSNotification*)notification;
27 - (void)parentWindowWillClose:(NSNotification*)notification; 28 - (void)parentWindowWillClose:(NSNotification*)notification;
29 - (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification;
28 - (void)closeCleanup; 30 - (void)closeCleanup;
29 @end 31 @end
30 32
31 @implementation BaseBubbleController 33 @implementation BaseBubbleController
32 34
33 @synthesize parentWindow = parentWindow_; 35 @synthesize parentWindow = parentWindow_;
34 @synthesize anchorPoint = anchor_; 36 @synthesize anchorPoint = anchor_;
35 @synthesize bubble = bubble_; 37 @synthesize bubble = bubble_;
36 @synthesize shouldOpenAsKeyWindow = shouldOpenAsKeyWindow_; 38 @synthesize shouldOpenAsKeyWindow = shouldOpenAsKeyWindow_;
37 @synthesize shouldCloseOnResignKey = shouldCloseOnResignKey_; 39 @synthesize shouldCloseOnResignKey = shouldCloseOnResignKey_;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 [super dealloc]; 114 [super dealloc];
113 } 115 }
114 116
115 - (void)registerForNotifications { 117 - (void)registerForNotifications {
116 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 118 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
117 // Watch to see if the parent window closes, and if so, close this one. 119 // Watch to see if the parent window closes, and if so, close this one.
118 [center addObserver:self 120 [center addObserver:self
119 selector:@selector(parentWindowWillClose:) 121 selector:@selector(parentWindowWillClose:)
120 name:NSWindowWillCloseNotification 122 name:NSWindowWillCloseNotification
121 object:parentWindow_]; 123 object:parentWindow_];
124 // Watch for the full screen event, if so, close the bubble
125 [center addObserver:self
126 selector:@selector(parentWindowWillBecomeFullScreen:)
127 name:NSWindowWillEnterFullScreenNotification
128 object:parentWindow_];
122 // Watch for parent window's resizing, to ensure this one is always 129 // Watch for parent window's resizing, to ensure this one is always
123 // anchored correctly. 130 // anchored correctly.
124 [center addObserver:self 131 [center addObserver:self
125 selector:@selector(parentWindowDidResize:) 132 selector:@selector(parentWindowDidResize:)
126 name:NSWindowDidResizeNotification 133 name:NSWindowDidResizeNotification
127 object:parentWindow_]; 134 object:parentWindow_];
128 } 135 }
129 136
130 - (void)setAnchorPoint:(NSPoint)anchor { 137 - (void)setAnchorPoint:(NSPoint)anchor {
131 anchor_ = anchor; 138 anchor_ = anchor;
(...skipping 12 matching lines...) Expand all
144 - (NSBox*)separatorWithFrame:(NSRect)frame { 151 - (NSBox*)separatorWithFrame:(NSRect)frame {
145 frame.size.height = 1.0; 152 frame.size.height = 1.0;
146 base::scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]); 153 base::scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]);
147 [spacer setBoxType:NSBoxSeparator]; 154 [spacer setBoxType:NSBoxSeparator];
148 [spacer setBorderType:NSLineBorder]; 155 [spacer setBorderType:NSLineBorder];
149 [spacer setAlphaValue:0.2]; 156 [spacer setAlphaValue:0.2];
150 return [spacer.release() autorelease]; 157 return [spacer.release() autorelease];
151 } 158 }
152 159
153 - (void)parentWindowDidResize:(NSNotification*)notification { 160 - (void)parentWindowDidResize:(NSNotification*)notification {
161 if (!parentWindow_)
162 return;
163
154 DCHECK_EQ(parentWindow_, [notification object]); 164 DCHECK_EQ(parentWindow_, [notification object]);
155 NSPoint newOrigin = NSMakePoint(NSMinX([parentWindow_ frame]), 165 NSPoint newOrigin = NSMakePoint(NSMinX([parentWindow_ frame]),
156 NSMaxY([parentWindow_ frame])); 166 NSMaxY([parentWindow_ frame]));
157 newOrigin.x -= anchorOffset_.x; 167 newOrigin.x -= anchorOffset_.x;
158 newOrigin.y -= anchorOffset_.y; 168 newOrigin.y -= anchorOffset_.y;
159 [self setAnchorPoint:newOrigin]; 169 [self setAnchorPoint:newOrigin];
160 } 170 }
161 171
162 - (void)parentWindowWillClose:(NSNotification*)notification { 172 - (void)parentWindowWillClose:(NSNotification*)notification {
163 parentWindow_ = nil; 173 parentWindow_ = nil;
164 [self close]; 174 [self close];
165 } 175 }
166 176
177 - (void)parentWindowWillBecomeFullScreen:(NSNotification*)notification {
178 parentWindow_ = nil;
179 [self close];
180 }
181
167 - (void)closeCleanup { 182 - (void)closeCleanup {
168 if (eventTap_) { 183 if (eventTap_) {
169 [NSEvent removeMonitor:eventTap_]; 184 [NSEvent removeMonitor:eventTap_];
170 eventTap_ = nil; 185 eventTap_ = nil;
171 } 186 }
172 if (resignationObserver_) { 187 if (resignationObserver_) {
173 [[NSNotificationCenter defaultCenter] 188 [[NSNotificationCenter defaultCenter]
174 removeObserver:resignationObserver_ 189 removeObserver:resignationObserver_
175 name:NSWindowDidResignKeyNotification 190 name:NSWindowDidResignKeyNotification
176 object:nil]; 191 object:nil];
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 344
330 - (void)activateTabWithContents:(content::WebContents*)newContents 345 - (void)activateTabWithContents:(content::WebContents*)newContents
331 previousContents:(content::WebContents*)oldContents 346 previousContents:(content::WebContents*)oldContents
332 atIndex:(NSInteger)index 347 atIndex:(NSInteger)index
333 reason:(int)reason { 348 reason:(int)reason {
334 // The user switched tabs; close. 349 // The user switched tabs; close.
335 [self close]; 350 [self close];
336 } 351 }
337 352
338 @end // BaseBubbleController 353 @end // BaseBubbleController
OLDNEW
« no previous file with comments | « base/mac/sdk_forward_declarations.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698