Commit 1430a093 authored by stkhapugin's avatar stkhapugin Committed by Commit bot

[ObjC ARC] Converts ios/chrome/browser/infobars:infobars to ARC.

Semi-automatically generated ARCMigrate commit

Notable issues:Had to fix includes and subclasses.
BUG=624363
TEST=None

Review-Url: https://codereview.chromium.org/2574463002
Cr-Commit-Position: refs/heads/master@{#438183}
parent 089ce14f
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
source_set("infobars") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"confirm_infobar_controller+protected.h",
"confirm_infobar_controller.h",
......
......@@ -15,6 +15,10 @@
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/image/image.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// UI Tags for the infobar elements.
......@@ -53,13 +57,13 @@ ConfirmInfoBarDelegate::InfoBarButton UITagToButton(NSUInteger tag) {
#pragma mark -
#pragma mark InfoBarController
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
UIView<InfoBarViewProtocol>* infoBarView;
_confirmInfobarDelegate = delegate->AsConfirmInfoBarDelegate();
infoBarView.reset(
ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate));
infoBarView =
ios::GetChromeBrowserProvider()->CreateInfoBarView(frame, self.delegate);
// Model data.
gfx::Image modelIcon = _confirmInfobarDelegate->GetIcon();
int buttons = _confirmInfobarDelegate->GetButtons();
......
......@@ -13,6 +13,10 @@
#include "ios/chrome/browser/infobars/infobar_controller.h"
#include "ios/chrome/browser/translate/translate_infobar_tags.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using infobars::InfoBar;
using infobars::InfoBarDelegate;
......@@ -26,7 +30,7 @@ InfoBarIOS::~InfoBarIOS() {
}
void InfoBarIOS::SetController(InfoBarController* controller) {
controller_.reset([controller retain]);
controller_.reset(controller);
}
void InfoBarIOS::Layout(CGRect container_bounds) {
......
......@@ -13,6 +13,10 @@
#include "ios/chrome/browser/infobars/infobar_container_view.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
InfoBarContainerIOS::InfoBarContainerIOS(
infobars::InfoBarContainer::Delegate* delegate)
: InfoBarContainer(delegate), delegate_(delegate) {
......
......@@ -9,6 +9,10 @@
#include "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
#include "ui/base/device_form_factor.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation InfoBarContainerView
- (void)addInfoBar:(InfoBarIOS*)infoBarIOS position:(NSInteger)position {
......
......@@ -6,7 +6,6 @@
#define IOS_CHROME_BROWSER_INFOBARS_INFOBAR_CONTROLLER_H_
#import <UIKit/UIKit.h>
#include "base/mac/scoped_nsobject.h"
@protocol InfoBarViewProtocol;
class InfoBarViewDelegate;
......@@ -26,9 +25,9 @@ class InfoBarDelegate;
// Creates a view and lays out all the infobar elements in it. Will not add
// it as a subview yet. This method must be overriden in subclasses.
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)bounds;
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)bounds;
// Creates the view.
- (void)layoutForDelegate:(infobars::InfoBarDelegate*)delegate
......
......@@ -9,8 +9,12 @@
#include "base/logging.h"
#import "ios/public/provider/chrome/browser/ui/infobar_view_protocol.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface InfoBarController () {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> _infoBarView;
UIView<InfoBarViewProtocol>* _infoBarView;
}
@end
......@@ -33,7 +37,6 @@
- (void)dealloc {
[_infoBarView removeFromSuperview];
[super dealloc];
}
- (int)barHeight {
......@@ -46,9 +49,9 @@
_infoBarView = [self viewForDelegate:delegate frame:bounds];
}
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)bounds {
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)bounds {
// Must be overriden in subclasses.
NOTREACHED();
return _infoBarView;
......
......@@ -16,6 +16,10 @@
#include "ios/web/public/web_state/web_state.h"
#include "ui/base/page_transition_types.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
DEFINE_WEB_STATE_USER_DATA_KEY(InfoBarManagerImpl);
namespace {
......
......@@ -7,16 +7,19 @@
#include <memory>
#include <utility>
#include "base/mac/scoped_nsobject.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "ios/chrome/browser/infobars/confirm_infobar_controller.h"
#include "ios/chrome/browser/infobars/infobar.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar(
std::unique_ptr<ConfirmInfoBarDelegate> delegate) {
std::unique_ptr<InfoBarIOS> infobar(new InfoBarIOS(std::move(delegate)));
base::scoped_nsobject<ConfirmInfoBarController> controller(
[[ConfirmInfoBarController alloc] initWithDelegate:infobar.get()]);
ConfirmInfoBarController* controller =
[[ConfirmInfoBarController alloc] initWithDelegate:infobar.get()];
infobar->SetController(controller);
return std::move(infobar);
}
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/native_app_launcher/native_app_infobar_controller.h"
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -33,9 +34,9 @@
#pragma mark - InfoBarController
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
nativeAppInfoBarDelegate_ = static_cast<NativeAppInfoBarDelegate*>(delegate);
DCHECK(nativeAppInfoBarDelegate_);
......@@ -96,7 +97,7 @@ viewForDelegate:(infobars::InfoBarDelegate*)delegate
break;
}
}
return infoBarView;
return [[infoBarView retain] autorelease];
}
- (void)infoBarButtonDidPress:(UIButton*)button {
......
......@@ -9,6 +9,7 @@
#include <memory>
#include <utility>
#include "base/mac/scoped_nsobject.h"
#include "base/memory/ptr_util.h"
#include "base/strings/sys_string_conversions.h"
#include "components/infobars/core/infobar_manager.h"
......
......@@ -6,6 +6,7 @@
#include <utility>
#include "base/mac/scoped_nsobject.h"
#include "base/memory/ptr_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
......
......@@ -13,7 +13,7 @@ class IOSChromeUpdatePasswordInfoBarDelegate;
// the user whether they want to update their password.
@interface UpdatePasswordInfoBarController : ConfirmInfoBarController
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
- (UIView<InfoBarViewProtocol>*)
viewForDelegate:(IOSChromeUpdatePasswordInfoBarDelegate*)delegate
frame:(CGRect)frame;
......
......@@ -39,7 +39,7 @@ NSUInteger kAccountTag = 10;
return self;
}
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
- (UIView<InfoBarViewProtocol>*)
viewForDelegate:(IOSChromeUpdatePasswordInfoBarDelegate*)delegate
frame:(CGRect)frame {
_delegate = delegate;
......
......@@ -4,6 +4,7 @@
#include "ios/chrome/browser/translate/after_translate_infobar_controller.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/strings/grit/components_strings.h"
......@@ -29,9 +30,9 @@
#pragma mark -
#pragma mark InfoBarControllerProtocol
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
_translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate();
DCHECK(_translateInfoBarDelegate);
......@@ -89,7 +90,7 @@
target:self
action:@selector(infoBarSwitchDidPress:)];
}
return infoBarView;
return [[infoBarView retain] autorelease];
}
#pragma mark - Handling of User Events
......
......@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/strings/grit/components_strings.h"
......@@ -127,9 +128,9 @@ NSTimeInterval kPickerAnimationDurationInSeconds = 0.2;
#pragma mark -
#pragma mark InfoBarControllerProtocol
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
_translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate();
infoBarView.reset(
......@@ -155,7 +156,7 @@ NSTimeInterval kPickerAnimationDurationInSeconds = 0.2;
tag2:TranslateInfoBarIOSTag::BEFORE_DENY
target:self
action:@selector(infoBarButtonDidPress:)];
return infoBarView;
return [[infoBarView retain] autorelease];
}
- (void)updateInfobarLabelOnView:(UIView<InfoBarViewProtocol>*)view {
......
......@@ -4,6 +4,7 @@
#include "ios/chrome/browser/translate/never_translate_infobar_controller.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "components/strings/grit/components_strings.h"
......@@ -28,9 +29,9 @@
#pragma mark -
#pragma mark InfoBarControllerProtocol
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
translate::TranslateInfoBarDelegate* translateInfoBarDelegate =
delegate->AsTranslateInfoBarDelegate();
......@@ -61,7 +62,7 @@
tag2:TranslateInfoBarIOSTag::DENY_WEBSITE
target:self
action:@selector(infoBarButtonDidPress:)];
return infoBarView;
return [[infoBarView retain] autorelease];
}
#pragma mark - Handling of User Events
......
......@@ -4,6 +4,7 @@
#include "ios/chrome/browser/translate/translate_message_infobar_controller.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#include "components/translate/core/browser/translate_infobar_delegate.h"
#include "ios/chrome/browser/translate/translate_infobar_tags.h"
......@@ -21,9 +22,9 @@
@implementation TranslateMessageInfoBarController
- (base::scoped_nsobject<UIView<InfoBarViewProtocol>>)
viewForDelegate:(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
- (UIView<InfoBarViewProtocol>*)viewForDelegate:
(infobars::InfoBarDelegate*)delegate
frame:(CGRect)frame {
base::scoped_nsobject<UIView<InfoBarViewProtocol>> infoBarView;
translate::TranslateInfoBarDelegate* translateInfoBarDelegate =
delegate->AsTranslateInfoBarDelegate();
......@@ -49,7 +50,7 @@
target:self
action:@selector(infoBarButtonDidPress:)];
}
return infoBarView;
return [[infoBarView retain] autorelease];
}
#pragma mark - Handling of User Events
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment