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.h" | 5 #include "ios/chrome/browser/infobars/infobar.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "components/infobars/core/confirm_infobar_delegate.h" | 10 #include "components/infobars/core/confirm_infobar_delegate.h" |
11 #include "components/translate/core/browser/translate_infobar_delegate.h" | 11 #include "components/translate/core/browser/translate_infobar_delegate.h" |
12 #import "ios/chrome/browser/infobars/confirm_infobar_controller.h" | 12 #import "ios/chrome/browser/infobars/confirm_infobar_controller.h" |
13 #include "ios/chrome/browser/infobars/infobar_controller.h" | 13 #include "ios/chrome/browser/infobars/infobar_controller.h" |
14 #include "ios/chrome/browser/translate/translate_infobar_tags.h" | 14 #include "ios/chrome/browser/translate/translate_infobar_tags.h" |
15 | 15 |
| 16 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 17 #error "This file requires ARC support." |
| 18 #endif |
| 19 |
16 using infobars::InfoBar; | 20 using infobars::InfoBar; |
17 using infobars::InfoBarDelegate; | 21 using infobars::InfoBarDelegate; |
18 | 22 |
19 InfoBarIOS::InfoBarIOS(std::unique_ptr<InfoBarDelegate> delegate) | 23 InfoBarIOS::InfoBarIOS(std::unique_ptr<InfoBarDelegate> delegate) |
20 : InfoBar(std::move(delegate)) {} | 24 : InfoBar(std::move(delegate)) {} |
21 | 25 |
22 InfoBarIOS::~InfoBarIOS() { | 26 InfoBarIOS::~InfoBarIOS() { |
23 DCHECK(controller_); | 27 DCHECK(controller_); |
24 [controller_ detachView]; | 28 [controller_ detachView]; |
25 controller_.reset(); | 29 controller_.reset(); |
26 } | 30 } |
27 | 31 |
28 void InfoBarIOS::SetController(InfoBarController* controller) { | 32 void InfoBarIOS::SetController(InfoBarController* controller) { |
29 controller_.reset([controller retain]); | 33 controller_.reset(controller); |
30 } | 34 } |
31 | 35 |
32 void InfoBarIOS::Layout(CGRect container_bounds) { | 36 void InfoBarIOS::Layout(CGRect container_bounds) { |
33 DCHECK(controller_); | 37 DCHECK(controller_); |
34 if ([controller_ view]) { | 38 if ([controller_ view]) { |
35 [[controller_ view] setFrame:container_bounds]; | 39 [[controller_ view] setFrame:container_bounds]; |
36 } else { | 40 } else { |
37 [controller_ layoutForDelegate:delegate() frame:container_bounds]; | 41 [controller_ layoutForDelegate:delegate() frame:container_bounds]; |
38 } | 42 } |
39 SetBarTargetHeight([controller_ barHeight]); | 43 SetBarTargetHeight([controller_ barHeight]); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 119 } |
116 } | 120 } |
117 | 121 |
118 void InfoBarIOS::InfoBarDidCancel() { | 122 void InfoBarIOS::InfoBarDidCancel() { |
119 // If not owned, the infobar has already been removed. | 123 // If not owned, the infobar has already been removed. |
120 if (!owner()) | 124 if (!owner()) |
121 return; | 125 return; |
122 delegate()->InfoBarDismissed(); | 126 delegate()->InfoBarDismissed(); |
123 RemoveSelf(); | 127 RemoveSelf(); |
124 } | 128 } |
OLD | NEW |