cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ios / chrome / browser / infobars / infobar_container_ios.mm
bloba09d367a3910e31490a7ea87e36a13a847de229e
1 // Copyright 2012 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_container_ios.h"
7 #import <UIKit/UIKit.h>
9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h"
11 #include "ios/chrome/browser/infobars/infobar.h"
12 #include "ios/chrome/browser/infobars/infobar_container_view.h"
13 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
15 InfoBarContainerIOS::InfoBarContainerIOS(
16     infobars::InfoBarContainer::Delegate* delegate)
17     : InfoBarContainer(delegate), delegate_(delegate) {
18   DCHECK(delegate);
19   container_view_.reset([[InfoBarContainerView alloc] init]);
20   [container_view_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
21                                        UIViewAutoresizingFlexibleTopMargin];
24 InfoBarContainerIOS::~InfoBarContainerIOS() {
25   delegate_ = nullptr;
26   RemoveAllInfoBarsForDestruction();
29 InfoBarContainerView* InfoBarContainerIOS::view() {
30   return container_view_;
33 void InfoBarContainerIOS::PlatformSpecificAddInfoBar(infobars::InfoBar* infobar,
34                                                      size_t position) {
35   InfoBarIOS* infobar_ios = static_cast<InfoBarIOS*>(infobar);
36   [container_view_ addInfoBar:infobar_ios position:position];
39 void InfoBarContainerIOS::PlatformSpecificRemoveInfoBar(
40     infobars::InfoBar* infobar) {
41   InfoBarIOS* infobar_ios = static_cast<InfoBarIOS*>(infobar);
42   infobar_ios->RemoveView();
43   // If total_height() is 0, then the infobar was removed after an animation. In
44   // this case, signal the delegate that the state changed.
45   // Otherwise, the infobar is being replaced by another one. Do not call the
46   // delegate in this case, as the delegate will be updated when the new infobar
47   // is added.
48   if (infobar->total_height() == 0 && delegate_)
49     delegate_->InfoBarContainerStateChanged(false);
51   // TODO(rohitrao, jif): [Merge 239355] Upstream InfoBarContainer deletes the
52   // infobar. Avoid deleting it here.
53   // crbug.com/327290
54   // base::MessageLoop::current()->DeleteSoon(FROM_HERE, infobar_ios);
57 void InfoBarContainerIOS::PlatformSpecificInfoBarStateChanged(
58     bool is_animating) {
59   [container_view_ setUserInteractionEnabled:!is_animating];
60   [container_view_ setNeedsLayout];
63 void InfoBarContainerIOS::SuspendInfobars() {
64   ios::GetChromeBrowserProvider()->SetUIViewAlphaWithAnimation(container_view_,
65                                                                0);
68 void InfoBarContainerIOS::RestoreInfobars() {
69   ios::GetChromeBrowserProvider()->SetUIViewAlphaWithAnimation(container_view_,
70                                                                1);