Extract code handling PrinterProviderAPI from PrintPreviewHandler
[chromium-blink-merge.git] / ios / chrome / browser / infobars / infobar_controller.mm
blob2ea5cf6851e528b2b7349da6e276fad2f0b4d0aa
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/strings/sys_string_conversions.h"
8 #include "components/infobars/core/confirm_infobar_delegate.h"
9 #import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
10 #include "ui/gfx/image/image.h"
12 @implementation InfoBarController
14 - (instancetype)initWithDelegate:(InfoBarViewDelegate*)delegate {
15   self = [super init];
16   if (self) {
17     DCHECK(delegate);
18     delegate_ = delegate;
19   }
20   return self;
23 - (void)dealloc {
24   [infoBarView_ removeFromSuperview];
25   [super dealloc];
28 - (int)barHeight {
29   return CGRectGetHeight([infoBarView_ frame]);
32 - (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate
33                     frame:(CGRect)bounds {
34   // Must be overriden in subclasses.
35   NOTREACHED();
38 - (void)onHeightsRecalculated:(int)newHeight {
39   [infoBarView_ setVisibleHeight:newHeight];
42 - (UIView*)view {
43   return infoBarView_;
46 - (void)removeView {
47   [infoBarView_ removeFromSuperview];
50 - (void)detachView {
51   [infoBarView_ resetDelegate];
52   delegate_ = nullptr;
55 @end