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/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" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // Takes the |anchor_| point and adjusts the window's origin accordingly. | 244 // Takes the |anchor_| point and adjusts the window's origin accordingly. |
245 - (void)updateOriginFromAnchor { | 245 - (void)updateOriginFromAnchor { |
246 NSWindow* window = [self window]; | 246 NSWindow* window = [self window]; |
247 NSPoint origin = anchor_; | 247 NSPoint origin = anchor_; |
248 | 248 |
249 switch ([bubble_ alignment]) { | 249 switch ([bubble_ alignment]) { |
250 case info_bubble::kAlignArrowToAnchor: { | 250 case info_bubble::kAlignArrowToAnchor: { |
251 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + | 251 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + |
252 info_bubble::kBubbleArrowWidth / 2.0, 0); | 252 info_bubble::kBubbleArrowWidth / 2.0, 0); |
253 offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil]; | 253 offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil]; |
254 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { | 254 switch ([bubble_ arrowLocation]) { |
255 origin.x -= NSWidth([window frame]) - offsets.width; | 255 case info_bubble::kTopRight: |
256 } else { | 256 origin.x -= NSWidth([window frame]) - offsets.width; |
257 origin.x -= offsets.width; | 257 break; |
| 258 case info_bubble::kTopLeft: |
| 259 origin.x -= offsets.width; |
| 260 break; |
| 261 case info_bubble::kTopCenter: |
| 262 origin.x -= NSWidth([window frame]) / 2.0; |
| 263 break; |
| 264 case info_bubble::kNoArrow: |
| 265 NOTREACHED(); |
| 266 break; |
258 } | 267 } |
259 break; | 268 break; |
260 } | 269 } |
261 | 270 |
262 case info_bubble::kAlignEdgeToAnchorEdge: | 271 case info_bubble::kAlignEdgeToAnchorEdge: |
263 // If the arrow is to the right then move the origin so that the right | 272 // If the arrow is to the right then move the origin so that the right |
264 // edge aligns with the anchor. If the arrow is to the left then there's | 273 // edge aligns with the anchor. If the arrow is to the left then there's |
265 // nothing to do because the left edge is already aligned with the left | 274 // nothing to do because the left edge is already aligned with the left |
266 // edge of the anchor. | 275 // edge of the anchor. |
267 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { | 276 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { |
(...skipping 19 matching lines...) Expand all Loading... |
287 | 296 |
288 - (void)activateTabWithContents:(content::WebContents*)newContents | 297 - (void)activateTabWithContents:(content::WebContents*)newContents |
289 previousContents:(content::WebContents*)oldContents | 298 previousContents:(content::WebContents*)oldContents |
290 atIndex:(NSInteger)index | 299 atIndex:(NSInteger)index |
291 reason:(int)reason { | 300 reason:(int)reason { |
292 // The user switched tabs; close. | 301 // The user switched tabs; close. |
293 [self close]; | 302 [self close]; |
294 } | 303 } |
295 | 304 |
296 @end // BaseBubbleController | 305 @end // BaseBubbleController |
OLD | NEW |