summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/infobars/infobar.h
blob: faad0a7bd61cc529f09f3faf0a7790bd7098bd42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_INFOBARS_INFOBAR_H_
#define IOS_CHROME_BROWSER_INFOBARS_INFOBAR_H_

#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "components/infobars/core/infobar.h"
#import "ios/public/provider/chrome/browser/ui/infobar_view_delegate.h"

@class InfoBarController;
@class UIView;
namespace infobars {
class InfoBarDelegate;
}

// InfoBar for iOS acts as a UIViewController for InfoBarView.
class InfoBarIOS : public infobars::InfoBar, public InfoBarViewDelegate {
 public:
  explicit InfoBarIOS(scoped_ptr<infobars::InfoBarDelegate> delegate);
  ~InfoBarIOS() override;

  // Layouts the infobar using data from delegate and prepare it for adding to
  // superview.
  void Layout(CGRect container_bounds);

  // Returns UIView holding content of this infobar.
  UIView* view();

  // Remove the infobar view from infobar container view.
  void RemoveView();

  // Sets the controller. Should be called right after the infobar's creation.
  void SetController(InfoBarController* controller);

 private:
  // InfoBar overrides:
  void PlatformSpecificOnHeightsRecalculated() override;

  // InfoBarViewDelegate:
  void SetInfoBarTargetHeight(int height) override;
  void InfoBarDidCancel() override;
  void InfoBarButtonDidPress(NSUInteger button_id) override;

  base::scoped_nsobject<InfoBarController> controller_;
  DISALLOW_COPY_AND_ASSIGN(InfoBarIOS);
};

#endif  // IOS_CHROME_BROWSER_INFOBARS_INFOBAR_H_