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/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 BrowserWindowController* bwc = | 108 BrowserWindowController* bwc = |
109 [BrowserWindowController browserWindowControllerForWindow:parentWindow_]; | 109 [BrowserWindowController browserWindowControllerForWindow:parentWindow_]; |
110 if (bwc) { | 110 if (bwc) { |
111 TabStripController* tabStripController = [bwc tabStripController]; | 111 TabStripController* tabStripController = [bwc tabStripController]; |
112 TabStripModel* tabStripModel = [tabStripController tabStripModel]; | 112 TabStripModel* tabStripModel = [tabStripController tabStripModel]; |
113 tabStripObserverBridge_.reset(new TabStripModelObserverBridge(tabStripModel, | 113 tabStripObserverBridge_.reset(new TabStripModelObserverBridge(tabStripModel, |
114 self)); | 114 self)); |
115 } | 115 } |
116 | 116 |
117 [bubble_ setArrowLocation:info_bubble::kTopRight]; | 117 [bubble_ setArrowLocation:info_bubble::kTopTrailing]; |
118 } | 118 } |
119 | 119 |
120 - (void)dealloc { | 120 - (void)dealloc { |
121 [self unregisterFromNotifications]; | 121 [self unregisterFromNotifications]; |
122 [super dealloc]; | 122 [super dealloc]; |
123 } | 123 } |
124 | 124 |
125 - (void)registerForNotifications { | 125 - (void)registerForNotifications { |
126 // No window to register notifications for. | 126 // No window to register notifications for. |
127 if (!parentWindow_) | 127 if (!parentWindow_) |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 NSWindow* window = [self window]; | 404 NSWindow* window = [self window]; |
405 NSPoint origin = anchor_; | 405 NSPoint origin = anchor_; |
406 | 406 |
407 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); | 407 BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); |
408 switch ([bubble_ alignment]) { | 408 switch ([bubble_ alignment]) { |
409 case info_bubble::kAlignArrowToAnchor: { | 409 case info_bubble::kAlignArrowToAnchor: { |
410 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + | 410 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + |
411 info_bubble::kBubbleArrowWidth / 2.0, 0); | 411 info_bubble::kBubbleArrowWidth / 2.0, 0); |
412 offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil]; | 412 offsets = [[parentWindow_ contentView] convertSize:offsets toView:nil]; |
413 switch ([bubble_ arrowLocation]) { | 413 switch ([bubble_ arrowLocation]) { |
414 case info_bubble::kTopRight: | 414 case info_bubble::kTopTrailing: |
415 origin.x -= NSWidth([window frame]) - offsets.width; | 415 origin.x -= |
| 416 isRTL ? offsets.width : NSWidth([window frame]) - offsets.width; |
416 break; | 417 break; |
417 case info_bubble::kTopLeft: | 418 case info_bubble::kTopLeading: |
418 origin.x -= offsets.width; | 419 origin.x -= |
| 420 isRTL ? NSWidth([window frame]) - offsets.width : offsets.width; |
419 break; | 421 break; |
420 case info_bubble::kNoArrow: | 422 case info_bubble::kNoArrow: |
421 // FALLTHROUGH. | 423 // FALLTHROUGH. |
422 case info_bubble::kTopCenter: | 424 case info_bubble::kTopCenter: |
423 origin.x -= NSWidth([window frame]) / 2.0; | 425 origin.x -= NSWidth([window frame]) / 2.0; |
424 break; | 426 break; |
425 } | 427 } |
426 break; | 428 break; |
427 } | 429 } |
428 | 430 |
429 case info_bubble::kAlignEdgeToAnchorEdge: | 431 case info_bubble::kAlignEdgeToAnchorEdge: |
430 // If the arrow is to the right then move the origin so that the right | 432 // If the arrow is to the right then move the origin so that the right |
431 // edge aligns with the anchor. If the arrow is to the left then there's | 433 // edge aligns with the anchor. If the arrow is to the left then there's |
432 // nothing to do because the left edge is already aligned with the left | 434 // nothing to do because the left edge is already aligned with the left |
433 // edge of the anchor. | 435 // edge of the anchor. |
434 if ([bubble_ arrowLocation] == info_bubble::kTopRight) { | 436 if ([bubble_ arrowLocation] == info_bubble::kTopTrailing) { |
435 origin.x -= NSWidth([window frame]); | 437 origin.x -= NSWidth([window frame]); |
436 } | 438 } |
437 break; | 439 break; |
438 | 440 |
439 case info_bubble::kAlignTrailingEdgeToAnchorEdge: | 441 case info_bubble::kAlignTrailingEdgeToAnchorEdge: |
440 if (!isRTL) | 442 if (!isRTL) |
441 origin.x -= NSWidth([window frame]); | 443 origin.x -= NSWidth([window frame]); |
442 break; | 444 break; |
443 | 445 |
444 case info_bubble::kAlignLeadingEdgeToAnchorEdge: | 446 case info_bubble::kAlignLeadingEdgeToAnchorEdge: |
(...skipping 11 matching lines...) Expand all Loading... |
456 | 458 |
457 - (void)activateTabWithContents:(content::WebContents*)newContents | 459 - (void)activateTabWithContents:(content::WebContents*)newContents |
458 previousContents:(content::WebContents*)oldContents | 460 previousContents:(content::WebContents*)oldContents |
459 atIndex:(NSInteger)index | 461 atIndex:(NSInteger)index |
460 reason:(int)reason { | 462 reason:(int)reason { |
461 // The user switched tabs; close. | 463 // The user switched tabs; close. |
462 [self closeBubble]; | 464 [self closeBubble]; |
463 } | 465 } |
464 | 466 |
465 @end // BaseBubbleController | 467 @end // BaseBubbleController |
OLD | NEW |