| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/infobars/infobar_container_controller.h" | 5 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar.h" | 10 #include "chrome/browser/infobars/infobar.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 - (CGFloat)infobarArrowX { | 63 - (CGFloat)infobarArrowX { |
| 64 LocationBarViewMac* locationBar = | 64 LocationBarViewMac* locationBar = |
| 65 [[self browserWindowController] locationBarBridge]; | 65 [[self browserWindowController] locationBarBridge]; |
| 66 return locationBar->GetPageInfoBubblePoint().x; | 66 return locationBar->GetPageInfoBubblePoint().x; |
| 67 } | 67 } |
| 68 | 68 |
| 69 - (void)changeWebContents:(content::WebContents*)contents { | 69 - (void)changeWebContents:(content::WebContents*)contents { |
| 70 currentWebContents_ = contents; | 70 currentWebContents_ = contents; |
| 71 InfoBarManager* infobar_manager = NULL; |
| 71 if (contents) { | 72 if (contents) { |
| 72 containerCocoa_->ChangeInfoBarService( | 73 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents); |
| 73 InfoBarService::FromWebContents(contents)); | 74 if (infobar_service) |
| 74 } else { | 75 infobar_manager = infobar_service->infobar_manager(); |
| 75 containerCocoa_->ChangeInfoBarService(NULL); | |
| 76 } | 76 } |
| 77 containerCocoa_->ChangeInfoBarManager(infobar_manager); |
| 77 } | 78 } |
| 78 | 79 |
| 79 - (void)tabDetachedWithContents:(content::WebContents*)contents { | 80 - (void)tabDetachedWithContents:(content::WebContents*)contents { |
| 80 if (currentWebContents_ == contents) | 81 if (currentWebContents_ == contents) |
| 81 [self changeWebContents:NULL]; | 82 [self changeWebContents:NULL]; |
| 82 } | 83 } |
| 83 | 84 |
| 84 - (CGFloat)overlappingTipHeight { | 85 - (CGFloat)overlappingTipHeight { |
| 85 return containerCocoa_->GetVerticalOverlap(NULL); | 86 return containerCocoa_->GetVerticalOverlap(NULL); |
| 86 } | 87 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 158 |
| 158 // This code can be executed while InfoBarController is still on the stack, so | 159 // This code can be executed while InfoBarController is still on the stack, so |
| 159 // we retain and autorelease the controller to prevent it from being | 160 // we retain and autorelease the controller to prevent it from being |
| 160 // dealloc'ed too early. | 161 // dealloc'ed too early. |
| 161 [[controller retain] autorelease]; | 162 [[controller retain] autorelease]; |
| 162 [[controller view] removeFromSuperview]; | 163 [[controller view] removeFromSuperview]; |
| 163 [infobarControllers_ removeObject:controller]; | 164 [infobarControllers_ removeObject:controller]; |
| 164 } | 165 } |
| 165 | 166 |
| 166 @end | 167 @end |
| OLD | NEW |