1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ios/chrome/browser/infobars/infobar_controller.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
11 @interface InfoBarController () {
12 base::scoped_nsobject<UIView<InfoBarViewProtocol>> _infoBarView;
16 @implementation InfoBarController
17 @synthesize delegate = _delegate;
19 - (instancetype)initWithDelegate:(InfoBarViewDelegate*)delegate {
28 - (instancetype)init {
34 [_infoBarView removeFromSuperview];
39 return CGRectGetHeight([_infoBarView frame]);
42 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate
43 frame:(CGRect)bounds {
44 DCHECK(!_infoBarView);
45 _infoBarView = [self viewForDelegate:delegate frame:bounds];
48 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
49 viewForDelegate:(infobars::InfoBarDelegate*)delegate
50 frame:(CGRect)bounds {
51 // Must be overriden in subclasses.
56 - (void)onHeightsRecalculated:(int)newHeight {
57 [_infoBarView setVisibleHeight:newHeight];
60 - (UIView<InfoBarViewProtocol>*)view {
65 [_infoBarView removeFromSuperview];
69 [_infoBarView resetDelegate];