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

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

Issue 886883002: [OSX] Allow one zoom bubble to override another. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h" 5 #include "chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 9 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
10 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 10 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 namespace chrome { 68 namespace chrome {
69 69
70 void SetZoomBubbleAutoCloseDelayForTesting(NSTimeInterval time_interval) { 70 void SetZoomBubbleAutoCloseDelayForTesting(NSTimeInterval time_interval) {
71 gAutoCloseDelay = time_interval; 71 gAutoCloseDelay = time_interval;
72 } 72 }
73 73
74 } // namespace chrome 74 } // namespace chrome
75 75
76 @implementation ZoomBubbleController 76 @implementation ZoomBubbleController
77 77
78 @synthesize delegate = delegate_;
79
78 - (id)initWithParentWindow:(NSWindow*)parentWindow 80 - (id)initWithParentWindow:(NSWindow*)parentWindow
79 delegate:(ZoomBubbleControllerDelegate*)delegate { 81 delegate:(ZoomBubbleControllerDelegate*)delegate {
80 base::scoped_nsobject<InfoBubbleWindow> window( 82 base::scoped_nsobject<InfoBubbleWindow> window(
81 [[InfoBubbleWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 100) 83 [[InfoBubbleWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 100)
82 styleMask:NSBorderlessWindowMask 84 styleMask:NSBorderlessWindowMask
83 backing:NSBackingStoreBuffered 85 backing:NSBackingStoreBuffered
84 defer:NO]); 86 defer:NO]);
85 if ((self = [super initWithWindow:window 87 if ((self = [super initWithWindow:window
86 parentWindow:parentWindow 88 parentWindow:parentWindow
87 anchoredAt:NSZeroPoint])) { 89 anchoredAt:NSZeroPoint])) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 : info_bubble::kAnimateNone]; 121 : info_bubble::kAnimateNone];
120 122
121 self.anchorPoint = anchorPoint; 123 self.anchorPoint = anchorPoint;
122 [self showWindow:nil]; 124 [self showWindow:nil];
123 125
124 autoClose_ = autoClose; 126 autoClose_ = autoClose;
125 [self updateAutoCloseTimer]; 127 [self updateAutoCloseTimer];
126 } 128 }
127 129
128 - (void)onZoomChanged { 130 - (void)onZoomChanged {
131 // |delegate_| may be set null by this object's owner.
132 if (!delegate_)
133 return;
134
129 // TODO(shess): It may be appropriate to close the window if 135 // TODO(shess): It may be appropriate to close the window if
130 // |contents| or |zoomController| are NULL. But they can be NULL in 136 // |contents| or |zoomController| are NULL. But they can be NULL in
131 // tests. 137 // tests.
132 138
133 content::WebContents* contents = delegate_->GetWebContents(); 139 content::WebContents* contents = delegate_->GetWebContents();
134 if (!contents) 140 if (!contents)
135 return; 141 return;
136 142
137 ui_zoom::ZoomController* zoomController = 143 ui_zoom::ZoomController* zoomController =
138 ui_zoom::ZoomController::FromWebContents(contents); 144 ui_zoom::ZoomController::FromWebContents(contents);
(...skipping 23 matching lines...) Expand all
162 } 168 }
163 169
164 - (void)closeWithoutAnimation { 170 - (void)closeWithoutAnimation {
165 InfoBubbleWindow* window = 171 InfoBubbleWindow* window =
166 base::mac::ObjCCastStrict<InfoBubbleWindow>([self window]); 172 base::mac::ObjCCastStrict<InfoBubbleWindow>([self window]);
167 [window setAllowedAnimations:info_bubble::kAnimateNone]; 173 [window setAllowedAnimations:info_bubble::kAnimateNone];
168 [self close]; 174 [self close];
169 } 175 }
170 176
171 - (void)windowWillClose:(NSNotification*)notification { 177 - (void)windowWillClose:(NSNotification*)notification {
172 delegate_->OnClose(); 178 // |delegate_| may be set null by this object's owner.
173 delegate_ = NULL; 179 if (delegate_) {
180 delegate_->OnClose();
181 delegate_ = NULL;
182 }
174 [NSObject cancelPreviousPerformRequestsWithTarget:self 183 [NSObject cancelPreviousPerformRequestsWithTarget:self
175 selector:@selector(autoCloseBubble) 184 selector:@selector(autoCloseBubble)
176 object:nil]; 185 object:nil];
177 [super windowWillClose:notification]; 186 [super windowWillClose:notification];
178 } 187 }
179 188
180 - (void)mouseEntered:(NSEvent*)theEvent { 189 - (void)mouseEntered:(NSEvent*)theEvent {
181 isMouseInside_ = YES; 190 isMouseInside_ = YES;
182 [self updateAutoCloseTimer]; 191 [self updateAutoCloseTimer];
183 } 192 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 range:NSMakeRange(0, [title length])]; 350 range:NSMakeRange(0, [title length])];
342 title = selectedTitle.autorelease(); 351 title = selectedTitle.autorelease();
343 } 352 }
344 353
345 [[self cell] drawTitle:title 354 [[self cell] drawTitle:title
346 withFrame:bounds 355 withFrame:bounds
347 inView:self]; 356 inView:self];
348 } 357 }
349 358
350 @end 359 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser/zoom_bubble_controller.h ('k') | chrome/browser/ui/cocoa/location_bar/zoom_decoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698