| 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" | 
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" | 
| 12 #include "base/mac/sdk_forward_declarations.h" | 12 #include "base/mac/sdk_forward_declarations.h" | 
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" | 
| 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 
| 15 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 15 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 
| 16 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 16 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 
| 17 #include "chrome/browser/ui/cocoa/l10n_util.h" |  | 
| 18 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 17 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" | 
| 19 #include "components/bubble/bubble_controller.h" | 18 #include "components/bubble/bubble_controller.h" | 
| 20 #include "ui/base/cocoa/cocoa_base_utils.h" | 19 #include "ui/base/cocoa/cocoa_base_utils.h" | 
|  | 20 #import "ui/base/cocoa/rtl_feature.h" | 
| 21 | 21 | 
| 22 @interface BaseBubbleController (Private) | 22 @interface BaseBubbleController (Private) | 
| 23 - (void)registerForNotifications; | 23 - (void)registerForNotifications; | 
| 24 - (void)updateOriginFromAnchor; | 24 - (void)updateOriginFromAnchor; | 
| 25 - (void)activateTabWithContents:(content::WebContents*)newContents | 25 - (void)activateTabWithContents:(content::WebContents*)newContents | 
| 26                previousContents:(content::WebContents*)oldContents | 26                previousContents:(content::WebContents*)oldContents | 
| 27                         atIndex:(NSInteger)index | 27                         atIndex:(NSInteger)index | 
| 28                          reason:(int)reason; | 28                          reason:(int)reason; | 
| 29 - (void)recordAnchorOffset; | 29 - (void)recordAnchorOffset; | 
| 30 - (void)parentWindowDidResize:(NSNotification*)notification; | 30 - (void)parentWindowDidResize:(NSNotification*)notification; | 
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 397   // This is not a "real" cancel as potential changes to the radio group are not | 397   // This is not a "real" cancel as potential changes to the radio group are not | 
| 398   // undone. That's ok. | 398   // undone. That's ok. | 
| 399   [self closeBubbleWithReason:BUBBLE_CLOSE_CANCELED]; | 399   [self closeBubbleWithReason:BUBBLE_CLOSE_CANCELED]; | 
| 400 } | 400 } | 
| 401 | 401 | 
| 402 // Takes the |anchor_| point and adjusts the window's origin accordingly. | 402 // Takes the |anchor_| point and adjusts the window's origin accordingly. | 
| 403 - (void)updateOriginFromAnchor { | 403 - (void)updateOriginFromAnchor { | 
| 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 = ui::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::kTopRight: | 
| 415           origin.x -= NSWidth([window frame]) - offsets.width; | 415           origin.x -= NSWidth([window frame]) - offsets.width; | 
| 416           break; | 416           break; | 
| 417         case info_bubble::kTopLeft: | 417         case info_bubble::kTopLeft: | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 456 | 456 | 
| 457 - (void)activateTabWithContents:(content::WebContents*)newContents | 457 - (void)activateTabWithContents:(content::WebContents*)newContents | 
| 458                previousContents:(content::WebContents*)oldContents | 458                previousContents:(content::WebContents*)oldContents | 
| 459                         atIndex:(NSInteger)index | 459                         atIndex:(NSInteger)index | 
| 460                          reason:(int)reason { | 460                          reason:(int)reason { | 
| 461   // The user switched tabs; close. | 461   // The user switched tabs; close. | 
| 462   [self closeBubble]; | 462   [self closeBubble]; | 
| 463 } | 463 } | 
| 464 | 464 | 
| 465 @end  // BaseBubbleController | 465 @end  // BaseBubbleController | 
| OLD | NEW | 
|---|