Commit b103d6c6 authored by stkhapugin's avatar stkhapugin Committed by Commit bot

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

Semi-autogenerated ARCMigrate commit.
Notable issues:
 * Since one of the weak_nsobjects is exposed in a header and I change it to a __weak instead, converted two unit tests to ARC alongside this.
 * Fixed some assignments of newly created views to weak properties by introducing an intermediate local variable to retain the view until it's added as subview.

BUG=624363
TEST=None

Review-Url: https://codereview.chromium.org/2624963003
Cr-Commit-Position: refs/heads/master@{#443240}
parent a8b222fa
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
source_set("history") { source_set("history") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"clear_browsing_bar.h", "clear_browsing_bar.h",
"clear_browsing_bar.mm", "clear_browsing_bar.mm",
...@@ -93,12 +94,10 @@ source_set("unit_tests") { ...@@ -93,12 +94,10 @@ source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"favicon_view_provider_unittest.mm", "favicon_view_provider_unittest.mm",
"history_collection_view_controller_unittest.mm",
"history_entries_status_item_unittest.mm", "history_entries_status_item_unittest.mm",
"history_entry_inserter_unittest.mm", "history_entry_inserter_unittest.mm",
"history_entry_item_unittest.mm", "history_entry_item_unittest.mm",
"history_search_view_controller_unittest.mm", "history_search_view_controller_unittest.mm",
"history_service_facade_unittest.mm",
"history_util_unittest.mm", "history_util_unittest.mm",
"tab_history_popup_controller_unittest.mm", "tab_history_popup_controller_unittest.mm",
] ]
...@@ -133,10 +132,59 @@ source_set("unit_tests") { ...@@ -133,10 +132,59 @@ source_set("unit_tests") {
"//ui/gfx", "//ui/gfx",
"//url", "//url",
] ]
public_deps = [
":unit_tests_arc",
]
allow_circular_includes_from = [ ":unit_tests_arc" ]
}
source_set("unit_tests_arc") {
testonly = true
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"history_collection_view_controller_unittest.mm",
"history_service_facade_unittest.mm",
]
deps = [
":history",
":resources_unit_tests",
"//base",
"//base/test:test_support",
"//components/favicon/core",
"//components/favicon_base",
"//components/history/core/browser",
"//components/keyed_service/core",
"//components/sessions",
"//components/strings",
"//ios/chrome/app/strings",
"//ios/chrome/browser",
"//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/history",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/signin:test_support",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/collection_view",
"//ios/chrome/browser/ui/util",
"//ios/chrome/common",
"//ios/chrome/test:test_support",
"//ios/web",
"//ios/web:test_support",
"//skia",
"//testing/gtest",
"//third_party/ocmock",
"//ui/base",
"//ui/gfx",
"//url",
]
} }
bundle_data("resources_unit_tests") { bundle_data("resources_unit_tests") {
visibility = [ ":unit_tests" ] visibility = [
":unit_tests",
":unit_tests_arc",
]
testonly = true testonly = true
sources = [ sources = [
"//ios/chrome/test/data/favicon/test_favicon.png", "//ios/chrome/test/data/favicon/test_favicon.png",
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#import "ios/chrome/browser/ui/history/clear_browsing_bar.h" #import "ios/chrome/browser/ui/history/clear_browsing_bar.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/objc_property_releaser.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/rtl_geometry.h" #include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
...@@ -13,6 +12,10 @@ ...@@ -13,6 +12,10 @@
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Shadow opacity for the clear browsing bar. // Shadow opacity for the clear browsing bar.
CGFloat kShadowOpacity = 0.2f; CGFloat kShadowOpacity = 0.2f;
...@@ -22,9 +25,7 @@ CGFloat kHorizontalMargin = 8.0f; ...@@ -22,9 +25,7 @@ CGFloat kHorizontalMargin = 8.0f;
typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing }; typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing };
} // namespace } // namespace
@interface ClearBrowsingBar () { @interface ClearBrowsingBar ()
base::mac::ObjCPropertyReleaser propertyReleaser_ClearBrowsingBar_;
}
// Button that displays "Clear Browsing Data...". // Button that displays "Clear Browsing Data...".
@property(nonatomic, strong) UIButton* clearBrowsingDataButton; @property(nonatomic, strong) UIButton* clearBrowsingDataButton;
...@@ -56,27 +57,26 @@ typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing }; ...@@ -56,27 +57,26 @@ typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing };
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
_clearBrowsingDataButton = _clearBrowsingDataButton = [UIButton buttonWithType:UIButtonTypeCustom];
[[UIButton buttonWithType:UIButtonTypeCustom] retain];
[_clearBrowsingDataButton [_clearBrowsingDataButton
setTitle:l10n_util::GetNSStringWithFixup( setTitle:l10n_util::GetNSStringWithFixup(
IDS_HISTORY_OPEN_CLEAR_BROWSING_DATA_DIALOG) IDS_HISTORY_OPEN_CLEAR_BROWSING_DATA_DIALOG)
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[self styleButton:_clearBrowsingDataButton forPlacement:Leading]; [self styleButton:_clearBrowsingDataButton forPlacement:Leading];
_editButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; _editButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_editButton [_editButton
setTitle:l10n_util::GetNSString(IDS_HISTORY_START_EDITING_BUTTON) setTitle:l10n_util::GetNSString(IDS_HISTORY_START_EDITING_BUTTON)
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[self styleButton:_editButton forPlacement:Trailing]; [self styleButton:_editButton forPlacement:Trailing];
_deleteButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_deleteButton setTitle:l10n_util::GetNSString( [_deleteButton setTitle:l10n_util::GetNSString(
IDS_HISTORY_DELETE_SELECTED_ENTRIES_BUTTON) IDS_HISTORY_DELETE_SELECTED_ENTRIES_BUTTON)
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[self styleButton:_deleteButton forPlacement:Leading]; [self styleButton:_deleteButton forPlacement:Leading];
_cancelButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton [_cancelButton
setTitle:l10n_util::GetNSString(IDS_HISTORY_CANCEL_EDITING_BUTTON) setTitle:l10n_util::GetNSString(IDS_HISTORY_CANCEL_EDITING_BUTTON)
forState:UIControlStateNormal]; forState:UIControlStateNormal];
...@@ -106,7 +106,6 @@ typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing }; ...@@ -106,7 +106,6 @@ typedef NS_ENUM(BOOL, ButtonPlacement) { Leading, Trailing };
[self setBackgroundColor:[UIColor whiteColor]]; [self setBackgroundColor:[UIColor whiteColor]];
[[self layer] setShadowOpacity:kShadowOpacity]; [[self layer] setShadowOpacity:kShadowOpacity];
[self setEditing:NO]; [self setEditing:NO];
propertyReleaser_ClearBrowsingBar_.Init(self, [ClearBrowsingBar class]);
} }
return self; return self;
} }
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// Size for the favicon. // Size for the favicon.
@property(nonatomic) CGFloat size; @property(nonatomic) CGFloat size;
// Image view for the favicon. // Image view for the favicon.
@property(nonatomic, retain) UIImageView* faviconImage; @property(nonatomic, strong) UIImageView* faviconImage;
// Label for fallback favicon placeholder. // Label for fallback favicon placeholder.
@property(nonatomic, retain) UILabel* faviconFallbackLabel; @property(nonatomic, strong) UILabel* faviconFallbackLabel;
@end @end
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#import "ios/chrome/browser/ui/history/favicon_view.h" #import "ios/chrome/browser/ui/history/favicon_view.h"
#include "base/mac/objc_property_releaser.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Default corner radius for the favicon image view. // Default corner radius for the favicon image view.
const CGFloat kDefaultCornerRadius = 3; const CGFloat kDefaultCornerRadius = 3;
...@@ -14,7 +17,6 @@ const CGFloat kDefaultCornerRadius = 3; ...@@ -14,7 +17,6 @@ const CGFloat kDefaultCornerRadius = 3;
@interface FaviconView () { @interface FaviconView () {
// Property releaser for FaviconView. // Property releaser for FaviconView.
base::mac::ObjCPropertyReleaser _propertyReleaser_FaviconView;
} }
// Size constraints for the favicon views. // Size constraints for the favicon views.
@property(nonatomic, copy) NSArray* faviconSizeConstraints; @property(nonatomic, copy) NSArray* faviconSizeConstraints;
...@@ -30,7 +32,6 @@ const CGFloat kDefaultCornerRadius = 3; ...@@ -30,7 +32,6 @@ const CGFloat kDefaultCornerRadius = 3;
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
_propertyReleaser_FaviconView.Init(self, [FaviconView class]);
_faviconImage = [[UIImageView alloc] init]; _faviconImage = [[UIImageView alloc] init];
_faviconImage.clipsToBounds = YES; _faviconImage.clipsToBounds = YES;
_faviconImage.layer.cornerRadius = kDefaultCornerRadius; _faviconImage.layer.cornerRadius = kDefaultCornerRadius;
...@@ -51,10 +52,10 @@ const CGFloat kDefaultCornerRadius = 3; ...@@ -51,10 +52,10 @@ const CGFloat kDefaultCornerRadius = 3;
AddSameSizeConstraint(_faviconImage, self); AddSameSizeConstraint(_faviconImage, self);
AddSameCenterConstraints(_faviconFallbackLabel, self); AddSameCenterConstraints(_faviconFallbackLabel, self);
AddSameSizeConstraint(_faviconFallbackLabel, self); AddSameSizeConstraint(_faviconFallbackLabel, self);
_faviconSizeConstraints = [@[ _faviconSizeConstraints = @[
[self.widthAnchor constraintEqualToConstant:0], [self.widthAnchor constraintEqualToConstant:0],
[self.heightAnchor constraintEqualToConstant:0], [self.heightAnchor constraintEqualToConstant:0],
] retain]; ];
[NSLayoutConstraint activateConstraints:_faviconSizeConstraints]; [NSLayoutConstraint activateConstraints:_faviconSizeConstraints];
} }
return self; return self;
......
...@@ -38,7 +38,7 @@ class GURL; ...@@ -38,7 +38,7 @@ class GURL;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
// View that displays a favicon or fallback icon. // View that displays a favicon or fallback icon.
@property(nonatomic, readonly) FaviconView* faviconView; @property(strong, nonatomic, readonly) FaviconView* faviconView;
@end @end
......
...@@ -5,11 +5,8 @@ ...@@ -5,11 +5,8 @@
#import "ios/chrome/browser/ui/history/favicon_view_provider.h" #import "ios/chrome/browser/ui/history/favicon_view_provider.h"
#include "base/i18n/case_conversion.h" #include "base/i18n/case_conversion.h"
#include "base/ios/weak_nsobject.h"
#include "base/mac/bind_objc_block.h" #include "base/mac/bind_objc_block.h"
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#include "base/mac/objc_property_releaser.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -24,30 +21,30 @@ ...@@ -24,30 +21,30 @@
#include "skia/ext/skia_utils_ios.h" #include "skia/ext/skia_utils_ios.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface FaviconViewProvider () { @interface FaviconViewProvider () {
// Property releaser for FaviconViewProvider.
base::mac::ObjCPropertyReleaser _propertyReleaser_FaviconViewProvider;
// Delegate for handling completion of favicon load. // Delegate for handling completion of favicon load.
base::WeakNSProtocol<id<FaviconViewProviderDelegate>> _delegate; __weak id<FaviconViewProviderDelegate> _delegate;
// Used to cancel tasks for the LargeIconService. // Used to cancel tasks for the LargeIconService.
base::CancelableTaskTracker _faviconTaskTracker; base::CancelableTaskTracker _faviconTaskTracker;
// View that renders a favicon or a fallback image.
base::scoped_nsobject<FaviconView> _faviconView;
} }
// Size to render the favicon. // Size to render the favicon.
@property(nonatomic, assign) CGFloat faviconSize; @property(nonatomic, assign) CGFloat faviconSize;
// Favicon image for the favicon view. // Favicon image for the favicon view.
@property(nonatomic, retain) UIImage* favicon; @property(nonatomic, strong) UIImage* favicon;
// Fallback text for the favicon view if there is no appropriately sized // Fallback text for the favicon view if there is no appropriately sized
// favicon availabile. // favicon availabile.
@property(nonatomic, copy) NSString* fallbackText; @property(nonatomic, copy) NSString* fallbackText;
// Fallback background color for the favicon view if there is no appropriately // Fallback background color for the favicon view if there is no appropriately
// sized favicon available. // sized favicon available.
@property(nonatomic, retain) UIColor* fallbackBackgroundColor; @property(nonatomic, strong) UIColor* fallbackBackgroundColor;
// Fallback text color for the favicon view if there is no appropriately // Fallback text color for the favicon view if there is no appropriately
// sized favicon available. // sized favicon available.
@property(nonatomic, retain) UIColor* fallbackTextColor; @property(nonatomic, strong) UIColor* fallbackTextColor;
// Fetches favicon for |URL| from |faviconService|. Notifies delegate when // Fetches favicon for |URL| from |faviconService|. Notifies delegate when
// favicon is retrieved. // favicon is retrieved.
...@@ -65,6 +62,7 @@ ...@@ -65,6 +62,7 @@
@synthesize fallbackText = _fallbackText; @synthesize fallbackText = _fallbackText;
@synthesize fallbackBackgroundColor = _fallbackBackgroundColor; @synthesize fallbackBackgroundColor = _fallbackBackgroundColor;
@synthesize fallbackTextColor = _fallbackTextColor; @synthesize fallbackTextColor = _fallbackTextColor;
@synthesize faviconView = _faviconView;
- (instancetype)initWithURL:(const GURL&)URL - (instancetype)initWithURL:(const GURL&)URL
faviconSize:(CGFloat)faviconSize faviconSize:(CGFloat)faviconSize
...@@ -73,12 +71,10 @@ ...@@ -73,12 +71,10 @@
delegate:(id<FaviconViewProviderDelegate>)delegate { delegate:(id<FaviconViewProviderDelegate>)delegate {
self = [super init]; self = [super init];
if (self) { if (self) {
_propertyReleaser_FaviconViewProvider.Init(self,
[FaviconViewProvider class]);
_faviconSize = faviconSize; _faviconSize = faviconSize;
_delegate.reset(delegate); _delegate = delegate;
_fallbackBackgroundColor = [[UIColor grayColor] retain]; _fallbackBackgroundColor = [UIColor grayColor];
_fallbackTextColor = [[UIColor whiteColor] retain]; _fallbackTextColor = [UIColor whiteColor];
[self fetchFaviconForURL:URL [self fetchFaviconForURL:URL
size:faviconSize size:faviconSize
minSize:minFaviconSize minSize:minFaviconSize
...@@ -98,11 +94,11 @@ ...@@ -98,11 +94,11 @@
service:(favicon::LargeIconService*)largeIconService { service:(favicon::LargeIconService*)largeIconService {
if (!largeIconService) if (!largeIconService)
return; return;
base::WeakNSObject<FaviconViewProvider> weakSelf(self); __weak FaviconViewProvider* weakSelf = self;
GURL blockURL(URL); GURL blockURL(URL);
void (^faviconBlock)(const favicon_base::LargeIconResult&) = ^( void (^faviconBlock)(const favicon_base::LargeIconResult&) = ^(
const favicon_base::LargeIconResult& result) { const favicon_base::LargeIconResult& result) {
base::scoped_nsobject<FaviconViewProvider> strongSelf([weakSelf retain]); FaviconViewProvider* strongSelf = weakSelf;
if (!strongSelf) if (!strongSelf)
return; return;
if (result.bitmap.is_valid()) { if (result.bitmap.is_valid()) {
...@@ -122,36 +118,35 @@ ...@@ -122,36 +118,35 @@
[strongSelf setFallbackText:base::SysUTF16ToNSString( [strongSelf setFallbackText:base::SysUTF16ToNSString(
favicon::GetFallbackIconText(blockURL))]; favicon::GetFallbackIconText(blockURL))];
} }
[strongSelf.get()->_delegate faviconViewProviderFaviconDidLoad:strongSelf]; [strongSelf->_delegate faviconViewProviderFaviconDidLoad:strongSelf];
}; };
// Always call LargeIconService in case the favicon was updated. // Always call LargeIconService in case the favicon was updated.
CGFloat faviconSize = [UIScreen mainScreen].scale * size; CGFloat faviconSize = [UIScreen mainScreen].scale * size;
CGFloat minFaviconSize = [UIScreen mainScreen].scale * minSize; CGFloat minFaviconSize = [UIScreen mainScreen].scale * minSize;
largeIconService->GetLargeIconOrFallbackStyle( largeIconService->GetLargeIconOrFallbackStyle(
URL, minFaviconSize, faviconSize, base::BindBlock(faviconBlock), URL, minFaviconSize, faviconSize, base::BindBlockArc(faviconBlock),
&_faviconTaskTracker); &_faviconTaskTracker);
} }
- (FaviconView*)faviconView { - (FaviconView*)faviconView {
if (!_faviconView) { if (!_faviconView) {
_faviconView.reset([[FaviconView alloc] initWithFrame:CGRectZero]); _faviconView = [[FaviconView alloc] initWithFrame:CGRectZero];
} }
_faviconView.get().size = _faviconSize; _faviconView.size = _faviconSize;
// Update favicon view with current properties. // Update favicon view with current properties.
if (self.favicon) { if (self.favicon) {
_faviconView.get().faviconImage.image = self.favicon; _faviconView.faviconImage.image = self.favicon;
_faviconView.get().faviconImage.backgroundColor = [UIColor whiteColor]; _faviconView.faviconImage.backgroundColor = [UIColor whiteColor];
_faviconView.get().faviconFallbackLabel.text = nil; _faviconView.faviconFallbackLabel.text = nil;
} else { } else {
_faviconView.get().faviconImage.image = nil; _faviconView.faviconImage.image = nil;
_faviconView.get().faviconImage.backgroundColor = _faviconView.faviconImage.backgroundColor = self.fallbackBackgroundColor;
self.fallbackBackgroundColor; _faviconView.faviconFallbackLabel.text = self.fallbackText;
_faviconView.get().faviconFallbackLabel.text = self.fallbackText; _faviconView.faviconFallbackLabel.textColor = self.fallbackTextColor;
_faviconView.get().faviconFallbackLabel.textColor = self.fallbackTextColor;
CGFloat fontSize = floorf(_faviconSize / 2); CGFloat fontSize = floorf(_faviconSize / 2);
_faviconView.get().faviconFallbackLabel.font = _faviconView.faviconFallbackLabel.font =
[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:fontSize]; [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:fontSize];
} }
return _faviconView; return _faviconView;
......
...@@ -8,10 +8,7 @@ ...@@ -8,10 +8,7 @@
#include <memory> #include <memory>
#import "base/ios/weak_nsobject.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "base/mac/objc_property_releaser.h"
#include "base/mac/scoped_nsobject.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h" #include "base/metrics/user_metrics_action.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -40,6 +37,7 @@ ...@@ -40,6 +37,7 @@
#include "ios/chrome/browser/ui/history/history_util.h" #include "ios/chrome/browser/ui/history/history_util.h"
#import "ios/chrome/browser/ui/url_loader.h" #import "ios/chrome/browser/ui/url_loader.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MDCActivityIndicator.h"
#import "ios/third_party/material_components_ios/src/components/Collections/src/MaterialCollections.h" #import "ios/third_party/material_components_ios/src/components/Collections/src/MaterialCollections.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h" #import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
#import "ios/web/public/referrer.h" #import "ios/web/public/referrer.h"
...@@ -48,6 +46,10 @@ ...@@ -48,6 +46,10 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
typedef NS_ENUM(NSInteger, ItemType) { typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeHistoryEntry = kItemTypeEnumZero, ItemTypeHistoryEntry = kItemTypeEnumZero,
...@@ -66,30 +68,27 @@ const CGFloat kSeparatorInset = 10; ...@@ -66,30 +68,27 @@ const CGFloat kSeparatorInset = 10;
HistoryEntryInserterDelegate, HistoryEntryInserterDelegate,
HistoryEntryItemDelegate, HistoryEntryItemDelegate,
HistoryServiceFacadeDelegate> { HistoryServiceFacadeDelegate> {
base::mac::ObjCPropertyReleaser
_propertyReleaser_HistoryCollectionViewController;
// Facade for communicating with HistoryService and WebHistoryService. // Facade for communicating with HistoryService and WebHistoryService.
std::unique_ptr<HistoryServiceFacade> _historyServiceFacade; std::unique_ptr<HistoryServiceFacade> _historyServiceFacade;
// The main browser state. Not owned by HistoryCollectionViewController. // The main browser state. Not owned by HistoryCollectionViewController.
ios::ChromeBrowserState* _browserState; ios::ChromeBrowserState* _browserState;
// Backing ivar for delegate property. // Backing ivar for delegate property.
base::WeakNSProtocol<id<HistoryCollectionViewControllerDelegate>> _delegate; __weak id<HistoryCollectionViewControllerDelegate> _delegate;
// Backing ivar for URLLoader property. // Backing ivar for URLLoader property.
base::WeakNSProtocol<id<UrlLoader>> _URLLoader; __weak id<UrlLoader> _URLLoader;
} }
// Object to manage insertion of history entries into the collection view model. // Object to manage insertion of history entries into the collection view model.
@property(nonatomic, retain) HistoryEntryInserter* entryInserter; @property(nonatomic, strong) HistoryEntryInserter* entryInserter;
// Delegate for the history collection view. // Delegate for the history collection view.
@property(nonatomic, assign, readonly) @property(nonatomic, weak, readonly) id<HistoryCollectionViewControllerDelegate>
id<HistoryCollectionViewControllerDelegate>
delegate; delegate;
// UrlLoader for navigating to history entries. // UrlLoader for navigating to history entries.
@property(nonatomic, assign, readonly) id<UrlLoader> URLLoader; @property(nonatomic, weak, readonly) id<UrlLoader> URLLoader;
// The current query for visible history entries. // The current query for visible history entries.
@property(nonatomic, copy) NSString* currentQuery; @property(nonatomic, copy) NSString* currentQuery;
// Coordinator for displaying context menus for history entries. // Coordinator for displaying context menus for history entries.
@property(nonatomic, assign) ContextMenuCoordinator* contextMenuCoordinator; @property(nonatomic, strong) ContextMenuCoordinator* contextMenuCoordinator;
// Type of displayed history entries. Entries can be synced or local, or there // Type of displayed history entries. Entries can be synced or local, or there
// may be no history entries. // may be no history entries.
@property(nonatomic, assign) HistoryEntriesStatus entriesType; @property(nonatomic, assign) HistoryEntriesStatus entriesType;
...@@ -151,12 +150,10 @@ const CGFloat kSeparatorInset = 10; ...@@ -151,12 +150,10 @@ const CGFloat kSeparatorInset = 10;
delegate { delegate {
self = [super initWithStyle:CollectionViewControllerStyleDefault]; self = [super initWithStyle:CollectionViewControllerStyleDefault];
if (self) { if (self) {
_propertyReleaser_HistoryCollectionViewController.Init(
self, [HistoryCollectionViewController class]);
_historyServiceFacade.reset(new HistoryServiceFacade(browserState, self)); _historyServiceFacade.reset(new HistoryServiceFacade(browserState, self));
_browserState = browserState; _browserState = browserState;
_delegate.reset(delegate); _delegate = delegate;
_URLLoader.reset(loader); _URLLoader = loader;
[self loadModel]; [self loadModel];
// Add initial info section as header. // Add initial info section as header.
[self.collectionViewModel [self.collectionViewModel
...@@ -181,10 +178,10 @@ const CGFloat kSeparatorInset = 10; ...@@ -181,10 +178,10 @@ const CGFloat kSeparatorInset = 10;
self.collectionView.keyboardDismissMode = self.collectionView.keyboardDismissMode =
UIScrollViewKeyboardDismissModeOnDrag; UIScrollViewKeyboardDismissModeOnDrag;
base::scoped_nsobject<UILongPressGestureRecognizer> longPressRecognizer([ UILongPressGestureRecognizer* longPressRecognizer = [
[UILongPressGestureRecognizer alloc] [UILongPressGestureRecognizer alloc]
initWithTarget:self initWithTarget:self
action:@selector(displayContextMenuInvokedByGestureRecognizer:)]); action:@selector(displayContextMenuInvokedByGestureRecognizer:)];
[self.collectionView addGestureRecognizer:longPressRecognizer]; [self.collectionView addGestureRecognizer:longPressRecognizer];
} }
...@@ -357,19 +354,17 @@ const CGFloat kSeparatorInset = 10; ...@@ -357,19 +354,17 @@ const CGFloat kSeparatorInset = 10;
// loading indicator removal will not be observed. // loading indicator removal will not be observed.
[self updateEntriesStatusMessage]; [self updateEntriesStatusMessage];
__block base::scoped_nsobject<NSMutableArray> filterResults( __block NSMutableArray* filterResults = [NSMutableArray array];
[[NSMutableArray array] retain]); __block NSString* searchQuery = [base::SysUTF16ToNSString(result.query) copy];
__block base::scoped_nsobject<NSString> searchQuery(
[base::SysUTF16ToNSString(result.query) copy]);
[self.collectionView performBatchUpdates:^{ [self.collectionView performBatchUpdates:^{
// There should always be at least a header section present. // There should always be at least a header section present.
DCHECK([[self collectionViewModel] numberOfSections]); DCHECK([[self collectionViewModel] numberOfSections]);
for (const history::HistoryEntry& entry : entries) { for (const history::HistoryEntry& entry : entries) {
HistoryEntryItem* item = HistoryEntryItem* item =
[[[HistoryEntryItem alloc] initWithType:ItemTypeHistoryEntry [[HistoryEntryItem alloc] initWithType:ItemTypeHistoryEntry
historyEntry:entry historyEntry:entry
browserState:_browserState browserState:_browserState
delegate:self] autorelease]; delegate:self];
[self.entryInserter insertHistoryEntryItem:item]; [self.entryInserter insertHistoryEntryItem:item];
if ([self isSearching] || self.filterQueryResult) { if ([self isSearching] || self.filterQueryResult) {
[filterResults addObject:item]; [filterResults addObject:item];
...@@ -573,16 +568,15 @@ const CGFloat kSeparatorInset = 10; ...@@ -573,16 +568,15 @@ const CGFloat kSeparatorInset = 10;
- (void)updateEntriesStatusMessage { - (void)updateEntriesStatusMessage {
CollectionViewItem* entriesStatusItem = nil; CollectionViewItem* entriesStatusItem = nil;
if (!self.hasHistoryEntries) { if (!self.hasHistoryEntries) {
CollectionViewTextItem* noResultsItem = [[[CollectionViewTextItem alloc] CollectionViewTextItem* noResultsItem =
initWithType:ItemTypeEntriesStatus] autorelease]; [[CollectionViewTextItem alloc] initWithType:ItemTypeEntriesStatus];
noResultsItem.text = noResultsItem.text =
self.isSearching ? l10n_util::GetNSString(IDS_HISTORY_NO_SEARCH_RESULTS) self.isSearching ? l10n_util::GetNSString(IDS_HISTORY_NO_SEARCH_RESULTS)
: l10n_util::GetNSString(IDS_HISTORY_NO_RESULTS); : l10n_util::GetNSString(IDS_HISTORY_NO_RESULTS);
entriesStatusItem = noResultsItem; entriesStatusItem = noResultsItem;
} else { } else {
HistoryEntriesStatusItem* historyEntriesStatusItem = HistoryEntriesStatusItem* historyEntriesStatusItem =
[[[HistoryEntriesStatusItem alloc] initWithType:ItemTypeEntriesStatus] [[HistoryEntriesStatusItem alloc] initWithType:ItemTypeEntriesStatus];
autorelease];
historyEntriesStatusItem.delegate = self; historyEntriesStatusItem.delegate = self;
AuthenticationService* authService = AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(_browserState); AuthenticationServiceFactory::GetForBrowserState(_browserState);
...@@ -691,8 +685,8 @@ const CGFloat kSeparatorInset = 10; ...@@ -691,8 +685,8 @@ const CGFloat kSeparatorInset = 10;
fromSectionWithIdentifier:kSectionIdentifierEnumZero]; fromSectionWithIdentifier:kSectionIdentifierEnumZero];
[self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]];
} }
CollectionViewItem* loadingIndicatorItem = [[[CollectionViewItem alloc] CollectionViewItem* loadingIndicatorItem =
initWithType:ItemTypeActivityIndicator] autorelease]; [[CollectionViewItem alloc] initWithType:ItemTypeActivityIndicator];
loadingIndicatorItem.cellClass = [ActivityIndicatorCell class]; loadingIndicatorItem.cellClass = [ActivityIndicatorCell class];
[self.collectionViewModel addItem:loadingIndicatorItem [self.collectionViewModel addItem:loadingIndicatorItem
toSectionWithIdentifier:kEntriesStatusSectionIdentifier]; toSectionWithIdentifier:kEntriesStatusSectionIdentifier];
...@@ -724,10 +718,10 @@ const CGFloat kSeparatorInset = 10; ...@@ -724,10 +718,10 @@ const CGFloat kSeparatorInset = 10;
HistoryEntryItem* entry = base::mac::ObjCCastStrict<HistoryEntryItem>( HistoryEntryItem* entry = base::mac::ObjCCastStrict<HistoryEntryItem>(
[self.collectionViewModel itemAtIndexPath:touchedItemIndexPath]); [self.collectionViewModel itemAtIndexPath:touchedItemIndexPath]);
base::WeakNSObject<HistoryCollectionViewController> weakSelf(self); __weak HistoryCollectionViewController* weakSelf = self;
web::ContextMenuParams params; web::ContextMenuParams params;
params.location = touchLocation; params.location = touchLocation;
params.view.reset([self.collectionView retain]); params.view.reset(self.collectionView);
NSString* menuTitle = NSString* menuTitle =
base::SysUTF16ToNSString(url_formatter::FormatUrl(entry.URL)); base::SysUTF16ToNSString(url_formatter::FormatUrl(entry.URL));
params.menu_title.reset([menuTitle copy]); params.menu_title.reset([menuTitle copy]);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <memory> #include <memory>
#import "base/mac/scoped_nsobject.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "base/time/time.h" #include "base/time/time.h"
...@@ -61,31 +60,27 @@ class HistoryCollectionViewControllerTest : public BlockCleanupTest { ...@@ -61,31 +60,27 @@ class HistoryCollectionViewControllerTest : public BlockCleanupTest {
AuthenticationServiceFactory::GetInstance(), AuthenticationServiceFactory::GetInstance(),
AuthenticationServiceFake::CreateAuthenticationService); AuthenticationServiceFake::CreateAuthenticationService);
mock_browser_state_ = builder.Build(); mock_browser_state_ = builder.Build();
mock_delegate_.reset([[OCMockObject mock_delegate_ = [OCMockObject
niceMockForProtocol:@protocol(HistoryCollectionViewControllerDelegate)] niceMockForProtocol:@protocol(HistoryCollectionViewControllerDelegate)];
retain]); mock_url_loader_ = [OCMockObject niceMockForProtocol:@protocol(UrlLoader)];
mock_url_loader_.reset( history_collection_view_controller_ =
[[OCMockObject niceMockForProtocol:@protocol(UrlLoader)] retain]);
history_collection_view_controller_.reset(
[[HistoryCollectionViewController alloc] [[HistoryCollectionViewController alloc]
initWithLoader:mock_url_loader_ initWithLoader:mock_url_loader_
browserState:mock_browser_state_.get() browserState:mock_browser_state_.get()
delegate:mock_delegate_]); delegate:mock_delegate_];
} }
void TearDown() override { void TearDown() override {
history_collection_view_controller_.reset(); history_collection_view_controller_ = nil;
BlockCleanupTest::TearDown(); BlockCleanupTest::TearDown();
} }
protected: protected:
web::TestWebThreadBundle thread_bundle_; web::TestWebThreadBundle thread_bundle_;
base::scoped_nsprotocol<id<UrlLoader>> mock_url_loader_; id<UrlLoader> mock_url_loader_;
std::unique_ptr<TestChromeBrowserState> mock_browser_state_; std::unique_ptr<TestChromeBrowserState> mock_browser_state_;
base::scoped_nsprotocol<id<HistoryCollectionViewControllerDelegate>> id<HistoryCollectionViewControllerDelegate> mock_delegate_;
mock_delegate_; HistoryCollectionViewController* history_collection_view_controller_;
base::scoped_nsobject<HistoryCollectionViewController>
history_collection_view_controller_;
bool privacy_settings_opened_; bool privacy_settings_opened_;
DISALLOW_COPY_AND_ASSIGN(HistoryCollectionViewControllerTest); DISALLOW_COPY_AND_ASSIGN(HistoryCollectionViewControllerTest);
}; };
......
...@@ -38,7 +38,7 @@ class GURL; ...@@ -38,7 +38,7 @@ class GURL;
// YES if message for other forms of browsing data should be shown. // YES if message for other forms of browsing data should be shown.
@property(nonatomic, assign) BOOL showsOtherBrowsingDataNotice; @property(nonatomic, assign) BOOL showsOtherBrowsingDataNotice;
// Delegate for HistoryEntriesStatusItem. Is notified when a link is pressed. // Delegate for HistoryEntriesStatusItem. Is notified when a link is pressed.
@property(nonatomic, assign) id<HistoryEntriesStatusItemDelegate> delegate; @property(nonatomic, weak) id<HistoryEntriesStatusItemDelegate> delegate;
@end @end
// Cell for displaying status for history entry. Provides information on whether // Cell for displaying status for history entry. Provides information on whether
......
...@@ -4,9 +4,7 @@ ...@@ -4,9 +4,7 @@
#import "ios/chrome/browser/ui/history/history_entries_status_item.h" #import "ios/chrome/browser/ui/history/history_entries_status_item.h"
#include "base/ios/weak_nsobject.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "base/mac/objc_property_releaser.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item.h"
...@@ -18,6 +16,10 @@ ...@@ -18,6 +16,10 @@
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Delegate for HistoryEntriesStatusCell. // Delegate for HistoryEntriesStatusCell.
@protocol HistoryEntriesStatusCellDelegate<NSObject> @protocol HistoryEntriesStatusCellDelegate<NSObject>
// Notifies the delegate that |URL| should be opened. // Notifies the delegate that |URL| should be opened.
...@@ -25,33 +27,25 @@ ...@@ -25,33 +27,25 @@
didRequestOpenURL:(const GURL&)URL; didRequestOpenURL:(const GURL&)URL;
@end @end
@interface HistoryEntriesStatusCell () { @interface HistoryEntriesStatusCell ()
// Property releaser for HistoryEntriesStatusItem.
base::mac::ObjCPropertyReleaser _propertyReleaser_HistoryEntriesStatusCell;
// Delegate for the HistoryEntriesStatusCell. Is notified when a link is
// tapped.
base::WeakNSProtocol<id<HistoryEntriesStatusCellDelegate>> _delegate;
}
// Redeclare as readwrite. // Redeclare as readwrite.
@property(nonatomic, retain, readwrite) @property(nonatomic, strong, readwrite)
LabelLinkController* labelLinkController; LabelLinkController* labelLinkController;
// Delegate for the HistoryEntriesStatusCell. Is notified when a link is // Delegate for the HistoryEntriesStatusCell. Is notified when a link is
// tapped. // tapped.
@property(nonatomic, assign) id<HistoryEntriesStatusCellDelegate> delegate; // Delegate for the HistoryEntriesStatusCell. Is notified when a link is
// tapped.
@property(nonatomic, weak) id<HistoryEntriesStatusCellDelegate> delegate;
// Sets links on the cell label. // Sets links on the cell label.
- (void)setLinksForSyncURL:(const GURL&)syncURL - (void)setLinksForSyncURL:(const GURL&)syncURL
browsingDataURL:(const GURL&)browsingDataURL; browsingDataURL:(const GURL&)browsingDataURL;
@end @end
@interface HistoryEntriesStatusItem ()<HistoryEntriesStatusCellDelegate> { @interface HistoryEntriesStatusItem ()<HistoryEntriesStatusCellDelegate>
// Delegate for the HistoryEntriesStatusItem. Is notified when a link is
// tapped.
base::WeakNSProtocol<id<HistoryEntriesStatusItemDelegate>> _delegate;
}
@end @end
@implementation HistoryEntriesStatusItem @implementation HistoryEntriesStatusItem
@synthesize delegate = _delegate;
@synthesize entriesStatus = _entriesStatus; @synthesize entriesStatus = _entriesStatus;
@synthesize hidden = _hidden; @synthesize hidden = _hidden;
@synthesize showsOtherBrowsingDataNotice = _showsOtherBrowsingDataNotice; @synthesize showsOtherBrowsingDataNotice = _showsOtherBrowsingDataNotice;
...@@ -112,14 +106,6 @@ ...@@ -112,14 +106,6 @@
browsingDataURL:otherBrowsingDataURL]; browsingDataURL:otherBrowsingDataURL];
} }
- (void)setDelegate:(id<HistoryEntriesStatusItemDelegate>)delegate {
_delegate.reset(delegate);
}
- (id<HistoryEntriesStatusItemDelegate>)delegate {
return _delegate;
}
- (void)historyEntriesStatusCell:(HistoryEntriesStatusCell*)cell - (void)historyEntriesStatusCell:(HistoryEntriesStatusCell*)cell
didRequestOpenURL:(const GURL&)URL { didRequestOpenURL:(const GURL&)URL {
[self.delegate historyEntriesStatusItem:self didRequestOpenURL:URL]; [self.delegate historyEntriesStatusItem:self didRequestOpenURL:URL];
...@@ -146,27 +132,18 @@ ...@@ -146,27 +132,18 @@
@end @end
@implementation HistoryEntriesStatusCell @implementation HistoryEntriesStatusCell
@synthesize delegate = _delegate;
@synthesize labelLinkController = _labelLinkController; @synthesize labelLinkController = _labelLinkController;
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_propertyReleaser_HistoryEntriesStatusCell.Init(
self, [HistoryEntriesStatusCell class]);
}
return self;
}
- (void)setLinksForSyncURL:(const GURL&)syncURL - (void)setLinksForSyncURL:(const GURL&)syncURL
browsingDataURL:(const GURL&)browsingDataURL { browsingDataURL:(const GURL&)browsingDataURL {
base::WeakNSObject<HistoryEntriesStatusCell> weakSelf(self); __weak HistoryEntriesStatusCell* weakSelf = self;
self.labelLinkController = [[[LabelLinkController alloc] self.labelLinkController = [[LabelLinkController alloc]
initWithLabel:self.textLabel initWithLabel:self.textLabel
action:^(const GURL& URL) { action:^(const GURL& URL) {
[[weakSelf delegate] historyEntriesStatusCell:weakSelf [[weakSelf delegate] historyEntriesStatusCell:weakSelf
didRequestOpenURL:URL]; didRequestOpenURL:URL];
}] autorelease]; }];
[self.labelLinkController setLinkColor:[[MDCPalette cr_bluePalette] tint500]]; [self.labelLinkController setLinkColor:[[MDCPalette cr_bluePalette] tint500]];
// Remove link delimiters from text and get ranges for links. Both links // Remove link delimiters from text and get ranges for links. Both links
...@@ -196,14 +173,6 @@ ...@@ -196,14 +173,6 @@
} }
} }
- (void)setDelegate:(id<HistoryEntriesStatusCellDelegate>)delegate {
_delegate.reset(delegate);
}
- (id<HistoryEntriesStatusCellDelegate>)delegate {
return _delegate;
}
- (void)prepareForReuse { - (void)prepareForReuse {
[super prepareForReuse]; [super prepareForReuse];
self.labelLinkController = nil; self.labelLinkController = nil;
......
...@@ -36,7 +36,7 @@ class Time; ...@@ -36,7 +36,7 @@ class Time;
// Delegate for the HistoryEntryInserter. Receives callbacks upon item and // Delegate for the HistoryEntryInserter. Receives callbacks upon item and
// section insertion and removal. // section insertion and removal.
@property(nonatomic, assign) id<HistoryEntryInserterDelegate> delegate; @property(nonatomic, weak) id<HistoryEntryInserterDelegate> delegate;
// Designated initializer for HistoryEntryInserter. collectionViewModel is the // Designated initializer for HistoryEntryInserter. collectionViewModel is the
// model into which entries are inserted. Sections for history entries are // model into which entries are inserted. Sections for history entries are
......
...@@ -4,9 +4,7 @@ ...@@ -4,9 +4,7 @@
#import "ios/chrome/browser/ui/history/history_entry_inserter.h" #import "ios/chrome/browser/ui/history/history_entry_inserter.h"
#import "base/ios/weak_nsobject.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h" #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h"
...@@ -15,42 +13,38 @@ ...@@ -15,42 +13,38 @@
#include "ios/chrome/browser/ui/history/history_util.h" #include "ios/chrome/browser/ui/history/history_util.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface HistoryEntryInserter () { @interface HistoryEntryInserter () {
// Delegate for the HistoryEntryInserter.
base::WeakNSProtocol<id<HistoryEntryInserterDelegate>> _delegate;
// CollectionViewModel in which to insert history entries. // CollectionViewModel in which to insert history entries.
base::scoped_nsobject<CollectionViewModel> _collectionViewModel; CollectionViewModel* _collectionViewModel;
// The index of the first section to contain history entries. // The index of the first section to contain history entries.
NSInteger _firstSectionIndex; NSInteger _firstSectionIndex;
// Number of assigned section identifiers. // Number of assigned section identifiers.
NSInteger _sectionIdentifierCount; NSInteger _sectionIdentifierCount;
// Sorted set of dates that have history entries. // Sorted set of dates that have history entries.
base::scoped_nsobject<NSMutableOrderedSet> _dates; NSMutableOrderedSet* _dates;
// Mapping from dates to section identifiers. // Mapping from dates to section identifiers.
base::scoped_nsobject<NSMutableDictionary> _sectionIdentifiers; NSMutableDictionary* _sectionIdentifiers;
} }
@end @end
@implementation HistoryEntryInserter @implementation HistoryEntryInserter
@synthesize delegate = _delegate;
- (instancetype)initWithModel:(CollectionViewModel*)collectionViewModel { - (instancetype)initWithModel:(CollectionViewModel*)collectionViewModel {
if ((self = [super init])) { if ((self = [super init])) {
_collectionViewModel.reset([collectionViewModel retain]); _collectionViewModel = collectionViewModel;
_firstSectionIndex = [collectionViewModel numberOfSections]; _firstSectionIndex = [collectionViewModel numberOfSections];
_dates.reset([[NSMutableOrderedSet alloc] init]); _dates = [[NSMutableOrderedSet alloc] init];
_sectionIdentifiers.reset([[NSMutableDictionary dictionary] retain]); _sectionIdentifiers = [NSMutableDictionary dictionary];
} }
return self; return self;
} }
- (id<HistoryEntryInserterDelegate>)delegate {
return _delegate;
}
- (void)setDelegate:(id<HistoryEntryInserterDelegate>)delegate {
_delegate.reset(delegate);
}
- (void)insertHistoryEntryItem:(HistoryEntryItem*)item { - (void)insertHistoryEntryItem:(HistoryEntryItem*)item {
NSInteger sectionIdentifier = NSInteger sectionIdentifier =
...@@ -126,8 +120,8 @@ ...@@ -126,8 +120,8 @@
usingComparator:comparator]; usingComparator:comparator];
[_dates insertObject:date atIndex:index]; [_dates insertObject:date atIndex:index];
NSInteger insertionIndex = _firstSectionIndex + index; NSInteger insertionIndex = _firstSectionIndex + index;
CollectionViewTextItem* header = [[[CollectionViewTextItem alloc] CollectionViewTextItem* header =
initWithType:kItemTypeEnumZero] autorelease]; [[CollectionViewTextItem alloc] initWithType:kItemTypeEnumZero];
header.text = header.text =
base::SysUTF16ToNSString(history::GetRelativeDateLocalized(timestamp)); base::SysUTF16ToNSString(history::GetRelativeDateLocalized(timestamp));
[_collectionViewModel insertSectionWithIdentifier:sectionIdentifier [_collectionViewModel insertSectionWithIdentifier:sectionIdentifier
......
...@@ -75,13 +75,13 @@ class GURL; ...@@ -75,13 +75,13 @@ class GURL;
@interface HistoryEntryCell : MDCCollectionViewCell @interface HistoryEntryCell : MDCCollectionViewCell
// View for displaying the favicon for the history entry. // View for displaying the favicon for the history entry.
@property(nonatomic, retain) UIView* faviconViewContainer; @property(nonatomic, strong) UIView* faviconViewContainer;
// Text label for history entry title. // Text label for history entry title.
@property(nonatomic, readonly, retain) UILabel* textLabel; @property(nonatomic, readonly, strong) UILabel* textLabel;
// Text label for history entry URL. // Text label for history entry URL.
@property(nonatomic, readonly, retain) UILabel* detailTextLabel; @property(nonatomic, readonly, strong) UILabel* detailTextLabel;
// Text label for history entry timestamp. // Text label for history entry timestamp.
@property(nonatomic, readonly, retain) UILabel* timeLabel; @property(nonatomic, readonly, strong) UILabel* timeLabel;
@end @end
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
#import "ios/chrome/browser/ui/history/history_entry_item.h" #import "ios/chrome/browser/ui/history/history_entry_item.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/ios/weak_nsobject.h"
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#import "base/mac/objc_property_releaser.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/history/core/browser/url_row.h" #include "components/history/core/browser/url_row.h"
...@@ -24,6 +22,10 @@ ...@@ -24,6 +22,10 @@
#import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h" #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Size at which the favicon will be displayed. // Size at which the favicon will be displayed.
const CGFloat kFaviconSize = 24.0; const CGFloat kFaviconSize = 24.0;
...@@ -59,14 +61,12 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) { ...@@ -59,14 +61,12 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) {
#pragma mark - HistoryEntryItem #pragma mark - HistoryEntryItem
@interface HistoryEntryItem ()<FaviconViewProviderDelegate> { @interface HistoryEntryItem ()<FaviconViewProviderDelegate> {
// Property releaser for HistoryEntryItem.
base::mac::ObjCPropertyReleaser _propertyReleaser_HistoryEntryItem;
// Delegate for HistoryEntryItem. // Delegate for HistoryEntryItem.
base::WeakNSProtocol<id<HistoryEntryItemDelegate>> _delegate; __weak id<HistoryEntryItemDelegate> _delegate;
} }
// FaviconViewProvider to fetch the favicon and format the favicon view. // FaviconViewProvider to fetch the favicon and format the favicon view.
@property(nonatomic, retain) FaviconViewProvider* faviconViewProvider; @property(nonatomic, strong) FaviconViewProvider* faviconViewProvider;
// Custom accessibility actions for the history entry view. // Custom accessibility actions for the history entry view.
- (NSArray*)accessibilityActions; - (NSArray*)accessibilityActions;
...@@ -96,7 +96,6 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) { ...@@ -96,7 +96,6 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) {
delegate:(id<HistoryEntryItemDelegate>)delegate { delegate:(id<HistoryEntryItemDelegate>)delegate {
self = [super initWithType:type]; self = [super initWithType:type];
if (self) { if (self) {
_propertyReleaser_HistoryEntryItem.Init(self, [HistoryEntryItem class]);
self.cellClass = [HistoryEntryCell class]; self.cellClass = [HistoryEntryCell class];
favicon::LargeIconService* largeIconService = favicon::LargeIconService* largeIconService =
IOSChromeLargeIconServiceFactory::GetForBrowserState(browserState); IOSChromeLargeIconServiceFactory::GetForBrowserState(browserState);
...@@ -112,7 +111,7 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) { ...@@ -112,7 +111,7 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) {
[base::SysUTF16ToNSString(base::TimeFormatTimeOfDay(entry.time)) copy]; [base::SysUTF16ToNSString(base::TimeFormatTimeOfDay(entry.time)) copy];
_URL = GURL(entry.url); _URL = GURL(entry.url);
_timestamp = entry.time; _timestamp = entry.time;
_delegate.reset(delegate); _delegate = delegate;
} }
return self; return self;
} }
...@@ -143,28 +142,28 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) { ...@@ -143,28 +142,28 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) {
- (NSArray*)accessibilityActions { - (NSArray*)accessibilityActions {
UIAccessibilityCustomAction* deleteAction = UIAccessibilityCustomAction* deleteAction =
[[[UIAccessibilityCustomAction alloc] [[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString( initWithName:l10n_util::GetNSString(
IDS_HISTORY_ENTRY_ACCESSIBILITY_DELETE) IDS_HISTORY_ENTRY_ACCESSIBILITY_DELETE)
target:self target:self
selector:@selector(deleteHistoryEntry)] autorelease]; selector:@selector(deleteHistoryEntry)];
UIAccessibilityCustomAction* openInNewTabAction = UIAccessibilityCustomAction* openInNewTabAction =
[[[UIAccessibilityCustomAction alloc] [[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString( initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)
target:self target:self
selector:@selector(openInNewTab)] autorelease]; selector:@selector(openInNewTab)];
UIAccessibilityCustomAction* openInNewIncognitoTabAction = UIAccessibilityCustomAction* openInNewIncognitoTabAction =
[[[UIAccessibilityCustomAction alloc] [[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString( initWithName:l10n_util::GetNSString(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)
target:self target:self
selector:@selector(openInNewIncognitoTab)] autorelease]; selector:@selector(openInNewIncognitoTab)];
UIAccessibilityCustomAction* copyURLAction = UIAccessibilityCustomAction* copyURLAction =
[[[UIAccessibilityCustomAction alloc] [[UIAccessibilityCustomAction alloc]
initWithName:l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_COPY) initWithName:l10n_util::GetNSString(IDS_IOS_CONTENT_CONTEXT_COPY)
target:self target:self
selector:@selector(copyURL)] autorelease]; selector:@selector(copyURL)];
return @[ return @[
deleteAction, openInNewTabAction, openInNewIncognitoTabAction, copyURLAction deleteAction, openInNewTabAction, openInNewIncognitoTabAction, copyURLAction
]; ];
...@@ -220,15 +219,12 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) { ...@@ -220,15 +219,12 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) {
#pragma mark - HistoryEntryCell #pragma mark - HistoryEntryCell
@interface HistoryEntryCell () { @interface HistoryEntryCell ()
// Property releaser for HistoryEntryCell.
base::mac::ObjCPropertyReleaser _propertyReleaser_HistoryEntryCell;
}
// Redeclare as readwrite to allow property releaser to handle these properties. // Redeclare as readwrite.
@property(nonatomic, readwrite, retain) UILabel* textLabel; @property(nonatomic, readwrite, strong) UILabel* textLabel;
@property(nonatomic, readwrite, retain) UILabel* detailTextLabel; @property(nonatomic, readwrite, strong) UILabel* detailTextLabel;
@property(nonatomic, readwrite, retain) UILabel* timeLabel; @property(nonatomic, readwrite, strong) UILabel* timeLabel;
@end @end
@implementation HistoryEntryCell @implementation HistoryEntryCell
...@@ -241,7 +237,6 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) { ...@@ -241,7 +237,6 @@ NSString* FormattedTitle(const base::string16& title, const GURL& url) {
- (id)initWithFrame:(CGRect)frame { - (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
_propertyReleaser_HistoryEntryCell.Init(self, [HistoryEntryCell class]);
_faviconViewContainer = [[UIView alloc] initWithFrame:CGRectZero]; _faviconViewContainer = [[UIView alloc] initWithFrame:CGRectZero];
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
#import "ios/chrome/browser/ui/history/history_search_view.h" #import "ios/chrome/browser/ui/history/history_search_view.h"
#include "base/mac/objc_property_releaser.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/uikit_ui_util.h" #include "ios/chrome/browser/ui/uikit_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Shadow opacity for the search view. // Shadow opacity for the search view.
CGFloat kShadowOpacity = 0.2f; CGFloat kShadowOpacity = 0.2f;
...@@ -17,9 +20,7 @@ CGFloat kShadowOpacity = 0.2f; ...@@ -17,9 +20,7 @@ CGFloat kShadowOpacity = 0.2f;
CGFloat kHorizontalMargin = 16.0f; CGFloat kHorizontalMargin = 16.0f;
} // namespace } // namespace
@interface HistorySearchView () { @interface HistorySearchView ()
base::mac::ObjCPropertyReleaser propertyReleaser_HistorySearchView_;
}
// Stack view for laying out the text field and cancel button. // Stack view for laying out the text field and cancel button.
@property(nonatomic, strong) UIStackView* stackView; @property(nonatomic, strong) UIStackView* stackView;
...@@ -58,7 +59,7 @@ CGFloat kHorizontalMargin = 16.0f; ...@@ -58,7 +59,7 @@ CGFloat kHorizontalMargin = 16.0f;
_textField.clearButtonMode = UITextFieldViewModeAlways; _textField.clearButtonMode = UITextFieldViewModeAlways;
_textField.placeholder = l10n_util::GetNSString(IDS_HISTORY_SEARCH_BUTTON); _textField.placeholder = l10n_util::GetNSString(IDS_HISTORY_SEARCH_BUTTON);
_cancelButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setImage:[UIImage imageNamed:@"collapse"] [_cancelButton setImage:[UIImage imageNamed:@"collapse"]
forState:UIControlStateNormal]; forState:UIControlStateNormal];
[_cancelButton setImage:[UIImage imageNamed:@"collapse_pressed"] [_cancelButton setImage:[UIImage imageNamed:@"collapse_pressed"]
...@@ -81,9 +82,9 @@ CGFloat kHorizontalMargin = 16.0f; ...@@ -81,9 +82,9 @@ CGFloat kHorizontalMargin = 16.0f;
_stackView.layoutMarginsRelativeArrangement = YES; _stackView.layoutMarginsRelativeArrangement = YES;
CGFloat topAnchorConstant = IsCompact() ? StatusBarHeight() : 0; CGFloat topAnchorConstant = IsCompact() ? StatusBarHeight() : 0;
_topAnchorConstraint = [[_stackView.topAnchor _topAnchorConstraint =
constraintEqualToAnchor:self.topAnchor [_stackView.topAnchor constraintEqualToAnchor:self.topAnchor
constant:topAnchorConstant] retain]; constant:topAnchorConstant];
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
_topAnchorConstraint, _topAnchorConstraint,
[_stackView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor], [_stackView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
...@@ -94,8 +95,6 @@ CGFloat kHorizontalMargin = 16.0f; ...@@ -94,8 +95,6 @@ CGFloat kHorizontalMargin = 16.0f;
constraintEqualToAnchor:self.trailingAnchor constraintEqualToAnchor:self.trailingAnchor
constant:-kHorizontalMargin], constant:-kHorizontalMargin],
]]; ]];
propertyReleaser_HistorySearchView_.Init(self, [HistorySearchView class]);
} }
return self; return self;
} }
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
#import "ios/chrome/browser/ui/history/history_search_view_controller.h" #import "ios/chrome/browser/ui/history/history_search_view_controller.h"
#include "base/ios/weak_nsobject.h"
#include "base/mac/scoped_nsobject.h"
#import "ios/chrome/browser/ui/history/history_search_view.h" #import "ios/chrome/browser/ui/history/history_search_view.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface HistorySearchViewController ()<UITextFieldDelegate> { @interface HistorySearchViewController ()<UITextFieldDelegate> {
// Delegate for forwarding interactions with the search view.
base::WeakNSProtocol<id<HistorySearchViewControllerDelegate>> _delegate;
// View displayed by the HistorySearchViewController // View displayed by the HistorySearchViewController
base::scoped_nsobject<HistorySearchView> _searchView; HistorySearchView* _searchView;
} }
// Action for the cancel button. // Action for the cancel button.
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
@end @end
@implementation HistorySearchViewController @implementation HistorySearchViewController
@synthesize delegate = _delegate;
@synthesize enabled = _enabled; @synthesize enabled = _enabled;
- (void)loadView { - (void)loadView {
_searchView.reset([[HistorySearchView alloc] init]); _searchView = [[HistorySearchView alloc] init];
[_searchView setSearchBarDelegate:self]; [_searchView setSearchBarDelegate:self];
[_searchView setCancelTarget:self action:@selector(cancelButtonClicked:)]; [_searchView setCancelTarget:self action:@selector(cancelButtonClicked:)];
self.view = _searchView; self.view = _searchView;
...@@ -36,14 +36,6 @@ ...@@ -36,14 +36,6 @@
[_searchView becomeFirstResponder]; [_searchView becomeFirstResponder];
} }
- (void)setDelegate:(id<HistorySearchViewControllerDelegate>)delegate {
_delegate.reset(delegate);
}
- (id<HistorySearchViewControllerDelegate>)delegate {
return _delegate;
}
- (void)setEnabled:(BOOL)enabled { - (void)setEnabled:(BOOL)enabled {
_enabled = enabled; _enabled = enabled;
[_searchView setEnabled:enabled]; [_searchView setEnabled:enabled];
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "base/ios/weak_nsobject.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
...@@ -165,7 +164,7 @@ class HistoryServiceFacade : public history::HistoryServiceObserver { ...@@ -165,7 +164,7 @@ class HistoryServiceFacade : public history::HistoryServiceObserver {
ios::ChromeBrowserState* browser_state_; // weak ios::ChromeBrowserState* browser_state_; // weak
// Delegate for HistoryServiceFacade. Serves as client for HistoryService. // Delegate for HistoryServiceFacade. Serves as client for HistoryService.
base::WeakNSProtocol<id<HistoryServiceFacadeDelegate>> delegate_; __weak id<HistoryServiceFacadeDelegate> delegate_;
base::WeakPtrFactory<HistoryServiceFacade> weak_factory_; base::WeakPtrFactory<HistoryServiceFacade> weak_factory_;
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
#include "ios/chrome/browser/ui/history/history_service_facade_delegate.h" #include "ios/chrome/browser/ui/history/history_service_facade_delegate.h"
#include "ios/chrome/browser/ui/history/history_util.h" #include "ios/chrome/browser/ui/history/history_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// The amount of time to wait for a response from the WebHistoryService. // The amount of time to wait for a response from the WebHistoryService.
static const int kWebHistoryTimeoutSeconds = 3; static const int kWebHistoryTimeoutSeconds = 3;
...@@ -128,7 +132,7 @@ HistoryServiceFacade::HistoryServiceFacade( ...@@ -128,7 +132,7 @@ HistoryServiceFacade::HistoryServiceFacade(
HistoryServiceFacade::~HistoryServiceFacade() { HistoryServiceFacade::~HistoryServiceFacade() {
query_task_tracker_.TryCancelAll(); query_task_tracker_.TryCancelAll();
web_history_request_.reset(); web_history_request_.reset();
delegate_.reset(); delegate_ = nil;
} }
void HistoryServiceFacade::QueryHistory(const base::string16& search_text, void HistoryServiceFacade::QueryHistory(const base::string16& search_text,
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <memory> #include <memory>
#import "base/mac/scoped_nsobject.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/history/core/browser/history_service.h" #include "components/history/core/browser/history_service.h"
...@@ -106,7 +105,7 @@ class HistoryServiceFacadeTest : public PlatformTest, ...@@ -106,7 +105,7 @@ class HistoryServiceFacadeTest : public PlatformTest,
bool success = browser_state_->CreateHistoryService(true); bool success = browser_state_->CreateHistoryService(true);
EXPECT_TRUE(success); EXPECT_TRUE(success);
mock_delegate_.reset([[MockHistoryServiceFacadeDelegate alloc] init]); mock_delegate_ = [[MockHistoryServiceFacadeDelegate alloc] init];
history_service_facade_.reset( history_service_facade_.reset(
new HistoryServiceFacade(browser_state_.get(), mock_delegate_)); new HistoryServiceFacade(browser_state_.get(), mock_delegate_));
} }
...@@ -176,7 +175,7 @@ class HistoryServiceFacadeTest : public PlatformTest, ...@@ -176,7 +175,7 @@ class HistoryServiceFacadeTest : public PlatformTest,
protected: protected:
web::TestWebThreadBundle thread_bundle_; web::TestWebThreadBundle thread_bundle_;
std::unique_ptr<TestChromeBrowserState> browser_state_; std::unique_ptr<TestChromeBrowserState> browser_state_;
base::scoped_nsobject<MockHistoryServiceFacadeDelegate> mock_delegate_; MockHistoryServiceFacadeDelegate* mock_delegate_;
std::unique_ptr<HistoryServiceFacade> history_service_facade_; std::unique_ptr<HistoryServiceFacade> history_service_facade_;
GURL visited_url_; GURL visited_url_;
base::Time visited_time_; base::Time visited_time_;
......
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include "ui/base/l10n/time_format.h" #include "ui/base/l10n/time_format.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace history { namespace history {
base::string16 GetRelativeDateLocalized(const base::Time& visit_time) { base::string16 GetRelativeDateLocalized(const base::Time& visit_time) {
......
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
// Table cell used in TabHistoryViewController. // Table cell used in TabHistoryViewController.
@interface TabHistoryCell : UICollectionViewCell @interface TabHistoryCell : UICollectionViewCell
@property(nonatomic, retain) CRWSessionEntry* entry; @property(strong, nonatomic) CRWSessionEntry* entry;
@property(nonatomic, readonly) UILabel* titleLabel; @property(weak, nonatomic, readonly) UILabel* titleLabel;
@end @end
// Header for a section of TabHistoryCells. // Header for a section of TabHistoryCells.
@interface TabHistorySectionHeader : UICollectionReusableView @interface TabHistorySectionHeader : UICollectionReusableView
@property(nonatomic, readonly) UIImageView* iconView; @property(weak, nonatomic, readonly) UIImageView* iconView;
@property(nonatomic, readonly) UIView* lineView; @property(weak, nonatomic, readonly) UIView* lineView;
@end @end
// Footer for a section of TabHistoryCells. // Footer for a section of TabHistoryCells.
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#import "ios/chrome/browser/ui/history/tab_history_cell.h" #import "ios/chrome/browser/ui/history/tab_history_cell.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
...@@ -12,6 +11,10 @@ ...@@ -12,6 +11,10 @@
#import "ios/web/navigation/crw_session_entry.h" #import "ios/web/navigation/crw_session_entry.h"
#include "ios/web/public/navigation_item.h" #include "ios/web/public/navigation_item.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Header horizontal layout inset. // Header horizontal layout inset.
const CGFloat kHeaderHorizontalInset = 16; const CGFloat kHeaderHorizontalInset = 16;
...@@ -40,8 +43,8 @@ NS_INLINE CGFloat HeaderLineRadius() { ...@@ -40,8 +43,8 @@ NS_INLINE CGFloat HeaderLineRadius() {
} }
@implementation TabHistoryCell { @implementation TabHistoryCell {
base::scoped_nsobject<CRWSessionEntry> _entry; CRWSessionEntry* _entry;
base::scoped_nsobject<UILabel> _titleLabel; UILabel* _titleLabel;
} }
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
...@@ -61,7 +64,7 @@ NS_INLINE CGFloat HeaderLineRadius() { ...@@ -61,7 +64,7 @@ NS_INLINE CGFloat HeaderLineRadius() {
} }
- (void)commonInitialization { - (void)commonInitialization {
_titleLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]); _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[_titleLabel setTextColor:UIColorFromRGB(kTitleTextRGB)]; [_titleLabel setTextColor:UIColorFromRGB(kTitleTextRGB)];
[_titleLabel [_titleLabel
setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]]; setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]];
...@@ -77,11 +80,11 @@ NS_INLINE CGFloat HeaderLineRadius() { ...@@ -77,11 +80,11 @@ NS_INLINE CGFloat HeaderLineRadius() {
} }
- (CRWSessionEntry*)entry { - (CRWSessionEntry*)entry {
return [[_entry retain] autorelease]; return _entry;
} }
- (void)setEntry:(CRWSessionEntry*)entry { - (void)setEntry:(CRWSessionEntry*)entry {
_entry.reset([entry retain]); _entry = entry;
NSString* title = nil; NSString* title = nil;
web::NavigationItem* navigationItem = [_entry navigationItem]; web::NavigationItem* navigationItem = [_entry navigationItem];
...@@ -99,12 +102,12 @@ NS_INLINE CGFloat HeaderLineRadius() { ...@@ -99,12 +102,12 @@ NS_INLINE CGFloat HeaderLineRadius() {
} }
- (UILabel*)titleLabel { - (UILabel*)titleLabel {
return [[_titleLabel retain] autorelease]; return _titleLabel;
} }
- (void)prepareForReuse { - (void)prepareForReuse {
[super prepareForReuse]; [super prepareForReuse];
_entry.reset(nil); _entry = nil;
[_titleLabel setText:nil]; [_titleLabel setText:nil];
[self setAccessibilityLabel:nil]; [self setAccessibilityLabel:nil];
} }
...@@ -112,28 +115,28 @@ NS_INLINE CGFloat HeaderLineRadius() { ...@@ -112,28 +115,28 @@ NS_INLINE CGFloat HeaderLineRadius() {
@end @end
@implementation TabHistorySectionHeader { @implementation TabHistorySectionHeader {
base::scoped_nsobject<UIImageView> _iconView; UIImageView* _iconView;
base::scoped_nsobject<UIView> _lineView; UIView* _lineView;
} }
- (UIImageView*)iconView { - (UIImageView*)iconView {
return [[_iconView retain] autorelease]; return _iconView;
} }
- (UIView*)lineView { - (UIView*)lineView {
return [[_lineView retain] autorelease]; return _lineView;
} }
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
CGRect iconFrame = CGRectMake(0, 0, kSiteIconViewWidth, kSiteIconViewWidth); CGRect iconFrame = CGRectMake(0, 0, kSiteIconViewWidth, kSiteIconViewWidth);
_iconView.reset([[UIImageView alloc] initWithFrame:iconFrame]); _iconView = [[UIImageView alloc] initWithFrame:iconFrame];
[self addSubview:_iconView]; [self addSubview:_iconView];
UIColor* lineColor = UIColorFromRGB(kHeaderLineRGB); UIColor* lineColor = UIColorFromRGB(kHeaderLineRGB);
_lineView.reset([[UIView alloc] initWithFrame:CGRectZero]); _lineView = [[UIView alloc] initWithFrame:CGRectZero];
[[_lineView layer] setCornerRadius:HeaderLineRadius()]; [[_lineView layer] setCornerRadius:HeaderLineRadius()];
[_lineView setBackgroundColor:lineColor]; [_lineView setBackgroundColor:lineColor];
[self addSubview:_lineView]; [self addSubview:_lineView];
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/objc_property_releaser.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/history/tab_history_view_controller.h" #import "ios/chrome/browser/ui/history/tab_history_view_controller.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h"
...@@ -21,6 +20,10 @@ ...@@ -21,6 +20,10 @@
#import "ui/gfx/ios/NSString+CrStringDrawing.h" #import "ui/gfx/ios/NSString+CrStringDrawing.h"
#include "ui/gfx/ios/uikit_util.h" #include "ui/gfx/ios/uikit_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
static const CGFloat kTabHistoryMinWidth = 250.0; static const CGFloat kTabHistoryMinWidth = 250.0;
static const CGFloat kTabHistoryMaxWidthLandscapePhone = 350.0; static const CGFloat kTabHistoryMaxWidthLandscapePhone = 350.0;
...@@ -44,17 +47,15 @@ static const CGFloat kHeightPercentage = 0.85; ...@@ -44,17 +47,15 @@ static const CGFloat kHeightPercentage = 0.85;
// Container view of the history entries table. // Container view of the history entries table.
UIView* tabHistoryTableViewContainer_; UIView* tabHistoryTableViewContainer_;
base::mac::ObjCPropertyReleaser propertyReleaser_TabHistoryPopupController_;
} }
// Determines the width for the popup depending on the device, orientation, and // Determines the width for the popup depending on the device, orientation, and
// CRWSessionEntrys to display. // CRWSessionEntrys to display.
- (CGFloat)calculatePopupWidth:(NSArray*)entries; - (CGFloat)calculatePopupWidth:(NSArray*)entries;
@property(nonatomic, retain) @property(nonatomic, strong)
TabHistoryViewController* tabHistoryTableViewController; TabHistoryViewController* tabHistoryTableViewController;
@property(nonatomic, retain) UIView* tabHistoryTableViewContainer; @property(nonatomic, strong) UIView* tabHistoryTableViewContainer;
@end @end
...@@ -69,9 +70,6 @@ static const CGFloat kHeightPercentage = 0.85; ...@@ -69,9 +70,6 @@ static const CGFloat kHeightPercentage = 0.85;
DCHECK(parent); DCHECK(parent);
self = [super initWithParentView:parent]; self = [super initWithParentView:parent];
if (self) { if (self) {
propertyReleaser_TabHistoryPopupController_.Init(
self, [TabHistoryPopupController class]);
tabHistoryTableViewController_ = [[TabHistoryViewController alloc] init]; tabHistoryTableViewController_ = [[TabHistoryViewController alloc] init];
[tabHistoryTableViewController_ setSessionEntries:entries]; [tabHistoryTableViewController_ setSessionEntries:entries];
...@@ -168,7 +166,6 @@ static const CGFloat kHeightPercentage = 0.85; ...@@ -168,7 +166,6 @@ static const CGFloat kHeightPercentage = 0.85;
- (void)dealloc { - (void)dealloc {
[tabHistoryTableViewContainer_ removeFromSuperview]; [tabHistoryTableViewContainer_ removeFromSuperview];
[super dealloc];
} }
@end @end
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// TODO(crbug.com/546355): Convert this class to use an array of // TODO(crbug.com/546355): Convert this class to use an array of
// NavigationEntries. // NavigationEntries.
@property(nonatomic, retain) NSArray* sessionEntries; @property(nonatomic, strong) NSArray* sessionEntries;
// Returns the optimal height needed to display the session entries. // Returns the optimal height needed to display the session entries.
// The height returned is usually less than the |suggestedHeight| unless // The height returned is usually less than the |suggestedHeight| unless
......
...@@ -4,11 +4,8 @@ ...@@ -4,11 +4,8 @@
#import "ios/chrome/browser/ui/history/tab_history_view_controller.h" #import "ios/chrome/browser/ui/history/tab_history_view_controller.h"
#import "base/ios/weak_nsobject.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/objc_property_releaser.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
#include "ios/chrome/browser/ui/commands/ios_command_ids.h" #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
...@@ -20,6 +17,10 @@ ...@@ -20,6 +17,10 @@
#include "ios/web/public/navigation_item.h" #include "ios/web/public/navigation_item.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace { namespace {
// Visible percentage of the last visible row on the Tools menu if the // Visible percentage of the last visible row on the Tools menu if the
...@@ -217,16 +218,16 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind ...@@ -217,16 +218,16 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind
@end @end
@interface TabHistoryViewController ()<MDCInkTouchControllerDelegate> { @interface TabHistoryViewController ()<MDCInkTouchControllerDelegate> {
base::scoped_nsobject<MDCInkTouchController> _inkTouchController; MDCInkTouchController* _inkTouchController;
base::scoped_nsobject<NSArray> _partitionedEntries; NSArray* _partitionedEntries;
base::scoped_nsobject<NSArray> _sessionEntries; NSArray* _sessionEntries;
} }
@end @end
@implementation TabHistoryViewController @implementation TabHistoryViewController
- (NSArray*)sessionEntries { - (NSArray*)sessionEntries {
return [[_sessionEntries retain] autorelease]; return _sessionEntries;
} }
#pragma mark Public Methods #pragma mark Public Methods
...@@ -235,7 +236,7 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind ...@@ -235,7 +236,7 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind
DCHECK(suggestedHeight >= kCellHeight); DCHECK(suggestedHeight >= kCellHeight);
CGFloat optimalHeight = 0; CGFloat optimalHeight = 0;
for (NSArray* sectionArray in _partitionedEntries.get()) { for (NSArray* sectionArray in _partitionedEntries) {
NSUInteger sectionItemCount = [sectionArray count]; NSUInteger sectionItemCount = [sectionArray count];
for (NSUInteger i = 0; i < sectionItemCount; ++i) { for (NSUInteger i = 0; i < sectionItemCount; ++i) {
CGFloat proposedHeight = optimalHeight + kCellHeight; CGFloat proposedHeight = optimalHeight + kCellHeight;
...@@ -263,8 +264,8 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind ...@@ -263,8 +264,8 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind
} }
- (instancetype)init { - (instancetype)init {
base::scoped_nsobject<TabHistoryViewControllerLayout> layout( TabHistoryViewControllerLayout* layout =
[[TabHistoryViewControllerLayout alloc] init]); [[TabHistoryViewControllerLayout alloc] init];
return [self initWithCollectionViewLayout:layout]; return [self initWithCollectionViewLayout:layout];
} }
...@@ -286,8 +287,8 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind ...@@ -286,8 +287,8 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind
forSupplementaryViewOfKind:UICollectionElementKindSectionFooter forSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:footerIdentifier]; withReuseIdentifier:footerIdentifier];
_inkTouchController.reset( _inkTouchController =
[[MDCInkTouchController alloc] initWithView:collectionView]); [[MDCInkTouchController alloc] initWithView:collectionView];
[_inkTouchController setDelegate:self]; [_inkTouchController setDelegate:self];
[_inkTouchController addInkView]; [_inkTouchController addInkView];
} }
...@@ -370,7 +371,7 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind ...@@ -370,7 +371,7 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind
} }
- (void)setSessionEntries:(NSArray*)sessionEntries { - (void)setSessionEntries:(NSArray*)sessionEntries {
_sessionEntries.reset([sessionEntries retain]); _sessionEntries = sessionEntries;
std::string previousHost; std::string previousHost;
...@@ -406,7 +407,7 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind ...@@ -406,7 +407,7 @@ layoutAttributesForSupplementaryViewOfKind:(NSString*)kind
if (![partitionedEntries count]) if (![partitionedEntries count])
partitionedEntries = nil; partitionedEntries = nil;
_partitionedEntries.reset([partitionedEntries retain]); _partitionedEntries = partitionedEntries;
} }
#pragma mark MDCInkTouchControllerDelegate #pragma mark MDCInkTouchControllerDelegate
......
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