Fixes for Android GN build input/outputs
[chromium-blink-merge.git] / ios / chrome / browser / infobars / infobar_controller.mm
blob594f0f325ad8da0bf8c6a6afb9420e17b44f7118
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;
14 @end
16 @implementation InfoBarController
17 @synthesize delegate = _delegate;
19 - (instancetype)initWithDelegate:(InfoBarViewDelegate*)delegate {
20   self = [super init];
21   if (self) {
22     DCHECK(delegate);
23     _delegate = delegate;
24   }
25   return self;
28 - (void)dealloc {
29   [_infoBarView removeFromSuperview];
30   [super dealloc];
33 - (int)barHeight {
34   return CGRectGetHeight([_infoBarView frame]);
37 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate
38                     frame:(CGRect)bounds {
39   DCHECK(!_infoBarView);
40   _infoBarView = [self viewForDelegate:delegate frame:bounds];
43 - (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
44     viewForDelegate:(infobars::InfoBarDelegate*)delegate
45               frame:(CGRect)bounds {
46   // Must be overriden in subclasses.
47   NOTREACHED();
48   return _infoBarView;
51 - (void)onHeightsRecalculated:(int)newHeight {
52   [_infoBarView setVisibleHeight:newHeight];
55 - (UIView<InfoBarViewProtocol>*)view {
56   return _infoBarView;
59 - (void)removeView {
60   [_infoBarView removeFromSuperview];
63 - (void)detachView {
64   [_infoBarView resetDelegate];
65   _delegate = nullptr;
68 @end