OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/chrome/browser/infobars/infobar_container_ios.h" | 5 #include "ios/chrome/browser/infobars/infobar_container_ios.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "ios/chrome/browser/infobars/infobar.h" | 12 #include "ios/chrome/browser/infobars/infobar.h" |
13 #include "ios/chrome/browser/infobars/infobar_container_view.h" | 13 #include "ios/chrome/browser/infobars/infobar_container_view.h" |
14 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 14 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
15 | 15 |
16 InfoBarContainerIOS::InfoBarContainerIOS( | 16 InfoBarContainerIOS::InfoBarContainerIOS( |
17 infobars::InfoBarContainer::Delegate* delegate) | 17 infobars::InfoBarContainer::Delegate* delegate) |
18 : InfoBarContainer(delegate), delegate_(delegate) { | 18 : InfoBarContainer(delegate), delegate_(delegate) { |
19 DCHECK(delegate); | 19 DCHECK(delegate); |
20 container_view_.reset([[InfoBarContainerView alloc] init]); | 20 container_view_.reset([[InfoBarContainerView alloc] init]); |
21 [container_view_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 21 [container_view_ setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
(...skipping 23 matching lines...) Expand all Loading... |
45 // this case, signal the delegate that the state changed. | 45 // this case, signal the delegate that the state changed. |
46 // Otherwise, the infobar is being replaced by another one. Do not call the | 46 // Otherwise, the infobar is being replaced by another one. Do not call the |
47 // delegate in this case, as the delegate will be updated when the new infobar | 47 // delegate in this case, as the delegate will be updated when the new infobar |
48 // is added. | 48 // is added. |
49 if (infobar->total_height() == 0 && delegate_) | 49 if (infobar->total_height() == 0 && delegate_) |
50 delegate_->InfoBarContainerStateChanged(false); | 50 delegate_->InfoBarContainerStateChanged(false); |
51 | 51 |
52 // TODO(rohitrao, jif): [Merge 239355] Upstream InfoBarContainer deletes the | 52 // TODO(rohitrao, jif): [Merge 239355] Upstream InfoBarContainer deletes the |
53 // infobar. Avoid deleting it here. | 53 // infobar. Avoid deleting it here. |
54 // crbug.com/327290 | 54 // crbug.com/327290 |
55 // base::MessageLoop::current()->DeleteSoon(FROM_HERE, infobar_ios); | 55 // base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, infobar_ios); |
56 } | 56 } |
57 | 57 |
58 void InfoBarContainerIOS::PlatformSpecificInfoBarStateChanged( | 58 void InfoBarContainerIOS::PlatformSpecificInfoBarStateChanged( |
59 bool is_animating) { | 59 bool is_animating) { |
60 [container_view_ setUserInteractionEnabled:!is_animating]; | 60 [container_view_ setUserInteractionEnabled:!is_animating]; |
61 [container_view_ setNeedsLayout]; | 61 [container_view_ setNeedsLayout]; |
62 } | 62 } |
63 | 63 |
64 void InfoBarContainerIOS::SuspendInfobars() { | 64 void InfoBarContainerIOS::SuspendInfobars() { |
65 ios::GetChromeBrowserProvider()->SetUIViewAlphaWithAnimation(container_view_, | 65 ios::GetChromeBrowserProvider()->SetUIViewAlphaWithAnimation(container_view_, |
66 0); | 66 0); |
67 } | 67 } |
68 | 68 |
69 void InfoBarContainerIOS::RestoreInfobars() { | 69 void InfoBarContainerIOS::RestoreInfobars() { |
70 ios::GetChromeBrowserProvider()->SetUIViewAlphaWithAnimation(container_view_, | 70 ios::GetChromeBrowserProvider()->SetUIViewAlphaWithAnimation(container_view_, |
71 1); | 71 1); |
72 } | 72 } |
OLD | NEW |