| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/mac_util.h" | 6 #include "base/mac_util.h" |
| 7 #import "chrome/browser/cocoa/animatable_view.h" | 7 #import "chrome/browser/cocoa/animatable_view.h" |
| 8 #include "chrome/browser/cocoa/infobar.h" | 8 #include "chrome/browser/cocoa/infobar.h" |
| 9 #import "chrome/browser/cocoa/infobar_container_controller.h" | 9 #import "chrome/browser/cocoa/infobar_container_controller.h" |
| 10 #import "chrome/browser/cocoa/infobar_controller.h" | 10 #import "chrome/browser/cocoa/infobar_controller.h" |
| 11 #include "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" | 11 #include "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" |
| 12 #import "chrome/browser/cocoa/view_id_util.h" |
| 12 #include "chrome/browser/tab_contents/infobar_delegate.h" | 13 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
| 15 #include "skia/ext/skia_utils_mac.h" | 16 #include "skia/ext/skia_utils_mac.h" |
| 16 | 17 |
| 17 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED | 18 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED |
| 18 // notifications and proxies them back to |controller|. | 19 // notifications and proxies them back to |controller|. |
| 19 class InfoBarNotificationObserver : public NotificationObserver { | 20 class InfoBarNotificationObserver : public NotificationObserver { |
| 20 public: | 21 public: |
| 21 InfoBarNotificationObserver(InfoBarContainerController* controller) | 22 InfoBarNotificationObserver(InfoBarContainerController* controller) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 // NSMutableArray needs an initial capacity, and we rarely ever see | 88 // NSMutableArray needs an initial capacity, and we rarely ever see |
| 88 // more than two infobars at a time, so that seems like a good choice. | 89 // more than two infobars at a time, so that seems like a good choice. |
| 89 infobarControllers_.reset([[NSMutableArray alloc] initWithCapacity:2]); | 90 infobarControllers_.reset([[NSMutableArray alloc] initWithCapacity:2]); |
| 90 } | 91 } |
| 91 return self; | 92 return self; |
| 92 } | 93 } |
| 93 | 94 |
| 94 - (void)dealloc { | 95 - (void)dealloc { |
| 95 DCHECK([infobarControllers_ count] == 0); | 96 DCHECK([infobarControllers_ count] == 0); |
| 97 view_id_util::UnsetID([self view]); |
| 96 [super dealloc]; | 98 [super dealloc]; |
| 97 } | 99 } |
| 98 | 100 |
| 101 - (void)awakeFromNib { |
| 102 // The info bar container view is an ordinary NSView object, so we set its |
| 103 // ViewID here. |
| 104 view_id_util::SetID([self view], VIEW_ID_INFO_BAR_CONTAINER); |
| 105 } |
| 106 |
| 99 - (void)removeDelegate:(InfoBarDelegate*)delegate { | 107 - (void)removeDelegate:(InfoBarDelegate*)delegate { |
| 100 DCHECK(currentTabContents_); | 108 DCHECK(currentTabContents_); |
| 101 currentTabContents_->RemoveInfoBar(delegate); | 109 currentTabContents_->RemoveInfoBar(delegate); |
| 102 } | 110 } |
| 103 | 111 |
| 104 - (void)removeController:(InfoBarController*)controller { | 112 - (void)removeController:(InfoBarController*)controller { |
| 105 if (![infobarControllers_ containsObject:controller]) | 113 if (![infobarControllers_ containsObject:controller]) |
| 106 return; | 114 return; |
| 107 | 115 |
| 108 // This code can be executed while InfoBarController is still on the stack, so | 116 // This code can be executed while InfoBarController is still on the stack, so |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 frame.size.width = NSWidth(containerBounds); | 239 frame.size.width = NSWidth(containerBounds); |
| 232 frame.origin.y = minY; | 240 frame.origin.y = minY; |
| 233 minY += frame.size.height; | 241 minY += frame.size.height; |
| 234 [view setFrame:frame]; | 242 [view setFrame:frame]; |
| 235 } | 243 } |
| 236 | 244 |
| 237 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; | 245 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; |
| 238 } | 246 } |
| 239 | 247 |
| 240 @end | 248 @end |
| OLD | NEW |